Final Exam Question 171 CSI217
Final Exam Question 171 CSI217
1. a. What are the merits of linear circular linked list over linear linked list? [2]
b. Develop an algorithm to delete middle element from a doubly linked list. [2]
c. Design two algorithms to insert and delete first element to/from a linear circular linked
list. [4]
d. Write an algorithm to display elements of doubly linked list in reverse order. [2]
3. a. Convert the following infix expression into postfix using STACK and evaluate the
postfix expression for the given values. [5]
Infix expression: a * a - (b + c / d) + e * f
Given values: a=2, b=3, c=4, d=2, e=3 and f=2
b. Given, double A[100], which represents a one dimensional array of type double. If
loc(A[0])=6FADE then, find loc(A[60]). [1]
c. Design a recursive algorithm for TOWER OF HANOI using one intermediate
pillar/peg and show simulation for n = 3, where n is the number of disks. [2]
d. Design an iterative algorithm for TOWER OF HONOI assuming two intermediate
pillars/pegs. [2]
6. a. Suppose you are waiting for having a train ticket in a railway station. The station
manager tells you to maintain a line for ticket. Answer the following questions based on
this scenario. [3]
i. Which data structure are appropriate for maintaing a line?
ii. Implement a line using your data structure.
iii. How will you track the start and end of a line?
b. Which data structures are more appropriate for the following cases and why? [3]
i. For implementing the binary search tree.
ii. For reducing the memory wastage in a sparse matrix.
Iii. For storing student information like name, id, birthday, marks.
c. Write an algorithm to construct binary tree in memory. [2]
d. Design an algorithm to evaluate the following Binary Expression Tree (BET). [2]
Explanation: For the above BET, calculation will be in the following order:
= (12-3) * 2
=9*2
= 18, which is the final answer.