CSE220 Final Spring-24 Set-A
CSE220 Final Spring-24 Set-A
III. Which of the following linear array is the IV. Heap = [N, 19, 15, 12, 13, 7, 5, 1, -1, 3]
most accurate and ideal representation? (N
indicates None value) This array indicates a maxHeap. Value 20 is
inserted in the heap. What will be the index
a. [1, 2, N, N, 4, 5]
of the value 7 in the new heap?
b. [1, 4, -3, N, 5, 7]
c. [1, -2, 3, N, N, N] a. 4, b. 5, c. 9, d. 10
d. [N, N, 1, 4, 5, 7]
Page 1 of 4 Set-A
V. Which of the following is FALSE?
a. Linked List does not allow random access.
b. Head node cannot be directly accessed from the Tail node in a Singly Circular Linked
List.
c. Each node has two pointers in a Doubly Circular Linked List.
d. Tail node can be directly accessed from the Head node in a Doubly Circular Linked List.
Python Notation:
def hash(list, st):
# To Do
Consider the Node class for Binary Tree already defined with elem, left and right variables. You
can use helper functions.
YOU CANNOT USE LIST OR DICTIONARY, any built-in function, or global variables.
Python Notation:
def sumTree(root):
// To do
Page 2 of 4 Set-A
Here root refers to the tree below.
True For 26
Sum of left(20)+sum of right(6)=26
For 10
Sum of left(4)+Sum of right(6)=10
For 3
Sum of left(0)+Sum of right(3)=3
You are given MaxHeap and MinHeap classes. The methods in the MaxHeap class are -
MaxInsert(), MaxDelete() and the methods in the MinHeap class are - MinInsert(), MinDelete().
The constructor of both classes does not take any parameters. The method works according to
their names and no need to implement any of the methods.
YOU MUST USE THE GIVEN HEAP DATA STRUCTURES TO SOLVE THIS PROBLEM.
Hint: No need to modify the given array. Remember that the underlying data structure of
a heap is an array.
Python Notation:
def heapSum(A, k):
# To Do
Page 3 of 4 Set-A
Question – 5: CO2 [10 Points]
Suppose you have a set of 10 vertices which are denoted as A, B, C, D, E, F, G, H, I, J.
The matrix representation below shows the relationship between any of these two vertices.
A (0) B (1) C (2) D (3) E (4) F (5) G (6) H (7) I (8) J (9)
A (0) 5 3
B (1) 7
C (2) 4 6
D (3) 2
E (4)
F (5) 8
G (6) 9
H (7) 10
I (8)
J (9) 11
[Note: Vertex A is mapped as index position 0, Vertex B is mapped as index position 1 in the
matrix and so on]
a. Using the above matrix representation, draw an adjacency list representation of the
above nodes. [3]
b. Determine whether the graph is directed or undirected. If it is undirected, transform it
into a directed graph and if it is directed, transform it into an undirected one using the
above matrix representation. Write down the resulting matrix in your script [1+2]
c. Suppose that the vertices A to J have the following weights 31, 19, 25, 40, 45, 35, 33,
27, 14, 21, 37 respectively.
i. Draw a Binary Search Tree using the vertices A to J sequentially based on their
weights. Write down the node’s weights while drawing the BST. [2]
ii. Delete the node with the key of value 31 with the help of its predecessor of the
above tree and draw the new tree. [2]
Page 4 of 4 Set-A