We have been playing with strings and doing some basic operations on string for the last two posts. Another such interesting operation with strings is finding one string in another string. There are a number of things to be checked while searching for a string as a substring of second one. We shall be explaining these steps and other details in the proceeding lines.
We saw how to match the two given strings last time and determine whether they first of them is less than, greater than or equal to the second string. We developed a simple string matching algorithm for that purpose. Similarly we also want to perform a number of other operations on our strings and need to find certain patterns and keys in them. Today we shall develop a simple character finding algorithm in a given string. Let us see which things we need to find out.
Human Beings like to play with string in their daily life. We deal with all sorts of alphabets and words and often try to compare them with one another. To check whether we have two given set of characters equal or not, we make use of string matching algorithms. To match the two given strings, we use then to look for equality in both the strings for the desired results. A simple string matching algorithm is to iterate over each alphabet and match correspondingly. Let us see in detail how we do that.
Two weeks ago, I explained to you a basic and easy sorting algorithm which was Selection Sort. Moving onwards, there is yet another basic algorithm by the name of Bubble Sort. It is known as Bubble sort because it brings the small values on the top of the list just like the light bubbles in water tend to come to the surface. Let us see how it works in depth.
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.