0% found this document useful (0 votes)
7 views8 pages

2025 DS Example Final Exam Updated

The document is a final exam for a Data Structures course, consisting of true/false questions, multiple-choice questions, and coding exercises related to various data structures like Binary Search Trees, AVL Trees, and graphs. It evaluates students' understanding of concepts such as time complexity, collision resolution, and specific algorithms like Dijkstra's and Prim's. Additionally, it includes tasks requiring diagrammatic representations of tree and graph structures.

Uploaded by

ncl9100
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views8 pages

2025 DS Example Final Exam Updated

The document is a final exam for a Data Structures course, consisting of true/false questions, multiple-choice questions, and coding exercises related to various data structures like Binary Search Trees, AVL Trees, and graphs. It evaluates students' understanding of concepts such as time complexity, collision resolution, and specific algorithms like Dijkstra's and Prim's. Additionally, it includes tasks requiring diagrammatic representations of tree and graph structures.

Uploaded by

ncl9100
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Data Structures – Final Exam

(Example)
Name:
NYU NetID:
--------------------------------------------------------------------
A. Please read the following questions and respond with either T or F.
(Correct answers earn +2 points each, incorrect responses result in -1
point, and if left unanswered, no points will be awarded.)
1. All key values in each node of Binary Search Tree (BST) are unique.
( )
2. Time complexity of search, delete and insert operations of BST is
always O(log n). ( )
3. In AVL Tree, the Balance Factor (BF) at each node is. -1, 0 and 1 ( )
4. In AVL Tree, there are three generalized imbalanced cases ( )
5. A "high load factor" is one of the main causes of hash collisions. ( )
6. When using Chaining as collision resolution, the size of hash table
can be changed ( )
7. In a directed graph, the in-degree and out-degree of a vertex are
always equal. ( )
8. A connected graph with 𝑛 vertices and 𝑛 − 1 edges is always a tree.
( )
9. Path of Graph is a sequence of adjacent vertices from vertex u to
vertex v. ( )
10. To get a minimum spanning tree from Graph, Dikstra’s algorithm can
be used. ( )
B. Please read the following questions and options, then check the one that
corresponds to the correct answer.

1. Choose all operations with a time complexity (Big-O) of log n (e.g.,


O(log n)). Ignore the worst case of Tree or collision case of Hash
Table.

① Insert() operation of Hash


② Delete() operation of Hash
③ Search() operation of Hash
④ Insert() operation of BST
⑤ Delete() operation of BST
⑥ Search() operation of BST
2. The following code is the implementation of search() operation of
BST. Choose all appropriate code to fill in the blank spaces in the
following code

① [1] searchKey.compareTo(tNode.key) > 0, [2] tNode.right, [3] tNode.left


② [1] searchKey.compareTo(tNode.key) > 0, [2] tNode.left, [3] tNode.right
③ [1] searchKey.compareTo(tNode.key) < 0, [2] tNode.left, [3] tNode.right
④ [1] searchKey.compareTo(tNode.key) < 0, [2] tNode.right, [3] tNode.left
C. Please read the following question and fill in the blank space with the
appropriate code. (Node: Strict adherence to JAVA syntax is not
necessary).

1. The following code is the implementation of insertItem() of AVLTree.


Fill in the blank spaces ([1] and [2]) with the appropriate code.
2. The following code is the implementation of Prim’s algorithm. Fill in
the blank spaces ([1] and [2]) with the appropriate code.
D. Please carefully read the following problem and draw an appropriate
diagram.

1. The below figure shows the part of an AVL tree. After executing
delete(9), the below subtree becomes imbalanced. Draw the balanced
subtree after repairing this subtree with the appropriate rotation.
2. The below figure shows an undirected Graph G=(V,E). Mark the
visited edges after conducting Breadth-First Search (BFS). Then, we
consider that the vertex r is starting vertex.
3. The below figure shows a weighted directed Graph G=(V,E). Shows
the shortest path determined by applying Dijkstra’s algorithm. Then,
we consider that the vertex r is starting vertex.

You might also like