The document contains questions and answers related to binary search trees and graphs. It discusses finding the minimum element in a binary search tree, different tree traversals like preorder, inorder and postorder, properties of binary search trees like the increasing order of inorder traversal and complexity, balance factors of binary trees, cut vertices in graphs, and properties of complete graphs.
Introduction to Data structure & Algorithms - Sethuonline.com | Sathyabama Un...sethuraman R
Introduction to Data structure Algorithms
R.Sethuraman M.E,(PhD).,
Assistant Professor,
Faculty of Computing,
Dept of Computer Science Engineering,
Sathyabama University
http://Sethuonline.com
Introduction to Data structure & Algorithms - Sethuonline.com | Sathyabama Un...sethuraman R
Introduction to Data structure Algorithms
R.Sethuraman M.E,(PhD).,
Assistant Professor,
Faculty of Computing,
Dept of Computer Science Engineering,
Sathyabama University
http://Sethuonline.com
We have compiled the most important slides from each speaker's presentation. This year’s compilation, available for free, captures the key insights and contributions shared during the DfMAy 2024 conference.
Hierarchical Digital Twin of a Naval Power SystemKerry Sado
A hierarchical digital twin of a Naval DC power system has been developed and experimentally verified. Similar to other state-of-the-art digital twins, this technology creates a digital replica of the physical system executed in real-time or faster, which can modify hardware controls. However, its advantage stems from distributing computational efforts by utilizing a hierarchical structure composed of lower-level digital twin blocks and a higher-level system digital twin. Each digital twin block is associated with a physical subsystem of the hardware and communicates with a singular system digital twin, which creates a system-level response. By extracting information from each level of the hierarchy, power system controls of the hardware were reconfigured autonomously. This hierarchical digital twin development offers several advantages over other digital twins, particularly in the field of naval power systems. The hierarchical structure allows for greater computational efficiency and scalability while the ability to autonomously reconfigure hardware controls offers increased flexibility and responsiveness. The hierarchical decomposition and models utilized were well aligned with the physical twin, as indicated by the maximum deviations between the developed digital twin hierarchy and the hardware.
HEAP SORT ILLUSTRATED WITH HEAPIFY, BUILD HEAP FOR DYNAMIC ARRAYS.
Heap sort is a comparison-based sorting technique based on Binary Heap data structure. It is similar to the selection sort where we first find the minimum element and place the minimum element at the beginning. Repeat the same process for the remaining elements.
2. How will you find the minimum element in a binary search
tree?
3. How will you find the minimum element in
a binary search tree?
public void min(Tree root)
{
while(root.left() != null)
{ root = root.left(); }
System.out.println(root.data());
}
4. What does the following piece of code do?
public void func(Tree root)
{
System.out.println(root.data());
func(root.left());
func(root.right());
}
a) Preorder traversal
b) Inorder traversal
c) Postorder traversal
d) Level order traversal
5. What does the following piece of code do?
public void func(Tree root)
{
System.out.println(root.data());
func(root.left());
func(root.right());
}
a) Preorder traversal
b) Inorder traversal
c) Postorder traversal
d) Level order traversal
Postorder traversal
6. What is the speciality about the inorder traversal of a binary search tree?
a) It traverses in a non increasing order
b) It traverses in an increasing order
c) It traverses in a random fashion
d) It traverses based on priority of the node
7. What is the speciality about the inorder traversal of a binary search tree?
a) It traverses in a non increasing order
b) It traverses in an increasing order
c) It traverses in a random fashion
d) It traverses based on priority of the node
b) It traverses in an increasing order
8. What are the worst case and average case complexities of a binary search tree?
a) O(n), O(n)
b) O(logn), O(logn)
c) O(logn), O(n)
d) O(n), O(logn)
9. What are the worst case and average case complexities of a binary search tree?
a) O(n), O(n)
b) O(logn), O(logn)
c) O(logn), O(n)
d) O(n), O(logn)
Answer: d
Explanation: Worst case arises when the tree is skewed(either to the left or right) in which case
you have to process all the nodes of the tree giving O(n) complexity, otherwise O(logn) as you
process only the left half or the right half of the tree.
10. Construct a binary search tree with the below information.
The preorder traversal of a binary search tree
10, 4, 3, 5, 11, 12.
11. Construct a binary search tree with the below information.
The preorder traversal of a binary search tree
10, 4, 3, 5, 11, 12.
12. 2. The balance factor of a node in a binary tree is defined as _____
a) addition of heights of left and right subtrees
b) height of right subtree minus height of left subtree
c) height of left subtree minus height of right subtree
d) height of right subtree minus one
13. 2. The balance factor of a node in a binary tree is defined as _____
a) addition of heights of left and right subtrees
b) height of right subtree minus height of left subtree
c) height of left subtree minus height of right subtree
d) height of right subtree minus one
Answer: c
Explanation: For a node in a binary tree, the difference between the heights of its left subtree and
right subtree is known as balance factor of the node.
14. A binary tree is balanced if the difference between left and right subtree of every node is not
more than ____
a) 1
b) 3
c) 2
d) 0
15. A binary tree is balanced if the difference between left and right subtree of every node is not
more than ____
a) 1
b) 3
c) 2
d) 0
Answer: a
Explanation: In a balanced binary tree the heights of two subtrees of every node never differ by
more than 1.
16. Which of the following tree data structures is not a balanced binary tree?
a) AVL tree
b) Red-black tree
c) Splay tree
d) B-tree
17. Which of the following tree data structures is not a balanced binary tree?
a) AVL tree
b) Red-black tree
c) Splay tree
d) B-tree
Answer: d
Explanation: All the tree data structures given in options are balanced, but B-tree can have more
than two children.
18. Find inorder successor for the given key in a BST
The inorder successor of 8 is ?
The inorder successor of 12 is ?
The inorder successor of 25 ?
19. The leaves of an expression tree always contain?
a) operators
b) operands
c) null
d) expression
20. The leaves of an expression tree always contain?
a) operators
b) operands
c) null
d) expression
Answer: b
Explanation: The leaves of an expression tree always contain the result of a given expression
(i.e.) operands.
21. ++a*bc*+defg is an?
a) postfix expression
b) infix expression
c) prefix expression
d) invalid expression
22. ++a*bc*+defg is an?
a) postfix expression
b) infix expression
c) prefix expression
d) invalid expression
Answer: c
Explanation: It is a prefix expression obtained from a preorder traversal since it is of the form
operator-operand-operand.
23. What is the postfix expression for the following
expression tree?
a) abcde++**
b) ab+cde+**
c) abc+de+**
d) abcd+*e+*
24. What is the postfix expression for the following
expression tree?
a) abcde++**
b) ab+cde+**
c) abc+de+**
d) abcd+*e+*
Answer: b
Explanation: If the given expression tree is evaluated, the postfix
expression ab+cde+** is obtained.
25. In the given graph identify the cut vertices.
a) B and E
b) C and D
c) A and E
d) C and B
26. In the given graph identify the cut vertices.
a) B and E
b) C and D
c) A and E
d) C and B
Answer: d
Explanation: After removing either B or C, the graph becomes
disconnected.
27. 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
28. 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
Answer: c
Explanation: After removing vertices B and C, the graph becomes
disconnected.
29. What is the number of edges present in a complete graph having n vertices?
a) (n*(n+1))/2
b) (n*(n-1))/2
c) n
d) Information given is insufficient
30. What is the number of edges present in a complete graph having n vertices?
a) (n*(n+1))/2
b) (n*(n-1))/2
c) n
d) Information given is insufficient
Answer: b
Explanation: Number of ways in which every vertex can be connected to each other is nC2.
31. The given Graph is regular.
a) True
b) False
Answer: a
Explanation: In a regular graph, degrees of all the vertices are equal. In
the given graph the degree of every vertex is 3.