• Save
Quick sort demo
Upcoming SlideShare
Loading in...5
×
 

Quick sort demo

on

  • 163 views

qa.zariga.com

qa.zariga.com

Statistics

Views

Total Views
163
Views on SlideShare
163
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Scanning from right to left the first number visited that has value less than 51, thus exchange both of them
  • Scanning from right to left the first number visited that has value less than 51, thus exchange both of them
  • Scanning from left to right the first number visited that has value greater than 51, thus exchange both of them
  • Scanning from right to left the first number visited that has value less than 51, thus exchange both of them
  • Scanning from left to right the first number visited that has value greater than 51, thus exchange both of them
  • Scanning from right to left the first number visited that has value less than 51, thus exchange both of them

Quick sort demo Quick sort demo Presentation Transcript

  • Quick Sort DemoAnishqa.zariga.com
  • Quick SortA[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]51 41 21 61 81 101 46 71 105 31 91 76qa.zariga.com1. Divide and Conquer design.2. It works recursively3. Choose a Pivot element in an array(Random)Pivot4. Place this element in such a way, thearray list will get divided into two sublistso that pivot element will be greater thanfirst sublist and less than other sublist
  • Quick Sort Scanning from right to left the firstnumber visited that has value less than 51, thusexchange both of themIteration=1A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]51 41 21 61 81 101 46 71 105 31 91 76startLeft to right searchthe number whichless that 51 swapA[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]31 41 21 61 81 101 46 71 105 51 91 76qa.zariga.comPivotElement
  • Quick Sort Scanning from left to right the firstnumber visited that has value greater than 51, thusexchange both of themIteration=2A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]31 41 21 61 81 101 46 71 105 51 91 76startRight to left search51<A[n]A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]31 41 21 51 81 101 46 71 105 61 91 76qa.zariga.com
  • Quick Sort Scanning from right to left the firstnumber visited that has value less than 51, thusexchange both of themIteration=3A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]31 41 21 51 81 101 46 71 105 61 91 76startA[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]31 41 21 46 81 101 51 71 105 61 91 76qa.zariga.com
  • Quick Sort Scanning from left to right the firstnumber visited that has value greater than 51, thusexchange both of themIteration=4A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]31 41 21 46 81 101 51 71 105 61 91 76A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]31 41 21 46 51 101 81 71 105 61 91 76qa.zariga.com
  • Quick Sort Scanning from right to left the firstnumber visited that has value less than 51, thusexchange both of themIteration=6A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]31 41 21 46 51 101 81 71 105 61 91 76start51 >A[n]No Element FoundScanning from left to right the first number visited that has value greater than 51,thus exchange both of them51<A[n]No Element FoundA[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]31 41 21 46 51 101 81 71 105 61 91 76qa.zariga.com
  • Quick Sort The Number 51 is Placedto proper PositionA[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]31 41 21 46 51 101 81 71 105 61 91 76Sublist1 has valueless than 51Sublist1 has valuegreater than 511. The Whole Process is repeated forboth Sublist1 and Sublis22. The Final List what we get as SortedListA[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[10] A[11] A[12]21 31 41 46 51 61 71 76 81 91 101 105qa.zariga.com
  • Quick Sort Analysis• Worst Case O(n )– Pivot is the Smallest or Largest element in Array• Worst Case O(nlogn )– Each Array is divided into two equla subarray ofsize n/22qa.zariga.com
  • ThanksVisitzariga.comqa.zariga.comyoutube.com/zarigatongy/qa.zariga.com