Author Archive

Gnome Sort, a Variant of Insertion Sort

Written by Raza. Posted in C++

The Gnome Sort Algorithm

Last time, we discussed a sorting technique known as insertion sort. It is a very good sorting procedure and the simplest sorting algorithm for short lists and small amount of data. For larger lists, it’s running time increases exponentially which renders it inefficient. A number of variations have also been introduced to insertion sort, some of which are more efficient and some are equally good. Shell sort and Gnome Sort are two such variations. I prefer Gnome Sort so I will explain it to you in this article.

Templates with Multiple Parameters

Written by Raza. Posted in C++

computers network binary code

We have learnt that Templates in C are a very powerful feature. They constitute the concept of Generic Programming or Type Independent Programming. Last time, we saw templates that have one parameter or one generic type. They have the limitation that only one type of data type can be processed at a time. To solve that problem, we use templates with more than one type of parameters. Such multiple type templates allow more than one type of data types to be process at once. 

Top 10 Online Resources to Learn and Improve C++

Written by Raza. Posted in C++

computer programming network

For Novice and Beginners, C seems a very difficult and challenging language to learn. I won’t say that this is incorrect in entirety though constant practice and hard work makes it easier to code in C .

Here I shall briefly describe some of the Online Resources which I have used personally and found extremely useful. These include resources for learning, debugging to problem solving.

Use of Explicit Constructor in Our Class

Written by Raza. Posted in C++

explicit constructor c++

C++ is a very powerful and fast language. One potential danger because of this is the ability of language to call methods and convert data into other types automatically without asking the programmer. So the programmer has an added responsibility of keeping an eye on the compiler and watch out for all such errors. One such common problem is the implicit conversion through a constructor. To avoid that, we use an explicit constructor in C++. Let us see a sample code for that and then I shall explain to you what actually happens. 

Overloading Indexing Operator ([ ])

Written by Raza. Posted in C++

overloading indexing operator in c++

Up till now we have overloaded assignment operator and then the addition operator. One another operator which we quite frequently use in our program and thus need to redefine for ourselves is the indexing operator ([ ]). Indexing operator in in fact used to dereference a given index of the array. After overloading indexing operator, we can directly dereference the object for our particular index. Let us see how we can efficiently do this.