GATE | GATE MOCK 2017 | Question 50
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).
Choose the first element as pivot whatever may be its sign we don’t care and keep an extra index at pivot position .
Quiz of this Question
Recommended Posts:
- GATE | GATE MOCK 2017 | Question 9
- GATE | GATE 2017 MOCK II | Question 29
- GATE | GATE MOCK 2017 | Question 17
- GATE | GATE MOCK 2017 | Question 18
- GATE | GATE 2017 MOCK II | Question 30
- GATE | GATE 2017 MOCK II | Question 31
- GATE | GATE 2017 MOCK II | Question 32
- GATE | GATE 2017 MOCK II | Question 33
- GATE | GATE MOCK 2017 | Question 16
- GATE | GATE 2017 MOCK II | Question 28
- GATE | GATE MOCK 2017 | Question 15
- GATE | GATE MOCK 2017 | Question 10
- GATE | GATE MOCK 2017 | Question 11
- GATE | GATE MOCK 2017 | Question 12
- GATE | GATE 2017 MOCK II | Question 17

