Question
Which sorting algorithm is best suited for a nearly
sorted array, exhibiting O(N) time complexity in its best case?Solution
Insertion Sort performs very well on nearly sorted arrays. In the best case, when the array is already sorted, it only needs to iterate through the array once, performing N-1 comparisons and no swaps, resulting in O(N) time complexity. Other algorithms like Selection Sort, Merge Sort, Heap Sort, and Quick Sort generally do not achieve O(N) for nearly sorted inputs.
Ajay, Bablu and Chirag can complete a certain work in 21, 28 and 15 days respectively. Ajay and Chirag started the work while Bablu joined them after 5 ...
Three workers A, B and C can complete a job in 12, 15 and 20 days respectively, working alone. All three start working together. After some time, C leav...
A buffalo alone can plough field βAβ in 30 days. A Bull alone can plough the field βAβ in 50 days. Find the number of days taken by 2 bulls and ...
βPβ alone can complete a work in 25 days while βPβ and βQβ together can complete the whole work in 15 days. Find the time taken by βQβ a...
Akhil and Nikhil together can complete a work in 9 days while Nikhil alone takes 12 days to complete 50% of the work. If the efficiency of Sachin is 20%...
Sachin can complete a job in 15 days. Ankit alone can complete the same job in 10 days. Sachin works for 9 days and then the remaining job is completed ...
A and B can complete a task in 63 days and 42 days, respectively. If C is 40% more efficient than the combined efficiency of A and B, how much time will...
A can do a work in 10 hours while B can do the same work in 15 hours. If C is 50% more efficient than A and B together, then find the time taken by C al...
25 men can finish a work in 8 days by working 9 hours a day. How many more men are needed to finish the work in 10 days by working 6 hours a day?
Aβ and βBβ together can complete a work in 15 days while βAβ takes 20 days to complete the same work alone. If βCβ is 50% more efficient t...