Left View Of Binary Tree | Data Structure & Algorithms

preview_player
Показать описание
Left view of a binary tree is a set of nodes visible when tree is seen from the left side .
In order to understand this you need to have an understanding of level order traversal as well.

Algorithm :
1-Create a queue
2-enqueue root element to queue
3-dequeue root element and push left and right child
4-while dequeuing verify if the dequeued node is first node for that level
5-Print the node

Time Complexity :O(n) where n is No of nodes in the tree.

Company Tag : Flipkart ,Amazon, MakeMyTrip, Ola, QualCom as per geeksforgeeks
Рекомендации по теме
visit shbcf.ru