1 / 113

Sorting & Recursion

Sorting & Recursion. Briana B. Morrison Adapted from Alan Eugenio & William J. Collins. Topics. Review Insertion Sort Selection Sort Bubble Sort This term Tree Sort Heap Sort Radix Sort New Merge Sort Quick Sort. Selection Sort.

Download Presentation

Sorting & Recursion

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Sorting & Recursion Briana B. Morrison Adapted from Alan Eugenio & William J. Collins

  2. Topics • Review • Insertion Sort • Selection Sort • Bubble Sort • This term • Tree Sort • Heap Sort • Radix Sort • New • Merge Sort • Quick Sort Sorting

  3. Sorting

  4. Sorting

  5. Sorting

  6. Sorting

  7. Sorting

  8. Sorting

  9. Sorting

  10. Sorting

  11. Sorting

  12. Sorting

  13. Sorting

  14. Selection Sort • Loops through input and “selects” smallest/largest value and swaps with current location • Worst case O(n2) • Average case O(n2) Sorting

  15. Sorting

  16. Sorting

  17. Sorting

  18. Sorting

  19. Sorting

  20. Sorting

  21. Bubble Sort • Loops through input doing “adjacent” comparisons • Biggest/smallest element “bubble” to top/bottom • Worst case O(n2) • Average case O(n2) Sorting

  22. Sorting

  23. Sorting

  24. Sorting

  25. Sorting

  26. Sorting

  27. Sorting

  28. Sorting

  29. Sorting

  30. Sorting

  31. Sorting

  32. Sorting

  33. Sorting

  34. Sorting

  35. Sorting

  36. Sorting

  37. Sorting

  38. Sorting

  39. Sorting

  40. Sorting

  41. Sorting

  42. Sorting

  43. Sorting

  44. Sorting

  45. Sorting

  46. Sorting

  47. Sorting

  48. FOR TREE SORT, EACH INSERTION TAKES LOGARITHMIC TIME AT MOST, SO FOR n INSERTIONS worstTime(n) IS O(n log n). therefore… averageTime(n) IS O(n log n) Sorting

  49. Sorting

  50. Sorting

More Related