# Lab 1 Fall 2011

This lab is to review Chapters 0 and 1 of DG, bitwise operations and recollect your sorting and searching algorithms. . Please go to your lab, do the problems to get your full credit for the lab.
1. Arrange the following functions in increasing order of their growth rate.
n 2.5, sqrt(2n). n+10, 10n, 100n,  n2log(n), 102n
2. From the array of integers from 0 to 2 n-1, you are given all but one number. Your task is to write an algorithm and implement it to find which integer was not given, What is the running time of your algorithm. What is the memory requirement. (Eg. if n =2, give integers may be 0,1,3 and your output will be 2.)
3. From an array of integers, write an algorithm and implement to determine whether the sum of any two distinct elements is 0. What is the running time of your algorithm. (Hint: Can you come up with O(n log2 n) algorithm in the worst case.) (You may use STL libraries - Assume STL algorithms are the most efficient)
4. What is the running time of the following program which counts the number of distinct triples in a given integer array of size n which sum to 0 (An application of this is to test collinearity of three points). Assume input array a of size n is already given. (Using the idea from the second problem, can you make it more efficient - better than this algorithm).
```cnt=0;
for (i=0;i<n;i++)
for (j=i+1;j<n;j++)
for (k=j+1;k<n;k++)
if (a[i]+a[j]+a[k]==0)
cnt++;
```