Lesson Plan - 2: Bubble Sort, Quick Sort. Contents  Evocation  Objective  Introduction  Bubble Sort  Bubble Sort Algorithm  Quick Sort  Quick Sort

  • View
    221

  • Download
    5

Embed Size (px)

Transcript

  • Slide 1
  • Lesson Plan - 2: Bubble Sort, Quick Sort
  • Slide 2
  • Contents Evocation Objective Introduction Bubble Sort Bubble Sort Algorithm Quick Sort Quick Sort Algorithm Mind Map Summary
  • Slide 3
  • Evocation
  • Slide 4
  • Objective To study the basic knowledge of bubble sort algorithm To learn about the basic concept of quick sort algorithm
  • Slide 5
  • Introduction-Exchange Sort Exchange the elements that are out of order until the entire list is sorted Bubble Sort List at any movement is divided into two sublists: Sorted and Unsorted Smallest element is bubbled from unsorted sublist and moved to sorted sublist Given a list of n elements, bubble sort requires n-1 passes to sort data
  • Slide 6
  • Bubble Sort Examples
  • Slide 7
  • Bubble Sort Algorithm
  • Slide 8
  • Evocation
  • Slide 9
  • Quick Sort Quick sort is an exchange sort in which a pivot key is placed in its correct position in the array while rearranging other elements widely discussed across the list Each iteration of quick sort selects an element known as pivot Divide the lists into three groups Partition of elements whose keys are less than pivots key Pivot element is placed in correct location in list Partition of elements greater than or equal to pivots key Quick sorting left partition followed by sorting right partition
  • Slide 10
  • Quick Sort Hoares Algorithm Select pivot key as first element in list Singleton Algorithm Select pivot key as median value of three elements left, right and element in middle of list Once median value is determined it is exchanged with left element
  • Slide 11
  • Quick Sort Partitions
  • Slide 12
  • Quick Sort Algorithm
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Hidden picture puzzle Easter
  • Slide 21
  • Quick Sort Algorithm To determine correct position of pivot element Start from two ends of array towards middle Use median value of three elements Before exchange starts, median element in middle position and smallest of three element used to determine median in right location After median left algorithm, median is in left position and smallest in middle location Pivot key is moved to hold area to facilitate processing
  • Slide 22
  • Mind Map Exchange Sort Bubble SortQuick Sort Algorith m Example s Quick Sort Partitions Quick Sort Algorithms Straight Insertion Module Determin e median of three Quick Sort Algorithm
  • Slide 23
  • Summary Exchange sort systematically exchange elements that are out of order until list is sorted Two methods of exchange sorts are bubble sort and quick sort In bubble sort, list at any movement is divided into two sublists: Sorted and Unsorted In each pass the smallest element is bubbled from unsorted sublist and moved to sorted sublist In quick sort, list is continuously divided into smaller sublists and exchanging takes place between elements that are out of order
  • Slide 24
  • Summary Each pass of quick sort selects a pivot and divides the list into three groups Partition of elements whose key is less than pivots key Pivot element is placed in correct location in list Partition of elements greater than or equal to pivots key Quick sorting left partition followed by sorting right partition Quick sort algorithm is mainly based on three steps straight insertion module, determine median of three and quick sort