F I. Abstraction? Ii. Examples. Algorithm.: of of
F I. Abstraction? Ii. Examples. Algorithm.: of of
)
i. List five applications that use stacks as tools. (05 Marks)
ii. A route-map of a city can be modeled using dynamically linked nodes, if there
is a provision to keep the list of neighboring locations with a node. Suggest a
rlurt for
suitable structure Lrrr) purpose.
rur this L'elllle the
PUrPU>e' Define Lrle suggesrea structure uslng
suggested srrucrure usin
(09 Marks)
C/C++.
iii. lmplement a method to count and print the number of neighbors of each
location of the map implemented using the structure in above ii. (06 Marks)
a. a+(b+c*(d-f))/g+h
b. ((a+b*c)*(d-e))/(f+g)+h (04 Marks)
ii. Explain the steps of evaluating a given postfix expression using a suitable data
structure. (06 Marks)
iii. Convert the expression o/2 + b * ((c+ d)/e) +f*g into postfix and illustrate the
evaluation of it using the algorithm developed in above ii,
"' if" a=9,
- -' b-3, c-s, d=7
e=6,f=2and g=1. (04 Marks)
iv. Assume that you have declared the structure of a doubly-linked list. Write a
C/C++ function to insert an item into a sorted doubly-linked list. (08 Marks)
I Compare and contrast array based queues and priority queues. (04 Marks)
il Explain the processes of percolating down and percolating up in priority
queues.
(05 Marks)
lnsert the following list of numbers into a priority queue assuming the least
has the highest priority.
List: 12,5,10, 8,4, L5, 20,9, L (04 Marks)
iv. lllustrate the removal of highest priority value of the above priority queue. (02 Marks)
v. Write a CIC++ function to insert an item into a priority queue. (04 Marks)
5
I Write the recursive definition of the binary search tree (BST) structure. (04 Marks)
il Define the following terms with respect to BST:
Staft
lnitiolize two queues Q7, Q2
Node=root of the tree
lnsert Node into Q7
WHILE Ql is not EmpU
Node = remove first of Ql
lnsert the volue of Node into Q2
lf there is left child of Node insert left child into Ql
lf there is right child of Node insert right child into el
END WHILE
Print Q2
End
a. Traverse the tree above in iii. using this algorithm and write the output. (04 Marks)
b. What does this algorithm demonstrate? (lnterpret the output) (02 Marks)