So I have decided to put aside Sorting for some time and intended to discuss a few tidbits with you. This time I would share some interesting material on the swapping of two different variables. Swapping is one of the most frequently occurring processes taking place inside a Computer Machine. Then in many other Programs and Algorithms, swapping takes place as a sub-process. Sometimes it is user defined and sometimes not. So let us see how can we improve the swapping process.
Posts Tagged ‘c++’
Working with pointers in C requires a lot of practice to avoid memory leaks and dangling pointers. We discussed them in length in the previous post, Pointer Hazards in C . In object oriented paradigm, whenever you declare an object of user defined class type, a special function known as constructor is automatically invoked. Similarly when you want to copy an object to another object, copy constructor gets invoked. Writing an efficient and error free constructor is essential to the construction of a good program. In this post I shall explain how to write a good and efficient constructor and a copy constructor, paying special attention to pointer hazards.
After some really heavy programming concepts, let us explore some lighter side of programming for a while and then we’ll return back to where we started. This time we would have a go at Cstrings. Cstrings are character arrays having a null terminator ‘\0’ at its end. Right. So lets see what we are trying to do.
After talking about constructors and destructors, next up in my series on object oriented programming is how to use setters. Setters are functions that are used to change the values of data members inside classes. They are very important, as they are the only route through which we can change the value of our data members after an object is instantiated.
Sorting means to arrange the given list of data in any particular form or order. Generally sorting is done on the basis of numerical order and alphabetical or lexicographical order. Here we shall be discussing only the numerical order. In Computer Science, sorting has always been given special attention and interest because it is a vital part of many other fundamental processes. Still now, research is going on to improve the sorting techniques and numerous algorithms have been presented for this purpose. Some basic ones which are commonly used are selection sort, bubble sort, insertion sort, merge sort, shell sort, quick sort, etc.