You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
void printOddNodes(Node *root, bool isOdd = true)
{
// If empty tree
if (root == NULL)
return;
// If current node is of odd level
if (isOdd)
cout << root->data << " " ;
// Recur for children with isOdd
// switched.
printOddNodes(root->left, !isOdd);
printOddNodes(root->right, !isOdd);
}
// Utility method to create a node
struct Node* newNode(int data)
{
struct Node* node = new Node;
node->data = data;
node->left = node->right = NULL;
return (node);
}
Details:
Programming language : Any
Directory : Data Structures/Trees
The text was updated successfully, but these errors were encountered: