Skip to content

Instantly share code, notes, and snippets.

@haase1020
Created December 6, 2021 10:32
Show Gist options
  • Save haase1020/ff57c52e901702e8a142ff32390f4432 to your computer and use it in GitHub Desktop.
Save haase1020/ff57c52e901702e8a142ff32390f4432 to your computer and use it in GitHub Desktop.
binary tree inorder traversal
// https://leetcode.com/problems/binary-tree-inorder-traversal/
const dft = (root, result) => {
if (!root) return;
dft(root.left, result);
result.push(root.val);
dft(root.right, result);
return result;
};
const inorderTraversal = (root) => {
const result = [];
dft(root, result); // recursive call made to other function
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment