Assignments AOA SE15
Assignments AOA SE15
COMPANY CONFIDENTIAL
Infosys Document Revision History
Ver.
Date Author(s) Reviewer(s) Description
Revision
1.1 Jul 2004 Sivasubramanyam Y. Ramesh Babu S., Assignments in new
R M Bharadwaj format, in accordance
with the CDM
Contents
Assignment Chapter 1 - 3
1. Examine the code you have written for the Programming Fundamentals
project for code-tuning opportunities.
2. Consider a function that reads a matrix of numbers and outputs the sum of all
the entries. What do you think could be the worst-case complexity (running
time) of this program?
3. Make guesstimates of average-case complexity when the matrix represents the
consumption of various vegetables for each month of the year.
4. For the case when the matrix represents the number of days of the year for
which an Infoscion reports to another Infoscion directly. Did you need to
make any assumptions about internal data structures?
Assignment Chapter 4 - 5
1. A list of employee records sometimes needs to be accessed in increasing order
of salary, and sometimes in the reverse order. What is the complexity of
reversing a linked list? A doubly linked list?
4. Plot the actual running time of your implementation of bubble sort, insertion
and selection sort. Take an array size of 100 for the following kinds of input:
90% sorted array given, 90% reverse sorted array given, array with elements
alternating (10, 5, 8, 6, 20, 14,…), and array with randomly generated
elements
6. Given two sorted arrays A and B and an auxiliary array C, find an O(n)
algorithm (where n is the number of elements in A and B) for merging the
contents of A and B into C such that the elements in C are sorted
7. Tower of Hanoi Problem: We are given n disks of different sizes and three
poles. Initially all these n disks are mounted on the first pole in order of size,
the largest at the bottom and the smallest at the top. The problem is to move
these disks to the third pole using the second pole as an auxiliary. At any
given time we can move only disk with a constraint that a larger disk cannot
be placed on top of a smaller disk.
Solve the Tower of Hanoi problem and analyze the complexity of your
algorithm