0% found this document useful (0 votes)
61 views6 pages

Data Structures Alex Final Exam 2022

data structure exam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
61 views6 pages

Data Structures Alex Final Exam 2022

data structure exam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 6
robe Gel casio a irae ern Sed tnat/aead RIES A Churse Code: 108 Course: Data Structures and se; Data Structures and Algorithms ALEXANDRIA Time alowed: 20minutes Total polns: opelnts nena ‘Professor(s) name(s): Professor Dr, Ossama Ismail and Dr. M. ELHabrouk ‘ — ‘AMteMps ALL the following questions Cchoose the MOST APPROPRIATE answer forthe following statements ‘You may choose & (ALL) if all answers (A, 8, C and 0) are corrector choose F (ONE) none ofthe answers fs lease write your answers on the ANSWER SHEET ONLY. Inthe designated answer sheet, mark your choice (9, ©, ©, ‘Be sure that you have filed the approptlate bubbles carefully asin the example below. Example; ifthe cholee for question 300s "C" then your answer sheet should Took ike this: 300. © © @ © 1. Cana tree be stored in an array usin ether one of i-order or post-order or pre-order tra 12) Yes just traverse through the array and form the tree ) No in case of sparse trees etsfo we need one more traversal to form atree €) Yes by using both in-order » s Thee tollowing ines talks about deleting a node na binary ree (the tree property must note WS deletion }) from root search for the node to be deleted i) delete the node at what must be statement i) and the fil-up of statement i)? p)ilfind random node, replace with node to be deleted P b)ii}find node to be deleted found location Un ilind deepest node, replace with node to be deleted Ti delete a node a eclee eae rene winpacetotacened — aMrcnsagiec Se node eesrint minror of tree, showin below as an exa™o\s? as an example 3, What must be the missing code logic below s0 2° The swapping of eft & right nodes to print mirror of 2 tres (rootnede) + // missing code end 2) swapping of left and right nodes is missing. Pe b) swapping of left with root nodes is missing @ Which ofthe folowing statements is correct? Page 40f6 [a The pivot could be either th ither the 7 oF the 9, 6. The pit snot the 7, butt could be b. The pivot could be the, butitisnotthe9 4 Netter the 7ror the 9 ae 4. i fe fing Y Which of the following sorting algorithms In Is typical implementation gives best performance when applied on an array ‘hich is sorted or almost sorted (maximum 1 or two elements are misplaced) : x : Quick Sort b, Heap Sort Merge Sort Ainsertion Sort sume that we use Bubble Sort to sort n distinct elements in ascending order. When does the best case of Bubble Sort occur? AiWihen elements are sorted in ascending order c. When elements are not sorted by any order ’. When elements are sorted in descending order _d, There is no best case for Bubble Sort. It always takes O[n*n} time 56. Consider an array of elements arr5]= (5,4,3,2,4}, what are the steps of insertions done while doing insertion sortn the array. 45321,34521,23451,12345 b.54312,54123,51234,12345 57. Which is the correct order ofthe following algorithms with respect to their time complex! 1a. Merge sort> Quick sort >insertion sort> selection sort _¢: Merge sort selections Winsertion sort < Quick sort < Merge sort Quick sort > selection sort ins 58. A sorting technique is called stable f. 643215,32154,21543,15432 .45321,23451,34521,12345 ty inthe best case ? sart > quick sort > Insertion sort It uses divide and conquer paradigm 2. t takes O(n log njtime 4 It takes O(n) space “adit maintains the relative order oforeurrenc of non-distnct elements ste minimum numberof S368? a. Quick sort Biisertion sort Selection sort d, Heap so A Greedy method b, Divide-and-conquer ¢, Dynamic Programming 4. a. Priority queue ASingle ended queue c.clrcularqueue 4. ordinary a 2.0in) b.0{n"2) In toxin!) O(n) 4E.0(0"2) c. O(n * logial) 66. ini 1e worst-case scenario, suck sort has a time complexity oF s Ore on coseemy 00% ye eae ce fpcwan) #080 Fie lexity of AB verage -case scenario, bubble sort thas a time complexity of ‘hes ee ae ea ‘oin*2) ¢, On * login) 4, 0(28n) Cee ora “otnviay O(n) _ yns2) cc. O(n * login)! ol one Be Be ne? to simulate Dynamic Arrays 73,/arhich ofthe following can be done with tion of tacks and Queues ry Trees ich a Linkedtis's Nod! fit exists ‘implementation of Data Structures thatcaN 4. (a)and (b) je must store? Left-» Root Right -> Root» tap Aieft>Right-> Root —_b, Left > Root -> Right 76, What is/are the disadvantages of Implementing tree us!ng normal arrays? a) difficulty in knowing children’s nodes of a node ¢) difficult In finding the parent of a node AMfhave to know the maximum number of nodes possible before creation of trees 4) dif 0 implement 77, What must be the Ideal size of array if the height of a BST Is 7 Aa bl dl o)2i 78. Where is the parent for a node ‘w’ of a complete binary tree in an array. ‘representation when wis not 0? A iloortw-1/2) b)celllw-t/2) c)wet/2 w/a 73, Disadvantages of linked lst representation of binary trees over arrays? Al! ‘a) Randomly accessing is not possible ) Extra memory for a pointer Is needed with every element in the lst 'b) Difficulty in deletion d) Random access is nat possible and extra memory with every element 80. The main operations performed in a binary tree are " A insertion, deletion and traversal ‘addition, deletion and traversal 'b. insertion, deletion and reversal d. addition, subtraction and traversal 81, To obtain a prefix expression, which of the tree traversals is used? a) Level-order traversal &fPre-order traversal } Postiorder traversal) In-order traversal 82, For the tree shown in the figure tothe right the in-order traversal is FOUTS 94 02.72,65,115,9,4 b) 6,5, 2, 11, 7,4,9,5,2 4)2,7,6,5, 11, 2,9,5,4 £5, The numberof edges the otto the nodes cle ofthe ey Alea depth eJiength_ eth 4 Tne numberof edge rom the node tthe depet at iscalled ella quote tes a) Height AB Depth ) Length: d) Width 45. What wl be the hghtos balanced flay Wee wth leaves? als bs 6 Ms 86, When using Dijkstra’ algorthm to faethe shortest path ina graph, which ofthe following statements in not true «It can fine the shortest path within the same path data structure PF Everytime a new node's visited we choose the rode with smallest known dstance/cost (weight to vst fst Shortest path alnays pasts through the smalest numberof vertices 6. The raph needs tohave a non-negative weight on every edge Find the shortest path from vertex 1 to vertex forthe raph shown inthe figure tothe gh, Oiksas shortest path algorithm is used 3.1223355-77989 b1223366829 6122325566089 #712233655577-489 '88, For the graph shown nthe gure to the tht, aply Dijkstra algorithm from vertex St). Which ofthe flowing statements are tue? yy 8. Thea verter acted ts The shortest path from At Lis 5 There is exactly one shortest path from Ato F. v= & 4. (a) andte) £9, Forthe above problems the cost of the shortest path fom AG, A->H and A>! isthe Me b False True under condition 4. Not Applicable 90. “Which ofthe following isthe most commonly used data structure for Implementing Ditstr’s algorithm? 7vtax prionty queve Stack ¢. Creular queue dd. Min priory queue ‘Best Wishes - Page 6 of 6

You might also like