1.

Search Operation
In a sorted array, the search operation can be performed by using binary search.
Input Format:
The first line of input consists of T, the number of test cases. T testcases follow. Each testcase contains 3 lines of input. The first line of every test case consists of an integer N, denotes the number of elements in an array. The second line of every test cases consists of N spaced integers Ai. and last the value to be search in array.
Time Complexity of Search Operation: O(Log n) [Using Binary Search] 

2.
In a sorted array, a search operation is performed for the possible position of the given element by using Binary search and then insert operation is performed followed by shifting the elements. And in an unsorted array, the insert operation is faster as compared to the sorted array because we don’t have to care about the position at which the element to be placed.
Example
Before Insertion: 12 16 20 40 50 70
26 to be add.
Output
Before Insertion: 12 16 20 40 50 70 
After Insertion: 12 16 20 26 40 50 70 

Time Complexity of Insert Operation: O(n) [In the worst case all elements may have to be moved] 

3.
In the delete operation, the element to be deleted is searched using binary search and then delete operation is performed followed by shifting the elements.
Example

Input

Array before deletion 10 20 30 40 50
after deleting 30
Output
Array before deletion
10 20 30 40 50 
Array after deletion
10 20 40 50 

Time Complexity of Delete Operation: O(n) [In the worst case all elements may have to be moved]

4.

A step array is an array of integers where each element has a difference of at most k with its neighbor. Given a key x, we need to find the index value of x if multiple-element exist to return the first occurrence of the key.

Examples: 
 
Input : arr[] = {4, 5, 6, 7, 6}
           k = 1
           x = 6
Output : 2
The first index of 6 is 2.
Input : arr[] = {20, 40, 50, 70, 70, 60} 
          k = 20
          x = 60
Output : 5
The index of 60 is 5
5.

Implement a Queue using 2 stacks s1 and s2 .
A Query Q is of 2 Types
(i) 1 x (a query of this type means  pushing 'x' into the queue)
(ii) 2   (a query of this type means to pop element from queue and print the poped element)

Example 1:

Input:
5
1 2 1 3 2 1 4 2
Output:
2 3

Explanation:
In the first testcase
1 2 the queue will be {2}
1 3 the queue will be {2 3}
2   poped element will be 2 the queue
    will be {3}
1 4 the queue will be {3 4}
2   poped element will be 3.

Example 2:

Input:
4
1 2 2 2 1 4
Output:
2 -1

Explanation:
In the second testcase 
1 2 the queue will be {2}
2   poped element will be 2 and
    then the queue will be empty
2   the queue is empty and hence -1
1 4 the queue will be {4}.