Algorithms and OOD (CSC 207 2014F) : EBoards
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] - [Learning Outcomes] [FAQ] [Teaching & Learning] [Grading] [Rubric] - [Calendar]
Current: [Assignment] [EBoard] [Lab] [Outline] [Reading]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Readings]
Reference: [Student-Curated Resources] [Java 8 API] [Java 8 Tutorials] [Code Conventions]
Related Courses: [CSC 152 2006S (Rebelsky)] [CSC 207 2014S (Rebelsky)] [CSC 207 2014F (Walker)] [CSC 207 2011S (Weinman)]
Misc: [Submit Questions] - [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] - [Issue Tracker (Course)] [Issue Tracker (Textbook)]
Topics to discuss
Tree Traversal
Implementation
remaining
, that holds the linear structurepieces
, that holds the left/right/value tripletInitialization
if "the traversal is left-to-right, preorder, depth-first"
{
remaining = new Stack();
pieces = { "right", "left", "value" };
}
else if "the traversal is left-to-right, preorder, breadth-first"
{
remaining = new Queue();
pieces = { "value", "left", "right" };
}
Alternately: We can use dictionaries to store this information.
If we just think about traversal and not iteration, the algorithm is straightforward
while (!remaining.isEmpty())
{
next = remaining.get();
if ("next is a node")
pull out the pieces and put them into remaining
else
process next // e.g. print
} // while
We will benefit from a procedure that takes the list of pieces
we need, a node, and the linear structure, and uses the list
to pull the information and shove it in the linear structure.
Provided as unpack
.
next
and hasNext
.Final!
Outline Heap Sort