Question

Use Quick sort to sort the following list. Show the actions step by step 123, 34,...

Use Quick sort to sort the following list. Show the actions step by step

123, 34, 189, 56, 150, 12, 9, 240

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Quicksort (sometimes called partition-exchange sort) is an efficient sortingalgorithm, serving as a systematic method for placing the elements of an array in order.It is still a commonly used algorithm for sorting.

Assume pivot is the leftmost one in the range and the partition is:
Function Partition (left, right)
P = A [left]; i = left; j = right + 1
While (1)
Do i ++ until A [i]> = P;
Do j-- until A [j] <= P;
If i <j swap A [i] and A [j]
Else exit the while-loop
Swap A [left] and A [j]; return j;
Step-by step:
(123 34 189 56 150 12 9 240) (pivot 123)
(34 9 56 12) 123 (150 189 240) (pivot: 34, 150)
(912) 34 (56) 123 150 (189 240) (pivot: 9, 56, 189)
9 (12) 34 56 123 150 189 (240) (pivot: 12, 240)

Add a comment
Know the answer?
Add Answer to:
Use Quick sort to sort the following list. Show the actions step by step 123, 34,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT