Data st. & alg
Data st. & alg
INSTITUTE OF ENGINEERiNG BE
. r11I NrSIkr . 8_0 j
1, What are linear and nonlinear data structures? Define abstract data type (ADT) with
suitable example. [1+3]
2. Conveft foliowing infix expressions to Postflx and Evaluate the posthx expressions using
A:8, B:5, C:4, D:6. E:2, F:1, G:12and H:3. [5+3]
A+(B"C-(DiE+F)-C)*H
a
Explain how circular quene is efficient comparecl to linear queue. Write down an
algorithm to perform insertion and deletion operation in a linear queLle, [2*3]
4. Explain alray representation of list. Hou'it is different from dyrramic list? l2+2)
5. Write an algorithm to inserl a new nodr' a er any given node in doubly linked list.
Explain hor.r'you add two polSrnotttiais q,ith the help of linked list" 14+41
6. Write an algoritiirn to llnd n'h Fibonacci number using tail recursion. Generate a recursion
tree of TOH problem with 4 disks. [3t-5]
7. What do you rnean by complete binary tree? Explain w'ith example. Create an AVL
balanced tree for the follow'ing sequence of elements: 10, 9, 8, 4. 5,7,32,16, 11 , 1. 1)
andZ. 12+6)
B. Create a Binary Search Tree b,v inserting the nodes: 12. 15,25. 18,20,30,28, 10 and 5.
Then delete element 25 ltom it. [3+2]
9. Explain Heap as prioritl' queue. Use heap sort to sort the foliorving mrmbers: 27,23, 16,
82,47,18,38, 15,2.76,22 and12. 12+6)
10. What is coliision? What are the techniques used for collision resolution in hashing? Insert
the keys: 52,27, 16, 74, 97,21,82, 41 and 31 using quadratic probing method. The hash
function is h: (key) : key o/o 10 (Where 10 is the table size). ll+2+51
11. Define Big-Oh and Theta notation with suitable example. t4l
12. What is minimum spanning tree? Explain Warshall's algorithm with example. Define
Dijkstra's algorithrn ivith expianation. 12+4+41
ri( ,{< *
r_- -_---___----------_--__
TRIBHUVAN LINIVERSITY i Exam.
i.''..,...,..'-.--'........'-*-,,,......,,,,-,,.,,,,,,,,.,,,..m
INSTITUTE OF ENGINEERING ! Nlarks 80
Levet BE Full i
1. structure.
Define data structure, I)ifferentiate between prirnitive and non primitive L2+2)
2. What is stack? Convert the inf,rx expression 6+$*g+(dre-1)*g into infix expression. 12+6)
3" Def'rne Queue with its logical representation. W-rite an algorithm to enqueue 0 and
dequeue 0 element in Circular Queue. l2+4)
4. Write algorithm to insert data at the beginning in an'ay implementation ofllists. 141
5. Write an algorithm to insert a ne\v nr:de after a given node and to delete the last node of
singly linked list. 14+41
6. What is recursion? Erplain recursir-e moJule lor Toter rriHartoi l IOli) problern. Q+al
7. Construct an AVL tree for foilouing seqrien.e oielenr,'nt. -il. i6. 56.:r. 63,i2.30,25.
20, 10. i6t
L-J
10. Define Sorting and its iypes. Sort the given eiements using Shell Sort: [3+5]
Elements: 25, 31, 77, 21, 33, 9, 1 1, 7, 3
11. Explainhow collision occurs? Use quadratic probing to insert follovring keys: 72,27,35,
24,53,81, and 101 into the hash table, considering hash table size 10. And also list out its
advantages and disadvantages. l2+'l+11
12. Define minimum spanning tree. Create a minimum spanning tree for the follow-ing graph
using Krushkal's algorithm. [2+81
I
1. Expiain the importance of data structures and point out the areas in which data structures
are being applied extensively. Explain why List is called as Abstract Data type (ADT). 12+21
2. Define stack. Convert following infix expression to postfix expression showing stack
status in each step: Ax(B+C) -(B"D)*A + E i F. [2+6]
3. Explain the significance of dynamic list data structures over static iist. Write algorithms
to implement list structure using array tor the operations:
a) Insert at given position in the list
b) Delete from given position in the iist 12+al
4. Consider two linked lists that represent two polynomials. Subtract them and return the
difference as a linked list. Write an algorithm and program to implement above scenario. t10]
5. Explain how recursion uses stack data structures, use factorial of number calculation to
illustrate the concept. t6l
6. Explain pre-order and in-order tree traversal with example. Construct an AVL bala:rced
tree with given set of data: 15,20,24,1A,13,7,30,36,25 [3+3+6]
V. Construct a Huffman code for the given s. t6l
Symbol A B C D E F
Frequency (in 35 18 10 20 9 8
thousands)
8. Write an algorithm for quick sort. Sort the following numbers using quick sort:
30,25,79,19,48,28,21,44 andllA. t8]
9. What is collision? What are the techniques used for collision resolution in hashing? Insert
the keys:62 ,37 ,36,44,67 ,91,82, and 3 1 using quadratic probing method. The hash function
is: h(key) = key % 10 (where 10 is the table size). [1+2+5]
10. How do you find complexity of any algorithm? Explain with suitable example. t4l
11. Explain the concept of minimum spanning tree (MST) and fiod MST for the following
graph using Kruskal's algorithm: 12+61
TRIBHUVAN UNIVERSITY Exam. ftsgular
INSTITUTE OF ENGINEERING Level BE Full Marla 80
Examination Control Division Programme BCT, BEI Pass Marks 32
2077 Chaitra Year / Part II/II Time 3 hrs.
I ' Briefly explain the statement "ADT provides extraction" with suitable e:<ample.
l4I
2. Define stack. Converl folloi,ving infix expression showing stack status after
erzer), step. 12+61
*
(A*B (((C^X+D^Y)+E/Z)* F)))
3' What is queue? What are different operations that can be performed
over queue? 12+61
4. Illustrate the use of stack in recursion taking any recursive program of your
choice. t6l
5. Briefly explain the significance of asymptotic notations with suitable diagram.
t4I
6. Describe an AVL tree. Construct AVL tree for following sequence of elements: 5, 10, 15,
30,25,20,4,2,1
[2+6)
7. Define collision. Insert the keys 30. 15, 69,28,49. 5g, 7g andgl using
quadratic probing
method. The hash function is :h(ke1'): keyo410 where 10 is the tabte
Jze. 12+6)
8. Create a heap tree shorving each insertion steps fbr the follou,ing data: 2g, 24. 50, 36, 42,
58,22, 56,46, Use same heap tree to sort the data showing each intermediate
step. l8l
9. Explain with example how nthnode in a singry linked list can be deleted?
t6l
10' Expiain balancing of B-tree with example. Construct an AVL tree from
foilowing
sequence ofdata: 10,2A,15,25,30, 16, 1g, 19.
[4+6]
l1' Define depth first and breadth first traversal. Construct the minimum spanning
tree
(lvfsr) for the given graph using Krushkal's algorithm.
[4-F6]
**!&
TRIBHUVAN UNIVERSITY Exarn.
INSTITUTE OF ENGINEERING LeveI BE Full Marks 80
Examination Control Division Programme BCT PassMarks 3Z
2076 Baisakh Year / Part II/il Time 3 hrs,
'/ Candidates are required to give their answers in their ov,rn words as far as pr::cticable.
/ Attempt $tl-questions.
,/ The.figures in tlte margin indicate FqU Mqrks.
,/ Assuwe suitable data if necessary.
2. Write nn algorithm fcrr converting infix expression to postfix expressicn. convert the
given infix expression to postfix expression using above algorithm:-
a'"Lr*c,-d -e -f /e l(g-h) [5+5]
3" Wi:at is ditfercnce betu,eei: static and d.vnamic implementation of iist? Horv do you inseft
eleur*nt in static list? [3+3]
4. Iixplain how the addition of pol1,'nomial equations is doue using linked list. Write an
algorithm to insert element in queue using linked list. l5+5]
5" Explain horv rec'ursive program uses stack with illustrative stack diagram. Write an
alsoritltm fcrr solving J'orver Hanoi problem with 'n' discs. [4 f4]
6. \\rhat is an AV[, tree? Construct AVL tree using lollowing sequence of data:
1{:i , 27 ,9. 11 . 3 6, 54, 81 , 63, 72 [2+61
7. example.
Describe the inserlion operation in B-tree rn'ith suitable td"l
8. Define () megii and Theta notation rvith suitable example. 14]
9. jlefine Collision. Insert fbllor,ving keys: 30, 25,79, 19, 48, 2&,21 and 44 in hash table
irsing linear irrobing method vihere h(kcv) : key 4,6 LCI. 12+6]
1n Prove that tiine cornpiexity of bubble srrrt is O(rr'). Sort tlie numbers 40, 90,20, 10, 30, 5,
50, 100, 80 using heap sort method. [2+6]
11 Explain Warshall's aigorithm with example. Determine the breadth first topological
ordering ltrr the fbllou,irig graph. [4+4j
/* 1
36
- TRIBHUVAN T.INIVERSITY Exam. I{r:rular
INSTITI-TTE OF ENGINEERING Level BE Full Marks 80
1. What do you mean by Abshact Data Type? What is difference between primitive and non
primitive data sfructure? [2+21
2. Define stack. ConvErt given infix expression to postfix showing stack status in each step: 12+61
(A+B*(C+D/E)^F*G)
3. Define linear qusue and circular queue. Explain queue operation in circular queue. [3+5]
4. Discuss advantages and disadvantages of recursion. Generate a recursion tree for TOH
problem consisting 3-discs. [3+5]
5. Differentiate between array implementation and Dynamic implementation of list with
suitable example. t4I
6. Write an algorithm and element after Ke node in doubly linked list. Explain the
advantages and disadvantages of using doubly linked list. [4+4]
7. Define almost complete binary tree. Construct a tree from its given preorder and inorder
traversals. 12+61
Inorder: EACKFHDBG
Preorder: FAEKCDHGB
8. Write an algorithm for insertion sort. Sort the following number using radix sort:
l4l, 456, 342, 7 89, 90,2,87 0,192,938 and 243 [4+6]
9. Draw hash table obtained from double hashing with hash functions: hl(K) = K mod 11
and h2(K) = K mod 9 for the given keys: 76,36,47,49,2L,65 with table size 11. Use
hp(ki):(h1(k) +i*h2(k))modm. t8I
10. Explain Big'oh notation with its significance and limitation. t4I
11. What is minimum spanning hee? Explain \Marshall's algorithm with example. [2+8]
rf **