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.
Posts Tagged ‘algorithms’
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.
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.