The Gateway to Computer Science Excellence
0 votes

Is there any standard way to sort in Quicksort or what all matters is PIVOT getting placed at its correct position thats it?
I mean if only pivot condition then 3!*3! for both left and right elements but if any standard then each of the left and right parts shall also be preserved in that order so 1?

like in Selection sort we have fixed way that after 1st pass the array will remain as it is and only those elements compared with the minimum will be getting swapped.

in Algorithms by Junior (675 points)
edited by | 173 views
Answer should be 3!*3! = 36.
what is the meaning of "the effect of first pass of quicksort algorithm is preserved" ?

2 Answers

0 votes
please someone answer it
by (161 points)
0 votes
First Pass places the pivot element at the correct position. So after first pass array looks like

[50, 35, 33, 60, 100, 72, 85].

60 is going to be intact at its place.

We can arrange 50, 35, 33 in 3! ways without hurting the information of the first pass, which is all elements before pivot is smaller, similarly for [100, 72, 85].

Thus total ways are 3!*3! = 36.
by (11 points)

Related questions

+1 vote
1 answer
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,321 answers
105,151 users