Q1medium
You are given an array that is "nearly sorted" (each element is at most 2 positions away from its correct spot). Which sorting algorithm would be the most efficient to finalize the sort?
Topic-wise practice questions for Problem Solving & Analytical Skills. Test your knowledge, check solutions on demand, and pace your preparation.
while (low <= high):
mid = (low + high) / 2
if target == arr[mid]: return mid
if target < arr[mid]: high = mid
else: low = mid