Skip to main content
Back to Samples
MediumCompleted

Binary Tree Inorder Traversal

Tree traversal with recursive and iterative approaches

B+
Overall Grade
Performance Overview
Time Taken
25 minutes
Complexity Accuracy
Good
Edge Cases Discussed
Yes
Alternative Solutions
Partial
Your Solution
function inorderTraversal(root) {
    const result = [];
    
    function traverse(node) {
        if (!node) return;
        
        traverse(node.left);
        result.push(node.val);
        traverse(node.right);
    }
    
    traverse(root);
    return result;
}
Correct recursive approach
Proper base case handling
Could discuss iterative solution
AI Feedback
Strengths
  • • Solid understanding of tree traversal concepts
  • • Clean recursive implementation
  • • Good explanation of the algorithm flow
  • • Handled null node edge cases correctly
Areas for Improvement
  • • Could have discussed iterative approach with stack
  • • Space complexity analysis could be more detailed
  • • Consider Morris traversal for O(1) space
Next Steps

Practice implementing iterative tree traversals using explicit stacks. This will help you understand the relationship between recursive and iterative approaches.

Detailed Performance Metrics
Problem Understanding85%
Code Quality82%
Communication78%
Actions