liveBook · Manning

Preorder traversal

Preorder traversal is a tree traversal strategy that processes each node before recursively processing its child subtrees.

How 2 Manning books explain it

Functional Programming in JavaScript

A tree traversal strategy that visits a node before recursively visiting its children.

How it is used
Uses recursive preorder traversal to transform every value while preserving the tree’s structure.
How deep it goes
Defines the visit order, illustrates recursive descent, and implements it through Tree.map.
Examples
Uses a mathematician hierarchy represented with Node objects and mapped to a preorder sequence of full names.
What you can do after
Apply it via recursive JavaScript functions that process or transform each tree node in preorder.

Read how Functional Programming in JavaScript explains preorder traversal →

Clojure: The Essential Reference

A pre-order traversal processes a node before recursively processing its children.

How it is used
Guides transformations and inspections of arbitrarily nested Clojure data before processing descendant values.
How deep it goes
Defines depth-first ordering, function timing, inputs, outputs, and exceptions, but defers implementation internals.
Examples
Uses nested vectors, prewalk-demo output, and a pipeline branch whose descendants should not execute.
What you can do after
Apply it via clojure.walk/prewalk to inspect or transform each nested value before descending into children.

Read how Clojure: The Essential Reference explains preorder traversal →

Also covered in

Related concepts

Questions about preorder traversal

What is preorder traversal?

Preorder traversal is a tree traversal strategy that processes each node before recursively processing its child subtrees.

Which Manning books explain preorder traversal?

Functional Programming in JavaScript and Clojure: The Essential Reference.

What is the difference between preorder traversal and inorder traversal?

Preorder traversal is a tree traversal strategy that processes each node before recursively processing its child subtrees. Inorder traversal visits a node’s left subtree, then the node, and then its right subtree.

What is preorder traversal a kind of?

Preorder traversal is a kind of traversal. Traversal is the systematic process of visiting elements or nodes in a data structure according to a specified order or rule.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.