0% found this document useful (0 votes)
7 views

DS Questions

Uploaded by

emir
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 views

DS Questions

Uploaded by

emir
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

1. What is the definition of a leaf node in a tree data structure?

Choices

A) A childless node (answer)

B) A node adjacent to the root node

C) A node with multiple children

D) A node with a specific value

2. What is the depth of a node in a tree?


Choices

A) The length of the path from the node to the root (answer)

B) The total number of nodes in the tree

C) The number of children the node has

D) The level of the node in the tree


3. What is the term for a node adjacent to a given node on the path to the root node in a
tree data structure?
Choices

A) Parent node (answer)

B) Child node

C) Leaf node

D) Internal node
4. What is the term for an acyclic, connected graph with a specially designated root node
in data structures?
Choices

A) Node structure

B) Graph

C) Hierarchy
D) Tree (answer)

5. In a tree data structure, what is the term for a node with a child?
Choices

A) Child node

B) Root node

C) Internal node ( answer )

D) Leaf node
6. What is a tree in data structures?
● A. A linear data structure
● B. A hierarchical data structure
● C. A non-linear data structure
● D. Both B and C ( answer )

7. What is the time complexity to insert a node in a balanced binary search tree (AVL
tree)?
● A. O(log n) ( answer )
● B. O(n)
● C. O(n^2)
● D. O(1)

8. What is the purpose of a hash table?


Choices

A) To encrypt the records for secure storage

B) To perform arithmetic operations on records within the table

C) To store records with a key-value pair and quickly retrieve the value using the key

D) To sort records in ascending order based on their keys


( answer C)

.9. What is the role of the hash value in a hash table?


Choices

A) It represents the total number of records in the hash table

B) It indicates the size of the array used for storing records

C) It is used to determine the index where a record will be stored in the array ( answer C)

D) It serves as a unique identifier for each record

10.What does O(1) complexity refer to in the context of a hash table?


Choices

A) Constant time complexity for basic operations like insertion and retrieval

B) Exponential time complexity for resizing the hash table

C) Logarithmic time complexity for computing hash values

D) Linear time complexity for searching within the hash tabl


)Answer A(

11.What is the significance of the 'key' in a hash table record?


Choices

A) It indicates the position of the record within the array

B) It represents the value associated with each record in the hash table

C) It determines the order in which records are accessed

D) It is used as input to a hashing function to determine the storage location of the record

)Answer D(

12. How are empty spots handled in a hash table?


Choices

A) 'Empty' spots trigger automatic resizing of the hash table

B) Some spots contain valid records, and other spots are 'empty'
C) 'Empty' spots are removed from the array to optimize storage space

D) 'Empty' spots are filled with placeholder values to maintain array consistency
)Answer B(
13.What is the role of the push_back method in the given C++ code?

a. It deletes a key from the hash table.

b. It inserts a key into the hash table. (answer B)

c. It calculates the hash value for a given key.

d. It displays the hash table.

14.What is the purpose of the Hash class in the given C++ code?

a. It is a function to calculate hash values.

b. It is a container for storing integers.

c. It is a class for handling collisions in hash tables.

d. It is a class for implementing a hash table with chaining. ( Answer D)


15.In the given C++ code, what does the array a represent?

a. The number of buckets in the hash table.

b. The keys to be mapped into the hash table. (Answer B)

c. The values of the hash function.

d. The size of the hash table.

16. What is the main principle that a stack follows?


Choices

A) FIFO (First In, First Out)

B) LIFO (Last In, First Out) ( Answer B)

C) FILO (First In, Last Out)

D) LILO (Last In, Last Out)

17.What does a linked list implementation of a stack allow for?


Choices

A) Random access to elements in the stack

B) Efficient sorting of elements in the stack

C) Dynamic resizing of the stack as needed ( Answer)

D) Reduced memory consumption compared to an array implementation


18. What is the main purpose of using a stack in implementing undo/redo functionality?
Choices

A) To store multiple versions of the same data

B) To facilitate random access to previous states

C) To keep track of previous actions in chronological order ( answer)

D) To ensure real-time synchronization of data

19.What does the leftRotate function in the given C++ AVL tree code do?

a. It inserts a node into the AVL tree.

b. It performs a left rotation on a given AVL tree node. ( Answer )

c. It computes the maximum height between the left and right subtrees.

d. It calculates the height of the left subtree.


20.What is the purpose of the preOrder function in the given C++ AVL tree code?

a. It calculates the height of the AVL tree.

b. It inserts nodes into the AVL tree. ( Answer B )

c. It performs a pre-order traversal of the AVL tree.

d. It rotates nodes in the AVL tree.

You might also like