Here is my take on the few of the most popular sorting and searching algorithms. My goal was to understand the general idea behind every algorithm and on the basic level why everything is happening so I can have less trouble implementing them in the future.
Bubble sort sorts the array by comparing two adjacent elements and swaps them if they are not in the intended order. Here order can be anything like increasing order or decreasing order. One of the easiest algorithms to learn.
Insertion sort works similar to the way you sort playing cards in your hands. The array is virtually split into a sorted and an unsorted part. Values from the unsorted part are picked and placed at the correct position in the sorted part.
The selection sort sorts an array by repeatedly finding the minimum element (considering ascending order) from unsorted part and putting it at the beginning.
The merge sort is one of the more advanced sorting algorithms that’s quite efficient in sorting large amounts of data. The algorithm uses the recursive function concept with 'Divide and Conquer' strategy to efficiently sort a given list of elements. One of my favorite.
Quick Sort algorithm follows Divide and Conquer approach. It divides elements into smaller parts based on some condition and performing the sort operations on those divided smaller parts.
Binary Search is a very simple, intuitive, yet efficient searching algorithm. The only caveat is that it works only sorted arrays, so some preprocessing on our data in order to sort it might be necessary.