-
-
Save kaniket7209/7fb7488ea5a838eaaa1273815d8dff20 to your computer and use it in GitHub Desktop.
Level Order Traversal Of Binary Tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Can we use hashmap functionality to travel linewise in binary tree? | |
Answer: Yes we can assign keys for different levels and store the values of childrens in levels and do so. | |
2. Can we use recursion to tarvel linewise in binary tree? | |
Answer: Yes we can but we have to use extra parameters for levels. | |
3. Can we use any other data structure despite queue to travel linewise in binary tree? | |
Answer: Yes we can use stack also. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Can we use queue to solve this. | |
2. Use RPA Algo(Remove, print and add) | |
3. Loop is iterated for all the children at a level. | |
4. Process is continued for all the elements of each level and then for the next level until the queue is empty. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. The time complexity for Level Order Traversal Of Binary Tree is | |
a) O(1) | |
b) O(n) | |
c) O(log n) | |
d) O(nxn) | |
Answer: b) O(n) | |
2. The space complexity for Level Order Traversal Of Binary Tree is | |
a) O(1) | |
b) O(n) | |
c) O(log n) | |
d) O(nxn) | |
Answer: b) O(n) | |
3. The pre order traversal of a binary search tree is 15, 10, 12, 11, 20, 18, 16, 19.Which one of the following is the post order traversal of the tree? | |
a) 10, 11, 12, 15, 16, 18, 19, 20 | |
b) 11, 12, 10, 16, 19, 18, 20, 15 | |
c) 20, 19, 18, 16, 15, 12, 11, 10 | |
d) 19, 16, 18, 20, 11, 12, 10, 15 | |
Answer: b) 11, 12, 10, 16, 19, 18, 20, 15 | |
4. The elements in pre order traversal of a binary search tree is always sorted. Is it True or false? | |
Answer: True | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment