National Institute of Technology, Rourkela End-Semester Examination (Spring -2012-13) Sub: Data Structure and Algorithm (CS- 102) Time: 3 hrs, FM: 50
Answer as many questions as possible. Mark secured above FIFTY will be converted to FIFTY. Wherever necessary show all steps in your answer. Answer without the intermediate steps will NOT FETCH any mark. This question paper contains TWO pages. All questions carry equal marks.
[1] Write an algorithm to insert an ITEM into a two-way linked list sorted in increasing order. Each node in the list contains three fields: INFO, FORW and BACKW where the pointer FORW points to the successor and BACKW points to the predecessor of a node. Pointers HEAD points to the first node and TAIL points to the last node in the two-way list. [5]
[2] Write an algorithm to delete an ITEM from a one-dimensional sorted array of N elements. Array is sorted in the increasing order. Your algorithm must check for underflow condition. [5]
[3] Perform QUICKSORT on the array given below. You must show the content of the array at each step in the sorting process. No mark will be awarded if the sorting process is not shown clearly. [5]
[4] Inorder and Postorder traversal of a binary tree is given below. Construct the corresponding binary tree. Show each steps in the construction process. [5] Inorder: C, D, E, B, G, H, F, K, L, P, Q, M, N, J, A Postorder: E, D, C, H, G, Q, P, N, M, L, K, J, F, B, A
[5] Preorder traversal of an m-way search tree is defined as follows: Visit all the keys in the root node first, followed by visiting all nodes in the subtrees beginning from left to right recursively in preorder. Construct a 3-way search tree for the following keys: G S F L Q X Z V R A I J W. Perform preorder traversal in the above constructed 3-way search tree as per the above definition. [2+3] [6] Use Fibonacci search to locate the key K = 67 in the list given below. Trace each step in your search process. [5] 11, 89, 34, 15, 90, 67, 88, 01, 36, 98, 76, 50 [7] An AVL search tree is shown in Figure -2. Delete 75 from the tree. [5] [8] Find the shortest path from node 0 to rest of nodes in the graph using Bellman-Ford algorithm. Adjacency matrix for the graph is shown in Figure -1. Show each step in finding the shortest path. [5] 44 33 11 55 77 90 40 60 99 22 88 66 2
[9] Find the minimum cost spanning tree for the graph, whose adjacency matrix is given in Figure -1. Use Prims algorithm for finding the minimum cost spanning tree. [5] [10] Construct DFS starting at node 1 for the graph whose adjacency matrix is given in Figure -1. [5] [11] Define recursion. Write a recursive algorithm to compute the factorial of a given number N. [5] [12] Define the following terms [1+2+2] [a] Extended binary tree [b] m-way search tree [c] B tree
ChatGPT Money Machine 2024 - The Ultimate Chatbot Cheat Sheet to Go From Clueless Noob to Prompt Prodigy Fast! Complete AI Beginner’s Course to Catch the GPT Gold Rush Before It Leaves You Behind
ChatGPT Side Hustles 2024 - Unlock the Digital Goldmine and Get AI Working for You Fast with More Than 85 Side Hustle Ideas to Boost Passive Income, Create New Cash Flow, and Get Ahead of the Curve
ChatGPT Millionaire 2024 - Bot-Driven Side Hustles, Prompt Engineering Shortcut Secrets, and Automated Income Streams that Print Money While You Sleep. The Ultimate Beginner’s Guide for AI Business