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


Then how many pivot elements are there in the above output?
in Algorithms by
reshown by | 159 views
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
Answer should be 3

1,25 and 70

1 Answer

+1 vote
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.

Related questions

0 votes
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
52,345 questions
60,517 answers
95,368 users