0
0
DSA Typescriptprogramming~5 mins

Binary Tree Node Structure in DSA Typescript - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a binary tree node?
A binary tree node is a basic unit of a binary tree that contains data and references to at most two child nodes: left and right.
Click to reveal answer
beginner
What are the main parts of a binary tree node?
A binary tree node has three main parts:
  • Data: stores the value.
  • Left child: reference to the left subtree.
  • Right child: reference to the right subtree.
Click to reveal answer
beginner
TypeScript code snippet: Define a simple binary tree node class.
class TreeNode {
  value: number;
  left: TreeNode | null;
  right: TreeNode | null;

  constructor(value: number) {
    this.value = value;
    this.left = null;
    this.right = null;
  }
}
Click to reveal answer
beginner
Why do left and right child references sometimes hold null?
Because a node may not have a left or right child, so the reference is set to null to show the absence of a child node.
Click to reveal answer
beginner
How does a binary tree node relate to real-life family trees?
Like a person in a family tree has parents and children, a binary tree node has a value and can have up to two children nodes, representing branches.
Click to reveal answer
What does a binary tree node typically contain?
AOnly data
BOnly two child references
CData and three child references
DData and two child references
In TypeScript, what type should the left and right child references have in a binary tree node?
Anumber
BTreeNode | null
Cstring
Dboolean
If a node has no left child, what is the left reference set to?
A0
Bundefined
Cnull
Dempty string
How many children can a binary tree node have at most?
ATwo
BOne
CThree
DUnlimited
Which of these is NOT a part of a binary tree node?
AParent reference
BData value
CLeft child reference
DRight child reference
Describe the structure of a binary tree node and its components.
Think about what each node holds and how it connects to others.
You got /4 concepts.
    Explain why left and right child references can be null in a binary tree node.
    Consider what happens when a node has no children.
    You got /3 concepts.