Skip to main content

Posts

Showing posts from November, 2020

C++ Performance Optimization - Using Better Algorithms

Performance optimization is a hot topic in C++ language. I'm going to talk about this topic from simple to advanced techniques in a series of articles. Some tips can be simple but from a performance point of view the impact can be huge.

C++ Is It Safe to Delete a NULL pointer?

Simple answer is YES . It is perfectly safe to delete a null pointer. In C++ delete operator is used to deallocate the memory block pointed by the pointer by releasing the memory allocated via new operator. For basic information on delete operator you can visit this article . 

C++ Switch vs If Else Performance

In this article I'm not going to explain the basics of switch and if else statements. But I'm going give some points based on my experience from a performance point of view. When it comes to performance my rule of thumb is always measure the execution time and decide which solution perform better rather than going with theory. Because you might not know how the complier will optimize or based on other factors it might not work as per the theory.

C++ Find Middle Element of a Linked List

This is a famous coding interview question that every programmer suppose to know. Here I am going to look at two different answers. First one is the obvious one, of course not the answer that the interviewer is looking for. Second one is the smart answer.