Question: 1 0 . 1 0 LAB: Sorting user IDs Given a main ( ) that reads user IDs ( until - 1 ) , complete
LAB: Sorting user IDs
Given a main that reads user IDs until complete the Quicksort and Partition functions to sort the IDs in ascending order using the Quicksort algorithm, and output the sorted IDs one per line.
Ex If the input is:
kaylasimms
julia
myron
kaylajones
the output is:
julia
kaylajones
kaylasimms
myron
main.cpp
#include
#include
#include
using namespace std;
TODO: Write the partitioning algorithm pick the middle element as the
pivot, compare the values using two index variables l and h low and high
initialized to the left and right sides of the current elements being sorted,
and determine if a swap is necessary
int Partitionvector &userIDs, int l int h
TODO: Write the quicksort algorithm that recursively sorts the low and
high partitions
void Quicksortvector &userIDs, int l int h
int main
vector userIDList;
string userID;
cin userID;
while userID
userIDList.pushbackuserID;
cin userID;
Initial call to quicksort
QuicksortuserIDList userIDList.size;
for sizet i ; i userIDList.size; i
cout userIDList.ati endl;;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
