Top Algorithm Interview Questions

1) Selection Sort

-> Selection sort is an algorithm of sorting an array where it loop from the start of the array, check through other elements to find the minimum value. After the end of the first iteration, the minimum value is swapped with the current element. The iteration then continues from the 2nd element and so on.

2) Merge Sort

-> A comparison based sorting algorithm.
-> Divides entire dataset into groups of at most two.
-> Compares each number once at a time, moving the smallest number to left of the pair.
-> Once all pairs sorted it then compares left most elements of the two leftmost pairs creating a sorted group of four with the smallest  numbers on the left and the largest ones on the right.
-> This process is repeated until there is only one set.

3) Quick Sort

-> A comparison based sorting algorithm.
-> Divides the entire dataset in half by selecting the average element and putting all smaller elements to the left of the average.
-> It repeats the process on the left side until it is comparing only two elements at which point the left side is sorted.
-> When the left side is finished sorting it performs the same operation on the right side.
-> Computer architecture favors quick sort process.

4) Binary Search

->Binary search is a technique used to search sorted data sets. It works by selecting the middle element of data set, essentially the median and compares it against a target value. If the value matches it will return success.
-> If the target value is higher than the value of the probe element it will take the upper half of the dataset and perform the same operation against it.
-> Likewise, if the target value is lower than the value of the probe element it will perform the operation against the lower half. It will continue to halve the data set with each iteration until the value has been found or until it can no longer split the data set.

Leave a Reply

Your email address will not be published. Required fields are marked *