We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Through the lines where you use recursion i.e levelOrder(root->left) and levelOrder(root->right) you are first traversing the left side of the binary tree and then the right. Thus your usage of recursion here is wrong.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Tree: Level Order Traversal
You are viewing a single comment's thread. Return to all comments →
Through the lines where you use recursion i.e levelOrder(root->left) and levelOrder(root->right) you are first traversing the left side of the binary tree and then the right. Thus your usage of recursion here is wrong.