
Assignment 1
Written Homework:
1. How can LIFO and FIFO be implemented using singly linked list? Only consider the simple insertions
and removals.
2. What is the difference in using array and linked list when the data is to be stored in sorted order?
Discuss in terms of insertion, deletion and storage space.
3. Compute the Computation Complexity of the following using Big-Oh notation:
a. Sequential Search in an array of integers. It returns the index of the array that contains the
searched value.
int search(int[] a, int s)
{
for(int i = 0; i < a.length; i++)
if(s == a[i])
return i;
return -1;
}
b. Rectangle inclusion problem: Given a rectangle and m points. Decide how many points are
included in the rectangle.
count = 0
for each point p
if(p lies within the bounds of rectangle)
count++;
print count;
c. Nested loops
for(int i = 0; i< m; i ++)
for(int j = 0; j < n; j++)
System.out.println(m*n);