> For the complete documentation index, see [llms.txt](https://algorithm.prettylog.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://algorithm.prettylog.com/algorithm-problems/algoexpert/medium/bst-traversal.md).

# BST Traversal

![](/files/SrRKpObNhpYBsJ04GfYA)

*

```jsx
function inOrderTraverse(tree, arr) {
  if (tree === null){
    return;
  }

  inOrderTraverse(tree.left, arr);
  arr.push(tree.value);
  inOrderTraverse(tree.right, arr);
  
  return arr;
}

function preOrderTraverse(tree, arr) {
  if (tree === null){
    return;
  }

  arr.push(tree.value);
  preOrderTraverse(tree.left, arr);
  preOrderTraverse(tree.right, arr);
  
  return arr;
}

function postOrderTraverse(tree, arr) {
  if (tree === null){
    return;
  }

  postOrderTraverse(tree.left, arr);
  postOrderTraverse(tree.right, arr);
  arr.push(tree.value);
  
  return arr;
}

// Do not edit the lines below.
exports.inOrderTraverse = inOrderTraverse;
exports.preOrderTraverse = preOrderTraverse;
exports.postOrderTraverse = postOrderTraverse;
```
