Department of Computer Science and Engineering, IIT Kanpur

CS210: Data Structures

Dr. R. K. Ghosh


Home | Notice Board | Instructor | TAs | Students | Assignments | Schedule | Lectures | Resources
Assignment 2
Deadline for submission: Friday, 9 Aug, 2002, Midnight.

Q1. A usual punishment for the school kids committing a spelling mistake or a wrongly worded sentence is to rewrite the sentence multiple number of times. Write a simple java function which prints the following sentence 100 times: I will always use object oriented design for writing programs. Your program must number each of the sentences and it should make 8 random typos at various points in the listing of 100 sentences so that it looks like typed by human on a typewriter.

Q2.  Birthday paradox says that if there are more than 23 persons in a room the probability that two persons will have same birth day is more than half. Write a simple java function to test this paradox by a series of experiments on randomly generated birthdays. You should run at least 10 experiments for each value of n and for n=5, 10, 15, 20, 25, ..., 100. The output should be for each value of n the number of experiments such that two persons in that experiment have the same birthday.

Q3. Write a java program for multiplication of two nxn randomly generated real matrices. Run experiments to find the average time required for multiplication of the matrices for varying values of n=5, 10, 15, 20, 25, 30, 35, 40, 45, 50. You must take the average of 20 runs for each value of n. Use GNU plot to see the trend of growth rate in time with n. Analyze the result like you did in case of sorting and make a small report.

Note: Try to write all programs in Java. However, TAs have been instructed to check your programs written in C or C++. But there will be increasing penalty for submissions not written in Java from this assignment onwards. The penality starts at 10% for the current assignement which will double each time over the previous assignment.


Home | Notice Board | Instructor | TAs | Students | Assignments | Schedule | Lectures | Resources
Page last updated 3 Aug, 2002 by RK Ghosh