Illustrate QuickSort as above using the list 9, 8, 3, 13

Chapter 3, Problem 25

(choose chapter or problem)

Get Unlimited Answers
QUESTION:

Illustrate QuickSort as above using the list 9, 8, 3, 13

Questions & Answers

QUESTION:

Illustrate QuickSort as above using the list 9, 8, 3, 13

ANSWER:

Step 1 of 3

The given list of elements is 9, 8, 3, 13. The pivot element is 9. In QuickSort, the pivot element is compared with the rest of the elements, and two new lists named L1 and L2 are formed as illustrated below.

Compare 9 to 8. 8 is less than 9. Place 8 in list L1.

Compare 9 to 3. 3 is also less than 9. Place 9 in list L1.

Compare 9 to 13. 13 is greater than 9. So, place 13 in list L2.

As a result, two lists are formed. List L1 contains all the elements less than 9. List L2 contains all the elements greater than 9.

After the first pass, the list is 8,3, [9], 13.

Add to cart


Study Tools You Might Need

Not The Solution You Need? Search for Your Answer Here:

×

Login

Login or Sign up for access to all of our study tools and educational content!

Forgot password?
Register Now

×

Register

Sign up for access to all content on our site!

Or login if you already have an account

×

Reset password

If you have an active account we’ll send you an e-mail for password recovery

Or login if you have your password back