wavec022

insertion sort and merge sort

Mar 27th, 2020
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. Sorting-- insertion sort
  2.  
  3. Array(5,2,1,3,6,4)
  4. Call 5 sorted
  5. Shift 5 to the right, pointer now at index 2
  6. Shift 2 and 5 both over one so 1 is at index 0, pointer now at 3
  7. and so on and so forth
  8. it is O(n!)
  9.  
  10. Divide and conquer algorithm
  11. break down list of size n into n lists of 1
  12. merge sorted lists in a manner that produces a sorted list
  13.  
  14. =====
  15.  
  16. Merge sort
  17. Sort left half, sort right half, merge them
  18. looks like a tree
  19. so you end up with (1,2,5) and (3,4,6)
  20. then we compare from A to B and decide which one gets to go into the real list
Add Comment
Please, Sign In to add comment