DS Utech Final May2022
DS Utech Final May2022
Data Structures
Final Examination; May 2022
Instruction:
i. Answer all questions in both sections. Include explanation of any assumptions
you may have made in responding to section ‘b’ questions.
ii. Remember to include your name and ID#
1. A data item that can be used to distinguish between two entities (records) is
known as
(A) Alternate key
(B) Primary key
(C) Primary data item
(D) Unique data item
8. The postfix form of the following infix notation is : (A + B)* (C*D − E)* F
(A) AB + CD*E − *F*
(B) AB+ CDE + − * F*
(C) AB+ CD − EF + − **
(D) ABCDEF* − + * +
9. What are the sequence of popped out values if the sequence of operations - push(1), push(2), pop,
push(1), push(2), pop, pop, pop, push(2), pop are performed on a stack.
(A) 2, 2, 1, 1, 2
(B) 2, 2, 1, 2, 2
(C) 2, 1, 2, 2, 1
(D) 2, 1, 2, 2, 2
11. When the data structure is combined with its operation then, the data structure is known as
a) Topology
b) Data Structure
c) Abstract Data Type
d) Multilayered
a) Recursion
b) Iteration
c) Algorithm
d) Static
13. Linear Search is best for
a) Large arrays
b) Small arrays
c) Sorted array
d) All types of arrays
14. When new data are to be inserted into a data structure, but there is no available space, this
situation is usually called
a) Complete
b) Underflow
c) Overflow
d) Packed
a) LIFO lists
b) FIFO lists
c) Piles
d) Push down list
16. Which of the following is/are the levels of implementation of data structure
A) Abstract level
B) Application level
C) Implementation level
D) All of the above
17. Inserting an item into the stack when stack is not full is called …………. Operation and
deletion of item form the stack, when stack is not empty is called ………..operation
A)pop, push
B) push, pop
C) insert, delete
D) delete, insert
18. Which of the following data structure can’t store the non-homogeneous data elements?
A) Arrays
B) Records
C) Pointers
D) Stacks
19. A ……. is a data structure that organizes data similar to a line in the supermarket, where the
first one in line is the first one out.
A) Stacks linked list
B) Queue linked list
C) Both of them
D) Neither of them
20. To represent hierarchical relationship between elements, which data structure is suitable?
A) Dequeue
B) Priority
C) Tree
D) Graph
21. A directed graph is ………………. if there is a path from each vertex to every other vertex in
the digraph
A) Weakly connected
B) Strongly Connected
C) Tightly Connected
D) Linearly Connected
22. In the …………….. traversal we process all of a vertex’s descendants before we move to an
adjacent vertex.
A) Depth First
B) Breadth First
C) With First
D) Depth Limited
25. If the elements '1', '2', '3' and '4' are inserted in a stack, what would be the order for the
removal?
a) 4321
b) 1234
c) 2314
d) 3241
SECTION B
Answer all questions
Question 1:
i. What are the properties of a digraph? [3 marks]
ii. Using vertex 1 as your source of adjacency list/matrix demonstrate the result of running
BFS and DFS on the graph in the picture below. Show the status of the data structure
used at each stage. [10 marks]
ii. Using a sketch of your own distinguish among the 3 types of linked lists. [2 * 3 marks]
iii. We study structures because they are useful in solving real problems in computer science.
Outline any 3 applications of data structures in real life. [3 marks]
Question 2:
a. Assume stack1 and stack2 to be empty at the beginning of the following sequence of
operations. Show their contents respectively at the end of the sequence. Justify why you
think your answers are correct. [3 + 3 + 1 marks]
Stack1.push(Jesse)
Stack1.push(Ramon)
Stack2.push(Johntae)
Stack2.push(Maldini)
Stack1.pop()
Stack2.getTop(stackTop)
Stack1.push(stackTop)
Stack1.push(Chevon)
Stack2.pop(stackTop)
Stack1 Stack2
Stack2.push(Aaliya)
b. Given the edges and vertices of a directed graph as indicated below, draw a picture of the
graph by using the specified properties:
G = ( V, E)
V(G) = {1, 2, 3, 4, 5, 6}
E(G) = {(1,2), (2, 3), (3, 4), (5,1), (5, 6), (2, 6), (1, 6), (4, 6), (2, 4)} [3 marks]
For the graph you have just drawn: show the
(i) Adjacency matrix [2 marks]
(ii) Write an algorithm for binary search and explain the conditions under which sequential
search of a list is preferred over binary search? [4+4 marks]
(iii) Construct an expression tree for this arithmetic expression: 3+ (4*5-(9+6)) and show the
result at each stage. [5 marks]
Question 3:
a. Construct a BST using the following sequence of numbers in the order given. 47, 32, 87,
34, 68, 72, 15, 24, 30, 66, 11, 50, 8
i. Traverse the BST created using Pre-order technique
ii. Traverse the BST created using in-order technique
iii. Traverse the BST created using Post-order. technique [4+6 marks]
b. Computer Science uses recursion in diverse ways to solve complex problems through
divide and conquer. Let’s say you have been given a stack of three plates; Large, Medium
and Small on table ‘Red’ in the order indicated. There are two other tables; ‘Green’ and
‘Blue’. Using the Towers of Hanoi recursive technique, you are required to transfer all three
plates from table ‘Red’ to table ‘Blue’.
i. What are the rules you must observe to successfully accomplish this task?
ii. How many steps would you have gone through by the time your task is completed?
[10
marks]