The Gateway to Computer Science Excellence
+1 vote
75 views
After applying few passes of quick sort on a given array,  the following output was obtained:

1,10,5,8,25,44,55,30,70

Then how many pivot elements are there in the above output?
in Algorithms by Active (3.4k points) | 75 views
0
1 ,25  and 70 is the pivot element i guess, Pivot element means that it divide array such that. it one side contain element smaller that pivot element and other side contain element greter thn pivot element,For ex. For 1 its right hand side contain all value greater than 1 and there is no element in left hand side, Similarly for 70 it left hand side contain all element less than 70 .Correct me if i am wrong
+1
Answer should be 3

1,25 and 70

1 Answer

0 votes
There should be 3 pivot elements.

Property of output of each pass of Quicksort ->

1. The pivot elements is on its correct position.

2. All the elements on the left of pivot are smaller than it and elements on the right are greater than it.

So in the given question ->

1, 25 , 70 are pivot elements hence no of pivot elements are 3.
by (211 points)

Related questions

0 votes
1 answer
2
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,648 questions
56,429 answers
195,208 comments
99,921 users