Arrays Assignment
1. Implement Selection, Insertion and Bubble sorts.
2. Binary Search
3. Print sum of all positive and negative numbers seperately in an array
4. Given two arrays print their intersection.
a. Instead of printing write a function which returns their
intersection.
5. Given an array of integers A and an integer x. Find pairs of elements in
a. A which sum to x.
6. You are given two arrays. Find the sum of the two arrays and put the
a. result in another array. e.g. if you are given [1,2,4] and [4,5,6] the
b. output should be [5,8,0].
7. Find the duplicate number in an array of size n with numbers from 0 to
n-2. Each number is present at least once.
8. Given an array of integers A and an integer x. Find triplets of elements in
A which sum to x
9. You are given two arrays. Find the sum of the two arrays and put the
result in another array. e.g. if you are given [1,2,4] and [4,5,6] the output
should be [5,8,0].
10.Find the duplicate number in an array of size n with numbers from 0 to
n-2. Each number is present at least once.
11.A sorted array has been rotated by some number k in clockwise
direction. Find k. e.g. Input: 5,6,1,2,3,4 Output: 2
12.You are given with an array containing only 0’s and 1’s. Write a function
to sort this array. Do it in one pass, this means you can’t first find the
count of 0’s and 1’s in one pass and update the array in second pass.