Data Structures & AlgorithmsEasyTCS NQT · Infosys pattern
Which traversal of a binary search tree visits the keys in ascending order?
- A. Inorder
- B. Preorder
- C. Level order
- D. Postorder
Correct answer: A. Inorder
Inorder visits left subtree, root, right subtree; in a BST everything on the left is smaller and everything on the right larger, so the keys come out sorted.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- Which data structure does breadth-first search (BFS) use to decide which vertex to visit next?
- How many edges does a tree with n vertices have?
- In a min-heap, where is the smallest element always found?
- What is the space needed by the adjacency-matrix representation of a graph with V vertices and E edges?
- Depth-first search is naturally implemented with which of the following?
- A binary tree has root 1; 1's children are 2 (left) and 3 (right); 2's children are 4 (left) and 5 (right); 3 has only a right child, 6…