Sorting

1
Write a program to implement a binary search in an array which is sorted but rotated by some k places which is not known. Time complexity O(logn).



2
You are given an array of n+2 elements. All elements of the array occur once between 1 and n except 2 elements which occurs twice. Find the repeating elements in O(n).



3
Write a function for iterative mergesort.



4
Make a change in above binary search so that only one comparison should be made inside the loop.



5
Write a program to sort an array containing only 0, 1 and 2 randomly.