Searching and Sorting AlgorithmsSearching and Sorting Algorithms— Problem Solving with Algorithms
The Sequential Search
Sequential Search is a type of search where data is not kept in a certain order in our data structure and in the worst case we will visit each data in the array for search. The best example of this is the Linear Search algorithm.
The Binary Search
Binary Search is the process of searching for the desired value in an ordered array. It is one of the most familiar search algorithms in the programming world.
Sorting
Bubble sort
Bubble sort is one of the simplest sorting algorithms. In this comparison-based algorithm, each element in the list is compared with the next element. If the value of the first element is greater than the value of the second element, the two elements are swapped.
The Selection Sort
With the selection sort algorithm, in an unsorted list, the smallest element is found in each iteration. At the end of the iteration, the smallest element determined is replaced with the element at the beginning of the list. It is not included in the next iteration. In the second iteration, the smallest of the array elements is found again and this time it replaces the second element in the list and continues in this way until the list is sorted.
Insertion Sort
Insertion Sort is an improved version of the Bubble Sort algorithm. It leaves the first element of the array to be sorted, and takes the next elements (sub-array) in order and puts them in the appropriate place in the order. With the Instertion Sort algorithm, the elements of the array are sorted from smallest to largest. The new version of the array is printed on the last screen.