Can you implement this quick sort algorithm in C++ for me and write a test main program for it. Algorithm QuickSort(S): Input: A sequence S implemented as an array or linked list Output: The sequence...

Can you implement this quick sort algorithm in C++ for me and write a test main program for it.Algorithm QuickSort(S):<br>Input: A sequence S implemented as an array or linked list<br>Output: The sequence S in sorted order<br>if S.size() < 1 then<br>return<br>p-S.back(element()<br>Let L, E, and G be empty list-based sequences<br>while !S.empty ) do {scan S backwards, dividing it into L, E, and G}<br>if S.back().element() < p then<br>(L.jnsertBack(S.eraseBack())<br>elşe if S.back().element() = p then<br>EnsertBack(S.eraseBack())<br>else{the last element in S is greater than p}<br>G.JnsertBack(S.eraseBack())<br>QuickSort(L)<br>QuickSort(G)<br>while !L.empty() do {copy back to S the sorted elements less than p}<br>S.insertBack(L.eraseFront())<br>while !E.empty() do {copy back to S the elements equal to p}<br>S.insertBack(E.eraseFront())<br>while !G.empty () do {copy back to S the sorted elements greater than p}<br>S.insertBack(G.eraseFront()<br>{S is already sorted in this case}<br>{the pivot}<br>{Recur on the elements less than p}<br>{Recur on the elements greater than p}<br>return<br>{S is now in sorted order}<br>Code Fragment 11.5: Quick-sort for an input sequence S implemented with a linked<br>list or an array.<br>

Extracted text: Algorithm QuickSort(S): Input: A sequence S implemented as an array or linked list Output: The sequence S in sorted order if S.size() < 1="" then="" return="" p-s.back(element()="" let="" l,="" e,="" and="" g="" be="" empty="" list-based="" sequences="" while="" !s.empty="" )="" do="" {scan="" s="" backwards,="" dividing="" it="" into="" l,="" e,="" and="" g}="" if="" s.back().element()="">< p="" then="" (l.jnsertback(s.eraseback())="" elşe="" if="" s.back().element()="p" then="" ensertback(s.eraseback())="" else{the="" last="" element="" in="" s="" is="" greater="" than="" p}="" g.jnsertback(s.eraseback())="" quicksort(l)="" quicksort(g)="" while="" !l.empty()="" do="" {copy="" back="" to="" s="" the="" sorted="" elements="" less="" than="" p}="" s.insertback(l.erasefront())="" while="" !e.empty()="" do="" {copy="" back="" to="" s="" the="" elements="" equal="" to="" p}="" s.insertback(e.erasefront())="" while="" !g.empty="" ()="" do="" {copy="" back="" to="" s="" the="" sorted="" elements="" greater="" than="" p}="" s.insertback(g.erasefront()="" {s="" is="" already="" sorted="" in="" this="" case}="" {the="" pivot}="" {recur="" on="" the="" elements="" less="" than="" p}="" {recur="" on="" the="" elements="" greater="" than="" p}="" return="" {s="" is="" now="" in="" sorted="" order}="" code="" fragment="" 11.5:="" quick-sort="" for="" an="" input="" sequence="" s="" implemented="" with="" a="" linked="" list="" or="" an="">

Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here