Important Questions Unit 4&5
Important Questions Unit 4&5
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
a. Root
b. Leaf
c. Parent
d. Sibling
a. 0 children
b. 1 child
c. 2 children
d. 3 children
a. 2
b. 4
c. 8
d. 16
b. Pre-order
c. Post-order
d. Level-order
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
a. Rotation
b. Insertion
c. Deletion
d. In-order traversal
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
a. By balancing subtrees
5. In an in-order traversal of a binary tree, a node gets visited __after its left subtree__.
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__.
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
a. A chart in Excel
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
c. Dijkstra's algorithm
d. A* algorithm
a. Sorting
b. Graph traversal
c. Pattern matching
d. Encryption
7. What is the key idea behind the KMP algorithm for pattern matching?
b. Dynamic programming
c. Prefix function
d. Backtracking
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.
5. The main drawback of the brute-force pattern matching algorithm is that it has high __time complexity__.
7. The key idea behind the KMP algorithm is the use of a __prefix function__.