Skip to content
Snippets Groups Projects
Commit 41b041f4 authored by Brady James Garvin's avatar Brady James Garvin
Browse files

Recorded work from Monday.

parent 637bec5f
No related branches found
No related tags found
No related merge requests found
......@@ -133,8 +133,35 @@ How many moves does it take to reverse the string `123`?
## Recursive Depth-First Search (DFS)
* Worklist:
* Worklist: Call Stack
Activation Frames Backpointers Returned
----------------------------------- ------------ ------------------
edge = (⊥, a), incidence = …
edge = (⊥, a), incidence = (a, c) a → (⊥, a) [a, c, b, e, f, d]
edge = (a, c), incidence = (c, b) c → (a, c) [c, b, e, f, d]
edge = (c, b), incidence = (b, e) b → (c, b) [b, e, f, d]
edge = (b, a) ⊥
edge = (b, e), incidence = (e, f) e → (b, e) [e, f, d]
edge = (e, f), incidence = (f, d) f → (e, f) [f, d]
edge = (f, d) d → (f, d) [d]
↑ ↑↑↑↑↑↑
Don't need this Don't need this
For comparison, the iterative work has the same edges checked off as workitems, the same backpointers dictionary, and the same path:
Worklist Backpointers
-------- ------------
(⊥, a) ✓ a → (⊥, a)
(a, c) ✓ c → (a, c)
(c, e) b → (c, b)
(c, b) ✓ e → (b, e)
(b, e) ✓ f → (e, f)
(b, a) ✓ d → (f, d)
(e, d)
(e, f) ✓
(f, c)
(f, d) ✓
Reversed Path
----
d ← f ← e ← b ← c ← a
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment