Boundary order traversal using bfs

code–>


question–>
https://practice.geeksforgeeks.org/problems/boundary-traversal-of-binary-tree/1
it is showing segmentation fault

hello @sheikhhaji18 how many test cases you are able to pass?

no its showing segmentation fault

@sheikhhaji18 okay please wait .

bro have u found what is wrong with code

hey @sheikhhaji18 the problem with your approach is that you are taking the leftmost part of the tree and not the leftview itself.
in left boundary leftview will come, just like we generate with queue and bfs we do. and same for the right as well.
you are just simply iterating and because of this you are missing many nodes in between.
please see the updated:


Happy Learning !!