0% found this document useful (0 votes)
44 views6 pages

PracticeTest2 CSD201 ODD

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 6

CSD201 PROGRESS TEST 2

Time (60 minutes) The Question will be submitted along with your source code
to edu-next.

PART 1: Answer the Question. (40 pts)


1. Given an empty AVL tree, how would you construct the AVL tree when a set of numbers
are given without performing any rotations?
a. just build the tree with the given input
b. find the median of the set of elements given, make it as root, and construct the tree
c. use trial and error
d. use dynamic programming to build the tree

2. What do the below definitions convey?


i. A binary tree is balanced if for every node it is going to hold that the number of inner nodes in the
left subtree and the number of inner nodes in the right subtree differ by at most 1.

ii. A binary tree is balanced if, for any two leaves, the difference of the depth is at most 1.

a. weight-balanced and height-balanced tree definitions


b. height-balanced and weight-balanced tree definitions
c. definitions of weight-balanced tree
d. definitions of height-balanced tree

3. Searching and sorting algorithms are best implemented with which data structure?
a. An array-based list
b. A linked list
c. Both of the above
d. None of the above

4. A binary search algorithm can be best described as what?

a. An instant lookup method


b. A divide and conquer technique
c. Start at the head, and move through the list until found
d. None of the above

5. The following best describes which algorithm? The elements are compared and swapped if the first
is found to be greater than the next element.

a. Selection-sort algorithm
b. Quick-sort algorithm
c. Bubble-sort algorithm
d. None of the above

6. For the given graph(G), which of the following statements is true?

a. G is a complete graph
b. G is not a connected graph
c. The vertex connectivity of the graph is 2
d. The edge connectivity of the graph is 1

7. Binary search tree T is said to be balanced when for every node n in T?

a. n’s left and right subtrees have equal height.

b. n’s left and right subtrees have equal size.

c. n’s left and right subtrees have heights that differ by at most one.

d. n’s left and right subtrees have sizes that differ by at most one

8. The set of all addition edges generated by the BFS tree starting at node A is.
a. BDFGCE
b. D
c. ACDGFE
d. Cannot be generated

9. The set of all edges generated by the DFS tree starting at node B is.

a. BADCGFE
b. BCDAFEG
c. BGCEDAF
d. Cannot be generated

10. The common data structure required for Breadth First Traversal on a graph is.
a. Stack
b. Queue
c. Tree
d. All of the above

11 Which is the correct order for Kruskal’s minimum spanning tree algorithm to add edges to
the minimum spanning tree for the figure shown Below?
a. (AD)(BD)(DE)(EG)(GF)(AC)
b. (AD)(EG)(BD)(BE)(GF)(AC)
c. None of the above
d. Both of the above

12. For minimum spanning tree (MST) construction, Prim’s algorithm selects?
a. With minimum weight so that the cost of MST is always minimum
b. with the maximum number of vertices connected to it so that MST has the least
diameter
c. that does not introduce a cycle
d. that adds a new vertex to a partially constructed tree with minimal increment in the
cost of MST

13. Suppose a hash table can contain 10 entries and if required, it uses linear probing to
resolve collisions. Using key % 10 as a hash function, if key values 41, 165, 62, 123, 142 are
hashed, then the location of the key 142 is?
a. 2
b. 3
c. 4
d. 5
e. 6

14. The max heap constructed from the list of numbers 19 2 63 52 47 6 3 18 33 is


a. 63 47 52 33 19 18 6 3 2
b. 63 52 47 33 19 18 6 3 2
c. 63 47 52 19 33 6 18 2 3
d. 63 47 52 33 19 18 6 2 3

15. Suppose we remove the root node from the following BST tree, which could be
the new root?
a. 2
b. 1
c. 5
d. 4

16. Suppose we are sorting an array of eight integers using quick sort, and we have just
finished the first partitioning with the array looking like this: 2 5 1 7 9 12 11 10 Which
statement is correct?
a. the pivot could be 7 or 9
b. the pivot could be 7
c. the pivot could be 9
d. none of the above

17. In the quick sort method, a desirable choice for the portioning element in real-life data
will be?
a. The first element of the list.
b. The median element of the list.
c. The last element of the list.
d. The average value.

18, The number of swapping needed to sort the numbers 8,22,7,9,31,19,5,13 in the bubble-
sort algorithm for ascending order?
a. 14
b. 12
c. 13
d. 11

19) Consider a hash table of size seven, with starting index zero, and a hash function
(3x + 4) mod 11.
Assuming the hash table is initially empty and has a size of 10,
which of the following is the contents of the table when the sequence 1, 3, 8, 10, 7, 6?
a. 726130
b. 1 3 8 6 7 10
c. 6 10 3 7 8 1
d. 10 8 7 6 3 1

20) The minimum spanning tree problem belong to


a. Greedy
b. Dynamic Programming
c. Divide and conquer
d. None of the above

PART 2: (60 pts)


2. Construct the adjacency list for the following graph.
Construct the adjacency list for the following graph.
a. Write BFS method to traverse this graph from any vertex
b. Write DFS method to traverse this graph by graph by label from
Z – A order
c. From A, write a method to answer is F reachable, if F reachable
show the shortest path to F and its weight.
d. Construct minimum spanning tree from this graph
e. Write method to find Euler-path or circle for this graph

You might also like