B.Tech. (I) - ICP-132 (2008) Assignment 3 Level 0 ------- 1. Given natural numbers x and y construct a vector with numbers 1^2, 2^2,...,(x-1)^2,(x+1)^2,(x+2)^2,...y^2. Find the average value. 2. Read 'n' numbers and print the median, mode and range. 3. Find maximum of 'n' strings. Input: 3 hello world yes Output: world Level 1 ------- 1. Numbers 1^2, 2^2,...,(x-1)^2,(x+1)^2,(x+2)^2,...y^2 are given. Find x and y using a function. Input: 1 4 9 25 36 Output: x=4 y=6 2. Logistic function is given as X_n+1 = G.(X_n).(1-X_n), where X_n is the population in n'th year and X_n+1 is the population in (n+1)th and G is the growth constant. It is used in ecology to model population of predetor prey systems, where their numbers and growth constant show interesting dynamics. For G in range (1,3) population will reach a stable value while more complicated results appear from higher G. For a given X_0 and G as initial values, find the average population of predetor between (n-50) and n years. 3. Given nxn matrices A and B, find A*B' Level 2 ------- 1. Insert x^2 into its correct place as mentioned in Level 1 prob 1. 2. Using Lagrange interpolation formula, find sin(49) using sin(10), sin(10), sin(20), sin(33), sin(45), sin(48), and sin(57). Using math library find the difference from the actual value. 3. Given a vector write a function to sort it in descending order. Level 3 ------- (See "Introduction to Algorithms", by TH Corman, CE Leiserson, RL Rivest) 1. Implement a Queue on a vector v of integers. The functions to be built are: void enqueue(v, i), where i is the number to be enqueued int dequeue(v), int size(v), int front(v), 2. An nxn matrix (D) is given that shows the distance between any two cities. Using Floyd-Warshall algorithm, find the shortest between any two cities. 3. Task scheduling problem: Given n tasks and their completion times the best way to process jobs is using a 'greedy technique' in such a way that the tasks with fastest completion times are taken up earlier. Given a set of n tasks and their completion times, print the order in which tasks should be taken up.