A few recommendations for Data Structures and Algorithms:
Basic Sorting and Searching Algorithms for Arrays, at a glance
Merge SortMerge SortMerge sort is based on Divide and conquer method. It takes the list to be sorted and divide it in half to create two unsorted lists. The two unsorted lists are then sorted and merged to get a sorted list. The two unsorted lists are sorted by continually calling the mergesort algorithm; we eventually get a list of size 1 which is already sorted. The two lists of size 1 are then merged. Algorithm:This is a divide and conquer algorithm. This works as follows – 1. Divide the input which we have to sort into two parts in the middle. Call it the left part and right part. Example: Say the input is 10 32 45 78 91 1 0 16 then the left part will be 10 32 45  78 and the right part will be 91 1 0 6. 2. Sort each of them separately. Note that here sort does not mean to sort it using some other method. We use the same function recursively. 3. Then merge the two sorted parts. Input the total number of elements that are there in an array (number_of_elements). Input the array (array[number_of_elements]). Then call the function MergeSort() to sort the input array. MergeSort() function sorts the array in the range [left,right] i.e. from index left to index right inclusive. Merge() function merges the two sorted parts. Sorted parts will be from [left, mid] and [mid+1, right]. After merging output the sorted array. MergeSort() function: It takes the array, leftmost and rightmost index of the array to be sorted as arguments. Middle index (mid) of the array is calculated as (left + right)/2. Check if (left<right) cause we have to sort only when left<right because when left=right it is anyhow sorted. Sort the left part by calling MergeSort() function again over the left part MergeSort(array,left,mid) and the right part by recursive call of MergeSort function as MergeSort(array,mid + 1, right). Lastly merge the two arrays using the Merge function. Merge() function: (Explained in greater detail within the tutorial document) It takes the array, leftmost , middle and rightmost index of the array to be merged as arguments. Finally copy back the sorted array to the original array. Properties:Best case – When the array is already sorted O(nlogn). Worst case – When the array is sorted in reverse order O(nlogn). Average case – O(nlogn). Extra space is required, so space complexity is O(n) for arrays and O(logn) for linked lists. Merge Sort Visualization : Here's a Java Applet Visualization which might help you get a clearer idea of what exactly happens in mergesort. Complete Tutorial : Merge Sort  C Program Source Code#include<stdio.h>
MCQ Quiz: Efficient Sorting Algorithms Quick sort, Merge Sort, Heap Sort Check how much you can score!Your score will be emailed to the address filled up by you. MCQ Quiz More efficient sorting algorithmsGoogle Spreadsheet Form Related Tutorials :
Merge Sort Visualization : Here's a Java Applet Visualization which might help you get a clearer idea of what exactly happens in mergesort. Testing Zone For ProgrammersTry out our online MultipleChoiceQuestion tests in Programming and Computer Science!Recommended books for learning Computer Science, learning high quality programming, and preparing for programming interviews:These are the standard sources of the knowledge expected from candidates interviewing at Google, Microsoft, Facebook, Amazon and other startups and toptier technology companies. The books by Cormen or Sedgewick (a standard part of the undergraduate curriculum) are sufficient for this part of the preparation. Google specially, loves to focus on algorithmic questions.
 Tutorials on Sorting at a glance
