Class Template Specialization in C++

Written by Raza. Posted in C++

Computer Programming Code in Object Oriented Paradigm

We have been discussing templates in detail for over two weeks. First we explored function templates with a single parameter, then with multiple parameters and also learnt how to specialize template functions.  Currently we are exploring class templates. Today we shall see how we can specialize class templates for a particular data type. They are specialized like function templates and behave identically as well but they are declared with a different syntax. 

Selection Sort, the Basic Sorting Algorithm

Written by Raza. Posted in C++

selection sort algorithm c++

 

Selection sort is one of the basic sorting Algorithms. It is pretty simple to understand and very good to implement on small amount of data. However, it becomes quite inefficient when working with large lists.  

Selection Sort uses the concept of in-place sorting. It means that the data is sorted by shuffling it within the list. First I shall try to explain the algorithm and then together we would try to carve out of it a basic source code.

Best Online Resources to Practice C++

Written by Raza. Posted in C++

Students and newbies in C++ keep on looking forward to programming problems and quizzes which enable them to become a good programmer. There are some very good online forums where a wide range of problems with  different levels of difficulty could be found and practiced, I would share some of them here.

Function Template Specialization in C++

Written by Raza. Posted in C++

Computer with overloaded files

Templates are a very powerful tool in programming. They constitute the so called feature of Type Independent or Generic Programming. We have seen that using templates with multiple parameters or a single parameter, we can save our time and energy and write a code in a generic manner instead of writing it for each and every data type. However, as a thing becomes powerful, there are also certain potential dangers associated with it. One such scenario arises with templates quite frequently while its solution lies in template specialization. This type of specialization s known as Complete Specialization.

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.