Algorithms and data structures for JS/TS
  • Introduction
  • GETTING STARTED
    • TS
    • Node.js
    • ES Modules
    • Browsers
  • PUBLIC API
    • How to read
    • Linked lists
      • SinglyLinkedList
      • DoublyLinkedList
      • CircularlyLinkedList
    • Stacks and queues
      • LinkedStack
      • LinkedQueue
      • LinkedDeque
      • CircularQueue
      • CircularArrayBuffer
      • UnsortedPriorityQueue
      • SortedPriorityQueue
      • AdaptableHeapPriorityQueue
    • Maps
      • SortedMap
      • MaximaSet
      • AVLTreeMap
      • SplayTreeMap
      • RedBlackTreeMap
    • Trees
      • GeneralTree
      • LinkedBinaryTree
      • PreorderTreeTraversal
      • InorderTreeTraversal
      • PostorderTreeTraversal
      • EulerTourTreeTraversal
    • Searches
      • Binary search
      • Quick select
    • Text processing
      • Longest common subsequence
      • Boyer-Moore
      • Knuth-Morris-Pratt
    • Position
    • Locator
    • Comparators
  • CONTRIBUTION NOTES
    • How to contribute
    • Project structure
  • Changelog
Powered by GitBook
On this page
  • new PreorderTreeTraversal()
  • traverseBinary()
  • traverseGeneral()

Was this helpful?

  1. PUBLIC API
  2. Trees

PreorderTreeTraversal

Tree traversal algorithm that on each level of a tree visits root before traversing its subtrees.

new PreorderTreeTraversal()

/**
 * Creates an instance of PreorderTreeTraversal.
 *
 * @param callback Function to call on each visited element during traversal.
 */
constructor(protected callback: (
  element: T,
  meta: M,
  getPosition: () => ExtractPosition<TR>,
  tree: TR,
) => R)

traverseBinary()

/**
 * Traverses through a binary tree applying callback to each visited element.
 *
 * @param traversable Traversable representation of an element of the tree.
 */
traverseBinary(traversable: IBinaryTreeTraversable<T, TR>): R

traverseGeneral()

/**
 * Traverses through a general tree applying callback to each visited element.
 *
 * @param traversable Traversable representation of an element of the tree.
 */
traverseGeneral(traversable: IGeneralTreeTraversable<T, TR>): R
PreviousLinkedBinaryTreeNextInorderTreeTraversal

Last updated 5 years ago

Was this helpful?