mirror of
https://github.com/dholerobin/Lecture_Notes.git
synced 2025-07-01 13:06:29 +00:00
Update 3BinaryInsertionSort.md
This commit is contained in:
parent
629d2b6df2
commit
7dbc681720
@ -6,16 +6,16 @@ After finding the correct index, we right-shift elements and insert the element
|
||||
|
||||
For an array `[1 4 5 9 10 7 14]`, let's start binary insertion sort from element 7,
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||
Similarly, for $14$, but it is already at its right position.
|
||||
|
||||
@ -70,7 +70,7 @@ Merging lists of similar sizes tend to perform better than the other case, due t
|
||||
|
||||
Now, let's discuss some criteria we use to merge runs efficiently.
|
||||
|
||||

|
||||

|
||||
|
||||
**Note:** $|X|$ is a size of a run X.
|
||||
|
||||
@ -84,13 +84,13 @@ Whenever we push a new run into the stack, we check for these criteria and merge
|
||||
|
||||
Below is a stack of runs, for the shake of simplicity only length of runs are shown.
|
||||
|
||||

|
||||

|
||||
|
||||
Merge until none of these criteria satisfy. Criteria 1 is satisfying so merge,
|
||||
|
||||

|
||||

|
||||
Again, criteria 1 is satisfying so again merge,
|
||||

|
||||

|
||||
|
||||
No criteria are satisfying now, so stop.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user