Download presentation
1
Lesson Plan - 2: Bubble Sort, Quick Sort
Exchange Sorts Lesson Plan - 2: Bubble Sort, Quick Sort
2
Contents Evocation Objective Introduction Bubble Sort
Bubble Sort Algorithm Quick Sort Quick Sort Algorithm Mind Map Summary
3
Evocation
4
Objective To study the basic knowledge of bubble sort algorithm
To learn about the basic concept of quick sort algorithm
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
6
Bubble Sort Examples
7
Bubble Sort Algorithm
8
Evocation
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
10
Quick Sort Hoare’s 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
11
Quick Sort Partitions
12
Quick Sort Algorithm
20
Hidden picture puzzle Easter
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
22
Mind Map Exchange Sort Bubble Sort Quick Sort Algorithm Examples
Partitions Quick Sort Algorithms Straight Insertion Module Quick Sort Algorithm Determine median of three
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
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
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.