Open In App

GATE | GATE MOCK 2017 | Question 50

Last Updated : 07 Jun, 2019
Like Article
Like
Save
Share
Report

Consider an array consisting of –ve and +ve numbers. What would be the worst case time complexity of an algorithm to segregate the numbers having same sign altogether i.e all +ve on one side and then all -ve on the other ?

(A)

O(N)

(B)

O(N Log N)

(C)

O(N * N)

(D)

O(N Log Log N)



Answer: (A)

Explanation:

Here we can use the partition algorithm of quick sort for segregation and answer will be O(N).


Quiz of this Question
Please comment below if you find anything wrong in the above post


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads