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 two links: one to the left child and one to the right child.
Click to reveal answer
beginner
Show the Go struct definition for a binary tree node.
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}
Click to reveal answer
intermediate
Why do binary tree nodes use pointers for children in Go?
Pointers allow nodes to link to other nodes dynamically and represent absence of a child with nil, saving memory and enabling tree structure.
Click to reveal answer
beginner
What does it mean if a binary tree node's Left or Right pointer is nil?
It means that the node does not have a left or right child respectively, indicating the end of that branch.
Click to reveal answer
beginner
How can you create a new binary tree node with value 5 in Go?
node := &TreeNode{Val: 5, Left: nil, Right: nil}
Click to reveal answer
What fields does a binary tree node typically have?
✗ Incorrect
A binary tree node stores a value and pointers to its left and right children.
In Go, what type should the Left and Right fields of a binary tree node be?
✗ Incorrect
Left and Right are pointers to other TreeNode structs, so their type is *TreeNode.
What does a nil pointer in a binary tree node's child field represent?
✗ Incorrect
A nil pointer means the node does not have a child in that direction.
How do you declare a binary tree node struct in Go?
✗ Incorrect
Option A shows the correct Go syntax for a binary tree node struct.
Which of these is NOT true about binary tree nodes?
✗ Incorrect
Binary tree nodes do not always have a parent pointer; it is optional.
Describe the structure of a binary tree node in Go and explain the purpose of each field.
Think about how nodes connect to form a tree.
You got /4 concepts.
Explain why pointers are used for child nodes in a binary tree node struct in Go.
Consider how trees grow and shrink.
You got /4 concepts.