You are on page 1of 3

BTS-IV-04. [9-0669 Reg" No.

B. Tech. Degree IV Semeslff Exsmina


CS/IT 15-14$5 DATA STRUCTURES AhtD ALGO
(2015 SchemeJ

Time: 3 Hours MaximumMarks:60

PART A
{Answer ALL questions)
(10 x 2:20)
I. (a) what are sparse mauices? How can sparse matri es be efficie'nfly
'represented?
(b) Starc the advantage ofbinary search over linear search.
(c) State two applications of queue as a data sfructure-
(ol what is tne ouput ofthe following function where 'head' is pointingto
the first node of the following linked list?
Linkedlist: l+2)3)4+5)6
void fun (Node head)
{
if (head :: WLL|
retutn;
fun (head. ne:r^t) ;
System. out.Println (head,data) ;
]
(e) Evaluate the following postfix expression using stack, assuming each
operand is a single digit positive irrteger and each operator is bhary'
423+-382f++
(f) How is an A\IL hee better than a binary search tree?
(e) Write short note oil Threaded Binary Trer (TBT).
(h) Consider the following binary search
tree T as given below. Which node
contaiils the fourth smallest elerne,lrt
in T?

(i) Is the given graph regular? Justify


your all,$wer.

fi) Differentiate between B Trees and B+ Trees.


(P.T.0-)
2

PART B
(4 x 10:40)
II. (a) Insertthe characters ofthe stringKRP C S N Y T JMinto ahashtable of (5)
size 10 . Use hash function h(X) = ( ord(X) - ord('A') + 1 ) mod 10, where
ord(X) refers to the relative position of X in the alphabetic array
(Eg : ord(A): 1, ord(B):2.. or d(Z):26).
Use linear probing to resolve collision.
i. Which insertions cause collision?
ii. Display the final hash table.
(b) Write the algorithm for quick sort. Illustrate with an example (s)
OR
III. Consider the following elements in an anayi (3+3+3+1=10)
23,33,12,55,38,66,59. Perform Bubble sor! Insertion Sort
and Selection Sort on the input data. Show the status of
array after each iteration.
Why are the above mentioned sorting algorithms named so?

IV. (a) Implement a stack using an array. You need to write ttre pseudo-code for all (5)
the primitive operations of the stack.
(b) Giventwo singly linked tists Ll andu. Write pseudo-code to merge both (5)
linked lists to a single linked list.
OR
V. Explain with an algorithm, how infix expression can be converted into (10)
postfix form. Illustrate it with the expressisn; [*B-C*D+(E^F)*G/H{*J+K.

VI. (a) Draw a binary tree for the expression 4+3*7-5(3+4)+6. (4)
(b) Travetse the above generated tree using inorder, preorder and postorder (3)
traversals
(c) Also write a recursive function for each of the three traversal methods (3)
OR
VII. (a] Show intermediate steps to insert the (4)
node 70 into the given AVL tree
maintaining its AVL property?

(b) Write a function (Java codelpseudo-code) to insert a node into a binary (6)
search tree.
(Contd.....3)
3

Vm. (a) Consider the following graph and


find the shortest path from node 'a'
to node'e' using Dijkstra's
algorithm. Show atrl the steps
inv*lved.

(b) What is a spanning tree? Consider an undirected ga.ph of (6)


vertices{A,B,C,D,E,F}. Adjacency matrix of the graph is given below. Find
the minimum spanning ffee using Prim's algorithm. Show every step of
action.
22 0 0 0
0362\
3 0 s 0 3l
6 s o 411
2 o 4 o ol
03r0y
oRt
Explain the rules for BFS and DFS. What arerthe data stuctures used for ( 10)
eachof the traversal method? Why are they used?
Demonstrate with the given grap[ how each fitaversal is being carried out,
where the start node is 1.

You might also like