Which of the following is a valid way to implement a binary tree node in C++?

Practice Questions

1 question
Q1
Which of the following is a valid way to implement a binary tree node in C++?
  1. struct Node { int data; Node* left; Node* right; };
  2. class Node { int data; Node left; Node right; };
  3. struct Node { int data; Node left; Node right; };
  4. class Node { public: int data; Node* left; Node* right; };

Questions & Step-by-step Solutions

1 item
Q
Q: Which of the following is a valid way to implement a binary tree node in C++?
Solution: The correct implementation uses pointers for left and right children, and the class should have public access for the members.
Steps: 0

Related Questions

Soulshift Feedback ×

On a scale of 0–10, how likely are you to recommend The Soulshift Academy?

Not likely Very likely