Sorting Interview Quetions
Sorting Interview Quetions
4. Merge Sort:
Example 1: Combining two sorted lists of names. If you have two class
lists, one for boys and one for girls, and both are already alphabetically
sorted, you combine them by taking the first name from each list and
comparing, always adding the smaller name first.
1. Bubble Sort:
Example 2: Organizing kids by height in a line. You start from the
beginning of the line, comparing two kids, and if the one on the left is
taller, you switch their places. You do this over and over until everyone is
lined up by height.
2. Selection Sort:
Example 2: Arranging toys by size. You find the smallest toy, place it in
the first spot, then find the next smallest and put it next to the first,
repeating until all toys are lined up by size.