![]() ![]() Now lets discuss on the solution, Since you are traversing in the BFS fashion, Let us define a flag variable which is set to true when ever the child is found to be a null. Well this approach will not cover some corner cases. ![]() ![]() so you pop the elements and each popped element should not have any children. So for this you try to add a element in the Que such that it indicates that the level has completed. If we know that when we traverse in Breadth fashion way and if we encounter a null value that has to be last element in the tree. Before we discuss on the solution lets say on the possible discussions. In this problem we are given a binary tree and we need to find whether if it is a complete binary tree or not. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |