Question 10146 – Time-Complexity
November 14, 2023
Question 9893 – Time-Complexity
November 14, 2023
Question 10146 – Time-Complexity
November 14, 2023
Question 9893 – Time-Complexity
November 14, 2023

Question 9890 – Time-Complexity

Suppose  we  want  to  arrange  the  n  numbers  stored  in any  array  such  that  all negative  values  occur  before  all  positive  ones. Minimum  number  of  exchanges required in the worst case is

Correct Answer: D

Question 6 Explanation: 
Minimum no. of exchanges required in worst case will be when 1st half will contain all +ve nos and 2nd half will contain all -ve nos.
Now we will swap 1st no. with nth no. and then 2nd no. with (n-1)th no. and then 3rd no. with (n-2)th and so on. Like this we will have to do n/2 swaps in worst case.
A
n – 1
B
n
C
n + 1
D
None of the above
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!