Sie sind auf Seite 1von 2

Department of Computer Science & Engineering National Institute of Technology, Rourkela Mid-Semester Examination (Spring -2012-13) Sub: Data

Structure and Algorithm (CS- 102) Time: 2 hrs, FM: 30

Answer ALL questions. All parts of the question must be answered at the same place. You must show all the steps that lead to the answer. Answer without showing the intermediate steps will NOT FETCH any mark. This question paper contains TWO pages.
[1] An input restricted deque,

DEQ [0:5], as shown below is implemented as a circular array where insertion takes place from the left end only. Show the content of the deque for each of the following steps: (i) S5 is inserted into the queue, (ii) an element is deleted from the right of the deque resulted in step (i) . Given LEFT = 1 and RIGHT = 4. [1 + 1 = 2]
0 C1 1 A4 2 Y7 N6 3 4 5

DEQ

[2] A priority queue is implemented as a linked list. Write an algorithm to insert an element into the queue. [3] [3] Write an algorithm to delete a data item from the linked list. Your algorithm must check for an underflow condition. [3] [4] What are the conditions for testing whether a linked list T is empty, if T is (i) a circular linked list, and (ii) a circular headed linked list. Draw the corresponding schematic diagram of your linked list and then write the necessary condition. [2] [5] A STACK is implemented as linked list. Write an algorithm to (i) Insert an element into the STACK, (ii) Delete an element from the STACK. Your algorithm must check for Underflow and Overflow condition wherever necessary. [4] [7] Define the following terms a. Data structure b. Array c. Recursion. [8] Consider a multidimensional array, Y(3:10, 1:15, 10:20, -7:7). Find (i) the number of elements in the array, and (ii) the address of the element Y[5, 10, 15, 0]. Given Base(Y) = 1000 and Y is stored in row-major order. Each element of the array occupies 4 memory locations. [1+2 = 3] [ 1 x 3 = 3]

[9] Write an algorithm to find the maximum value and the number of nodes in a linked list.

[3]

[10] Let M and N be integers and Suppose F(M,N) is recursively defined by F(M,N) = 1 if M = 0 or M N 1 F(M - 1, N) + F(M - 1, N-1) Otherwise Write a recursive algorithm to compute the above function. [11] Write an algorithm to delete the last node in a circular header list. [3] [4]

Das könnte Ihnen auch gefallen