sorting examples
play

Sorting Examples CS 202 Department of Computer Engineering Bilkent - PowerPoint PPT Presentation

Sorting Examples CS 202 Department of Computer Engineering Bilkent University Slides adapted from Aybar Acar Spring 2015 Spring 2015 2015, CS 202 (Bilkent University) c 1 / 14 Playing Cards Spring 2015 2015, CS 202 (Bilkent


  1. Sorting Examples CS 202 Department of Computer Engineering Bilkent University Slides adapted from Aybar Acar Spring 2015 Spring 2015 � 2015, CS 202 (Bilkent University) c 1 / 14

  2. Playing Cards Spring 2015 � 2015, CS 202 (Bilkent University) c 2 / 14

  3. Insertion Sort: Random Input Outer : j = 1 Inner : i = 0 Ops : 0 Spring 2015 � 2015, CS 202 (Bilkent University) c 3 / 14

  4. Insertion Sort: Sorted Input Outer : j = 1 Inner : i = 0 Ops : 0 Spring 2015 � 2015, CS 202 (Bilkent University) c 4 / 14

  5. Insertion Sort: Reverse Sorted Input Outer : j = 1 Inner : i = 0 Ops : 0 Spring 2015 � 2015, CS 202 (Bilkent University) c 5 / 14

  6. Selection Sort: Random Input Outer : j = − 1 Inner : i = − 1 Ops : 0 Spring 2015 � 2015, CS 202 (Bilkent University) c 6 / 14

  7. Selection Sort: Sorted Input Outer : j = − 1 Inner : i = − 1 Ops : 0 Spring 2015 � 2015, CS 202 (Bilkent University) c 7 / 14

  8. Selection Sort: Reverse Sorted Input Outer : j = − 1 Inner : i = − 1 Ops : 0 Spring 2015 � 2015, CS 202 (Bilkent University) c 8 / 14

  9. Bubble Sort: Random Input Outer : j = − 1 Inner : i = − 1 Ops : 0 Spring 2015 � 2015, CS 202 (Bilkent University) c 9 / 14

  10. Bubble Sort: Reverse Sorted Input Outer : j = − 1 Inner : i = − 1 Ops : 0 Spring 2015 � 2015, CS 202 (Bilkent University) c 10 / 14

  11. Merge Sort: Merge Step p q r A: ... ... 1 4 5 7 2 3 6 8 ... ... Spring 2015 � 2015, CS 202 (Bilkent University) c 11 / 14

  12. Merge Sort: Merge Step p q r A: ... ... 1 4 5 7 2 3 6 8 ... ... 0 1 2 3 4 0 1 2 3 4 L: R: 1 4 5 7 2 3 6 8 8 8 Spring 2015 � 2015, CS 202 (Bilkent University) c 11 / 14

  13. Merge Sort: Merge Step 0 1 2 3 4 0 1 2 3 4 1 4 5 7 2 3 6 8 8 8 p q r ... ... 1 4 5 7 2 3 6 8 ... ... Spring 2015 � 2015, CS 202 (Bilkent University) c 12 / 14

  14. Merge Sort: Random Input Spring 2015 � 2015, CS 202 (Bilkent University) c 13 / 14

  15. Merge Sort: Reverse Sorted Input Spring 2015 � 2015, CS 202 (Bilkent University) c 14 / 14

Recommend


More recommend