Lecture overview -- Keyboard shortcut: 'u'  Previous page: Simultaneous traversal of two binary trees (1) -- Keyboard shortcut: 'p'  Next page: Trampolining [Section] -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 3 - Page 40 : 43
Programming Paradigms
Simulation of other Paradigms and Continuations
Simultaneous traversal of two binary trees (2)

Here we provide the details of the two simultaneous tree traversals

  • Two simulutaneous traversals scheduled by a controller:

    • Start the controller

    • Start pre-order traversal of the first tree - hand back pair of first node and traversal continuation

    • Start pre-order traversal of the second tree - hand back pair of first node and traversal continuation

    • Form pair of nodes, and recur

      • Continue each of the traversals - hand back control continuations

c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/tree-2-stuff/trees.scmThe basic tree functions - together with two concrete trees.

Notice the constructors make-tree and leaf; The accessors root, left-tree and right-tree; and the predicates inner-node?, leaf?, and empty-tree. Even if fully within the functional paradigm, the inspiration from OOP is clear: Hide the representatinon of the tree from the application/client.

c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/tree-2-stuff/traversals.scmThe tree traversal functions. This program is explained


c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/tree-2-stuff/controller.scmThe controller function. This program is explained


c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/tree-2-stuff/all.scmTree stuff, traversal, and controller - in one file.