You are on page 1of 4
YUSUF MAITAMA SULE UNIVERSITY, KANO © “7 Go S i FACULTY OF SCIENCE a DEPARTMENT OF COMPUTER SCIENCE ; 2018/2019 FIRST SEMESTER EXAMINATION — JUL¥|2019 ©SC2307/ITC2315 — FUNDAMENTALS OF DATA STRUCTURES Instruction: Answer Any Five questions * ‘Time plowed: 3 hours + aY Define a recursive procedure. What are the properties of recursive procedijre? 3 marks ) + b) Write a recursive procedure to find the nth term Fy of a Fibonacci Serias, I mark + ©) What do you understand by an Atray? Mention any four Operations of Anjays? 3 marks 26) }ow is a two-dimensional array represented in the memory? 2 marks ; oe) Consider a 16 x 5 two-dimensional array “marks” which has its basd address = 2632048 | \ “and the width is 4. Caloulats the address ofthe element, marks[12][3}. i, Assuming that the elements are stored in row major order. 1.Smarks | H. Assuming thatthe elements are stored in column major order. 1.Smarks * { A. 4) Corwertthe infix expression X +.(¥ * Z = (L/ M* N) * 0) + P/Q Ad its equivalent Prefix | © expression through Postfix. Show the steps involved and convert it directly to Prefix. — 3marks _b) Consider the prefix expression + ~27 * 8 /~ 4 8 12. Apply an algofithm to evaluate the expression, Hint: Sean Character from right to left one at a time. Ifthe sqanned character is an ‘opetind push it into the Operands Stack and if it is an operator pop twh operands. apply thg oper stor and push back into the stack. Continue until solution is obtained. Smark$ + ©) Corvert each of the following infix expressions into their equivalent postfix expressions: “4 YW OY)" LEKI L) (i) (AP B® O72) * G Gil) A* (B+ D=~E)/A-F (iv) (AB) /(D { i Ss : — = 2 evar ~ 465. pinin the éitvergice betivéen a singly circular linked list and a singly lifked list. 2. marks 48) Write an Algorithm to INSERT a New. Node before 4 given number in a Doubly Linked List : 2marks « 3. a) Draw tree of the below memory representation ‘ Smarks gue : dog an . 2 e % i . rae Bae” E 1 | eo a aN } 7 Oe +b) Write an Algorithm that will DEI-ETE the I 4 ©) Write an algorithm to sort the following ee Simple = {60, 88, 30, 40, 44, 99, 55, 22, 66, last node of a Circular Doubly Linked List 2marks ments of an array i 77, 80, 11,33) — Buyeed ; i . Scanned with CamScanner te between feek(, push() and pop() operations. 2 marks 4) Ditffere sae sagt “4 Consider the STACK felow and use ito find the results ofthe following operations: v ‘ 2 : 67 78 6 0 TT+. 2 Top= 4 3 6 Imark ppush(100) ar) Imark iii, Peek) Imark 4. (a) Give the linked represdptation of the following polynomial: i i (| =. 2marks (b) Every Computer Scientfst *hust grapple with certain classic problems, and the Towers of Hanoi is dne of the most famdhis of these, Legend has it that in a temple in the Far-East, priests are attempting to move a slack of disks from one peg to another. The initial stack had 4 disks threaded onto one peg rd arranged from bottom to top by decreasing size. The priests are attempting to move the stack from this peg to a third peg (as shown in the figure below) under the constraints that exadly one disk is moved at a time, and at no time may a larger disk be i placed above a smalled djsk. A third peg is available for temporarily holding the disks. Supposedly, sonething fd may likely happen to the priest, if they fail to accomplish the task. Write an algorithm to hefp them move all the stack from peg | to3 without a problem, so that they can be safe, Hint: Use Move (Source] Destination, Temp), ie. if you are moving a disk-from 1 to 2 using 3 as temporary, write Movg-(1, 2, 3) or Move (3, 1, 2), if you are moving a disk from 3 to 1 using 2 as temporary. . j : + lst 2nd 3rd 3,4, 5 pho \ = a4,05 6% “ aa ae se I a 4,6245 0 | marks +c) Write an Algorithm that 9 ETE the First node of a Circular Doubly Linked List 2marks | “gy = 4 stack impleihented using a linked list differ from a stack implemented using an array’ rk « €) What do you understand ‘pose overflow and underflow? aime #5, (@) What do you understandby a Queue? Mention 4 types of Queue + 2marks \ ~Ab) How does a Queue reprdsented using an array differ from a Queue represented using a finked : 2 mark: (6) Write an algorithm to INBERT an element in a Circular Queue 2 marks seater ce cea n J ireular queue are waiting for execution and it was decided thet those Feo nes crcranaint'{ 8 2 Josephus Permutation (Josephus Problem), and a promise wee ane ee are eto” il be freed (declared the winner). Ifthe k® person is exeeure first, where k = 3, solve een problem and show all the steps involved until a winner (person to be freed) is declared, dma (©) Write an algorithm to FETE an clement from a Queue implemented using @ linked list. 2 marks Scanned with CamScanner ly explain any two types of trees, 2 marks \dy the tree below and write down its traversal results in both Pre-rder and In-order 3 marks ox . pre the corresponding tree of the memory representation below * 3 marks { . (pe one 4 42 ven 2 es ne 4fa 5 6|__19 sire a7 eas [7 8b AVARL gf. TeatimaTION 40 z i 41[_-1 wi 12[_ 7 ver 13 6 * 14|, . -15[0=4 conta =1 i 16 z ee H i 47[_ = aan —4 i is ae 19 =1 20 AND 15 & Scanned with CamScanner \U@) Using the In-onder trapersal r i CFG, construct back the binary tree. 2 marks: (©) Mention any four appligation of tree 2 marks 7. (a) What do you underftand Traversal algorithm? Briefly explain any two 3 marks (0) Write the Huffinan fre¢ of the following characters with their codes table 3 marks +(c) Mention any four (4) Create a Hutfinan’ Character ersal result: DB EA FC G and Pre-ofder traversal result: A B D E ks 2 marks oe with the following nodes arranged ina priority queue, 3 matks 9 +5 4— ni} | a4 | alsa] (©) Cateulate the inten a g ¢ L 4 so 6) atti length and the external path length of the binary tree below. + 3marks Scanned with CamScanner

You might also like