Spent probably two minutes just restating the definition back to myself out loud which felt awkward.
Use level-order traversal (BFS) with a queue, tracking whether a null child has been encountered. Once a null is seen, all subsequent nodes must be null; if any non-null node appears after a null, the tree is not complete. Alternatively, assign indices to nodes and check that the maximum index equals the number of nodes minus one.
Pro tip: Clarify the definition of a complete binary tree upfront and discuss edge cases like an empty tree or a single node. Mention that the BFS approach runs in O(n) time and O(n) space, and that the index-based method can be done iteratively with a stack to avoid recursion depth issues.
Confirm that a complete binary tree has all levels filled except possibly the last, which is filled from left to right. Discuss edge cases: empty tree (true), single node (true), and trees with missing children.
Decide between BFS with a flag or index assignment. BFS is straightforward: traverse level by level, and once a null child is seen, no further non-null nodes should appear.
Use a queue to perform level-order traversal. For each node, enqueue its left and right children (including nulls). Maintain a boolean flag that becomes true when a null is encountered; if a non-null node is seen after the flag is set, return false.
State that time complexity is O(n) and space complexity is O(n) in the worst case. Walk through examples: a perfect tree, a tree with a missing left child, and a tree with a node after a null.
Mention the index-based method: assign index i to a node, left child gets 2i+1, right child gets 2i+2. Track the maximum index and compare with the total number of nodes. This also runs in O(n) time and O(n) space.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.