You are on page 1of 7
MajorTest (A) 23" Nov. 2014 Entry Number Gp No___ ‘in the space provided for each question. below, describe how you will solve this problem and (in the size of the input). are given a dictionary in a foreign language (where tical order) and are asked to find the order of ‘the language. For English, say our dictionary has lice” in that order. Then your output must be ple, the fact that “accord” appears before ‘problem: You are given an n-by-n -by-n snake peas — Soe with numbers from 1 cS You may fi with a higher number, whereas a Mae we OS Square: Fey ae EY) Sqrare dust EA ete fete bee 6 he ak bine, ee ae 2 mans Ch A a Tila, you down to a square with 2 smaller number. Assume that you have a dice Which can show a number between 1 and 6. Whenever you throw the dice, you move ahead by these many steps - if you end-up ata square which has a jadder or a snake, you get transferred to the corresponding square. You are asked to find the minimum possible number of dice throws required to reach the last cell from the first cell. oe, Pan BF ode grff 5 OC spore 2 Ae fd a vette o $6 ep Dyer ok 9 Ape 2 a Fig tm 4 o's )) to - bie! er two vertices x and y that are simultaneously on th S from vertex s in an undirected graph. Which enya You are given a directed acyclic graph (DAG), represented using an ‘with non-negative edge weights and a fixed source vertex s. Give a ‘algorithm to find the shortest path distances from source vertex to Cam addons 79 iw )= (shar cncegree 0) ic Aten co fer cach noe J of i updad pry) & oti - 4 (i) if v4) > vide at} ) O(w) EI) . a ot ge = +l, te ver ie > i i — 5, [10 marks] A d-ary heap is lik ty heap but instead of two children, nodes i 2 aaah id you represent a d-ary heap inan al yediess = Sey terms of nand d? height of a d-ary heap of nelements in Pde a a deleteMin and insert operations take? ?, 16, 19, 24 =e ut, 15, £8, 19, 24 a e given an array of n elements with the guarantee that each K positions from its target position. Devise an algorithm that Wy K cent — © rete 1 datetomin, funk ie neh 40, [4 marks] Consider the following program for finding 3 number xin an array A of size n. Assuming that the number x appears ‘exactly twice in the array A, what is the probability that the program will output true? function find(A, x) { for ey per io ie

You might also like