Merge Sublists

Objective

The objective of this experiment it to demonstrate to the user that is possible to sort a list by repeatedly merging adjacent sorted subarray.

Experiment Setup

You are provided with one array , the each element in the array has indices marked on either side of it. The number on the left side of element indicates its index.

Clicking on the index boundary selects that index, clicking a selected boundary will deselect it.

You can select three of these indices. If you choose three indices "i","j"and "k", such that "i" < "j" < "k" , then the two sublists will be "i" to "j", and "j" to "k", both excluding the the element at the last index, that is first list does not have jth element and second sublist will not have kth element.

Both the selected sublists and resultant sublist will be highlighted in green if they are sorted and red otherwise. The "Merge" button will merge the selected sublists. Merging unsorted sublist will not give sorted result.

Procedure

  1. Pick the first index by clicking on the index boundaries. Similarly pick second index, make sure all elements between first and second index are sorted. Third index should be picked in the same fashion.
  2. Click "Merge" and observe the sublists. See if the whole array becomes sorted or not. If array is not sorted repeat the above steps.