Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Quick Sort Algorithm in C++: Understanding the Array-Based Implementation, Lecture notes of Design

An in-depth explanation of the Quick Sort algorithm in C++ with a focus on array-based lists. the divide-and-conquer technique, the process of partitioning the list into sublists, and the steps to implement the partition algorithm. This information is essential for computer science students and developers seeking to understand and apply the Quick Sort algorithm in their projects.

Typology: Lecture notes

2021/2022

Uploaded on 09/27/2022

bairloy
bairloy 🇺🇸

4.2

(5)

22 documents

1 / 8

Toggle sidebar

Related documents


Partial preview of the text

Download Quick Sort Algorithm in C++: Understanding the Array-Based Implementation and more Lecture notes Design in PDF only on Docsity! C++ Programming: Program Design Including Data Structures, Fourth Edition 1 Quick Sort: Array-Based Lists • Uses the divide-and-conquer technique – The list is partitioned into two sublists – Each sublist is then sorted – Sorted sublists are combined into one list in such a way so that the combined list is sorted 2 Quick Sort: Array-Based Lists (continued) • To partition the list into two sublists, first we choose an element of the list called pivot • The goal is to re-arrange the list so that the pivot divides the list into: lowerSublist and upperSublist – The elements in lowerSublist are < pivot – The elements in upperSublist are ≥ pivot {o] (1) (2) (3) [4] [5] [6] [7] [8) [9] [10] [11] [12] [13] FIGURE 19-40 List before sorting (0) (1) [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] pivot FIGURE 19-41 List after moving pivot to the first array position lower upper sublist sublist a pivot sar inte so FIGURE 19-42 List after a few iterations of Step 2 |-— lower sublist —+|—upper sublist —+| MEENA « ~*~ pivot smallIndex index FIGURE 19-43 List after moving 11 into the lower sublist lower sublist upper sublist fsa fee az] fer ss v0 oe CIC pivot smalliIndex index FIGURE 19-44 List before moving 58 into a sublist I lower sublist upper sublist — > ORO ooo ee pivot | smallIndex index FIGURE 19-45 List after moving 58 into the upper sublist C++ Programming: Program Design Including Data Structures, Fourth Edition 7 Quick Sort: Array-Based Lists (continued)
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved