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

Important Questions Unit 4&5

Uploaded by

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

Important Questions Unit 4&5

Uploaded by

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

UNIT 4

1. Given a binary tree, can you determine its height and explain how the height
of the tree affects its performance in terms of searching and insertion?
2. Create a scenario where a binary tree would be a more efficient data structure
than a linear data structure, and explain why the binary tree is a suitable
choice.
3. Define what a binary tree is and explain the roles of nodes, roots, leaves, and
branches in this data structure.
4. Given a binary tree, demonstrate how to perform an in-order traversal. Provide
the sequence of nodes visited and explain its significance.
5. Compare and contrast the advantages and disadvantages of a binary tree
compared to other tree structures.
6. Given an array representation of a binary tree, demonstrate how you would
determine the parent and child nodes for a specific element in the tree.
Provide a step-by-step explanation.
7. Compare the advantages and disadvantages of representing a binary tree
using an array versus other methods like linked lists. Under what
circumstances would you prefer an array representation?
8. Design an algorithm to convert a binary tree into an array representation.
Outline the steps involved and discuss the time complexity of your solution.
9. Explain how you would represent a binary tree using a linked list. Provide a
visual representation and discuss the benefits of using linked lists in this
context.
10. Compare the time complexity of searching for an element in a binary tree
represented by a linked list with that of an array representation. What are the
trade-offs involved in each representation?
11. Develop a method to insert a new node into a binary tree represented by a
linked list. Provide the pseudocode and discuss the efficiency of your
algorithm.
12. Given a set of numbers, construct a binary search tree. Demonstrate the step-
by-step process of inserting each element and explain how the properties of a
BST are maintained.
13. Compare the time complexity of searching for an element in a binary search
tree with that of searching in an unordered list or array. Discuss scenarios
where a BST provides better or worse performance.
14. Develop an algorithm to delete a node in a binary search tree while
maintaining its structure. Discuss the cases and considerations for different
scenarios during the deletion process.
15. Illustrate the process of balancing an AVL tree after inserting a new node.
Provide an example and explain the rotations required to maintain the AVL
tree properties.
16. Compare the advantages and disadvantages of AVL trees compared to
standard binary search trees. Under what circumstances would you choose an
AVL tree over a regular BST?
17. Design a method to check whether a given binary tree is an AVL tree. Outline
the steps involved in validating the AVL properties, and discuss the time
complexity of your algorithm.
18. What is a B-tree and what are its primary characteristics?
19. How does a B-tree differ from a binary search tree (BST)?
20. Explain the purpose and advantages of using B-trees in database systems.
21. Describe the process of inserting a new key into a B-tree and maintaining its properties.
22. What is the significance of the "order" or "degree" of a B-tree?
23. What is a Red-Black tree and how does it differ from a regular binary search tree?
24. Explain the rules that govern the coloring of nodes in a Red-Black tree.
25. How does a Red-Black tree ensure balance and why is balance important?
26. Describe the rotations used in Red-Black tree operations, such as insertion and deletion.
27. Discuss the time complexity of common operations (insertion, deletion, search) in a Red-Black
tree.
28. What is a Splay tree and what makes it different from other self-adjusting binary search trees?
29. Explain the splaying operation and how it is performed in a Splay tree.
30. Discuss the amortized time complexity of splaying in a Splay tree.
31. How does the splaying operation help improve the efficiency of recently accessed nodes?
32. Compare and contrast Splay trees with other self-adjusting binary search trees like AVL trees.

UNIT 5
33. Discuss the Knuth-Morris-Pratt (KMP) algorithm for pattern matching. How does
it improve upon the brute-force approach?
34. Explain the brute-force pattern matching algorithm. What are its limitations,
and in what scenarios is it suitable?
35. Describe the depth-first search (DFS) algorithm for traversing graphs. What are its applications?
36. Explain the breadth-first search (BFS) algorithm and discuss its advantages over depth-first search.
37. Compare and contrast the characteristics of DFS and BFS. In what scenarios would you choose one
over the other?
38. What is a graph and what are the basic components of a graph?
39. Differentiate between directed and undirected graphs. Provide examples of real-world applications
for each.
40. Explain the concepts of vertices and edges in a graph. How are they represented in computer
science?
41. Define and compare the terms "connected graph," "disconnected graph," "cyclic graph," and
"acyclic graph."

UNIT-4

1. What is a tree in data structures?

a. A linear data structure

b. A hierarchical data structure

c. A circular data structure

d. A tabular data structure

2. In a tree, a node with no children is called:

a. Root

b. Leaf

c. Parent

d. Sibling

3. In a binary tree, each node has:

a. 0 children

b. 1 child

c. 2 children

d. 3 children

4. What is the maximum number of nodes at level 3 in a binary tree?

a. 2

b. 4

c. 8

d. 16

5. In an in-order traversal of a binary tree, when does a node get visited?

a. Before its left subtree

b. After its left subtree

c. Between its left and right subtrees

d. After its right subtree

6. Which traversal visits the root node before its subtrees?


a. In-order

b. Pre-order

c. Post-order

d. Level-order

7. What is a threaded binary tree?

a. A tree with threads connecting its nodes

b. A binary tree with threads for data storage

c. A tree with nodes linked using pointers

d. A binary tree with a single thread connecting its nodes

8. In an AVL tree, what is the maximum height difference allowed between the left and right subtrees of any
node?

a. 1

b. 2

c. 3

d. 4

9. Which operation is performed during an AVL tree insertion to restore balance?

a. Rotation

b. Insertion

c. Deletion

d. In-order traversal

10. What is the primary use of B-trees in databases?

a. Sorting

b. Searching

c. Indexing

d. Encryption

11. In a Red-Black tree, what color does a newly inserted node initially have?

a. Red

b. Black

c. Blue

d. Green

12. How do splay trees adapt to improve search efficiency?

a. By balancing subtrees

b. By promoting frequently accessed nodes

c. By removing unnecessary nodes

d. By reordering the tree structure

Fill in the Blanks

1. A tree in data structures is a hierarchical data structure.


2. In a tree, a node with no children is called a __leaf__.

3. In a binary tree, each node has __2__ children.

4. The maximum number of nodes at level 3 in a binary tree is __4__.

5. In an in-order traversal of a binary tree, a node gets visited __after its left subtree__.

6. __Pre-order__ traversal visits the root node before its subtrees.

7. A threaded binary tree is a binary tree with __threads__ connecting its nodes.

8. In an AVL tree, the maximum height difference allowed between the left and right subtrees of any node is
__1__.

9. During an AVL tree insertion, the tree is restored to balance through a process called __rotation__.

10. The primary use of B-trees in databases is for __indexing__.

11. In a Red-Black tree, a newly inserted node initially has the color __red__.

12. Splay trees improve search efficiency by promoting __frequently__ accessed nodes.

UNIT 5

1. What is a graph in computer science?

a. A chart in Excel

b. A collection of interconnected nodes and edges

c. A linear data structure

d. A database table

2. What term is used to describe a graph in which each node is connected to every other node?

a. Connected graph

b. Disconnected graph

c. Cyclic graph

d. Complete graph

3. In a depth-first search (DFS), what data structure is typically used to keep track of visited nodes?

a. Queue

b. Stack

c. Priority queue

d. Linked list

4. Which algorithm is used to find the shortest path in a weighted graph?

a. Breadth-first search (BFS)

b. Depth-first search (DFS)

c. Dijkstra's algorithm

d. A* algorithm

5. What is the main drawback of the brute-force pattern matching algorithm?

a. It has high time complexity

b. It is not applicable to text processing


c. It cannot handle large datasets

d. It is not a valid pattern matching approach

6. The Knuth-Morris-Pratt (KMP) algorithm is used for:

a. Sorting

b. Graph traversal

c. Pattern matching

d. Encryption

7. What is the key idea behind the KMP algorithm for pattern matching?

a. Divide and conquer

b. Dynamic programming

c. Prefix function

d. Backtracking

Fill in the Blanks

1. A graph in computer science is a collection of interconnected nodes and edges. It is represented by a set of
__nodes__ and a set of __edges__.

2. A __complete__ graph is one in which each node is connected to every other node.

3. In a depth-first search (DFS), a __stack__ is typically used to keep track of visited nodes.

4. Dijkstra's algorithm is used to find the shortest path in a __weighted__ graph.

5. The main drawback of the brute-force pattern matching algorithm is that it has high __time complexity__.

6. The Knuth-Morris-Pratt (KMP) algorithm is primarily used for __pattern matching__.

7. The key idea behind the KMP algorithm is the use of a __prefix function__.

You might also like