edited by
387 views
0 votes
0 votes

An array of $n$ distinct elements is said to be un-sorted if  for every index $i$ such that $2 ≤ i ≤ n − 1,$

either $\{A[i] > max{A[i − 1], A[i + 1]}\},$ or $\{A[i] < min{A[i − 1], A[i + 1]}\}.$

What is the time-complexity of the fastest algorithm that takes as input a sorted array $A$ with $n$ distinct elements, and un-sorts $A$?

$(A) O(n log n)$ but not $O(n)$

$(B) O(n)$ but not $O( \sqrt{n})$

$(C) O( \sqrt{n})$ but not $O(log n)$

$(D) O(log n)$ but not $O(1)$

 

edited by

1 Answer

Related questions

0 votes
0 votes
0 answers
1
2 votes
2 votes
1 answer
2
0 votes
0 votes
1 answer
3
1 votes
1 votes
2 answers
4