Algorithm Analysis (CSC 301 2015F) : EBoards
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] [FAQ] [IRC] [Teaching & Learning]
Current: [Outline] [EBoard] [Reading] [Lab] [Assignment]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Readings]
Reference: [Algorist]
Related Courses: [Walker (2014F)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker]
Overview
add, remove, and find.SetOfStrings Implementations
SetOfStrings ADT provides
add(set,val), remove(set,val), contains(set,val)union(set,set), subtract(set,set)SetofStrings.
(You need not write code; just describe memory arrangement and
related issues.)How do I change the size of my vector?
I'd recommend that you build your hash tables as four element vectors (size, capacity, alpha, vector of lists). That way, when you expand them, you're just setting one element of the enclosing vector.
Do values have to move when we expand the hash table?
Almost certainly.
What will our code look like?
(vector-set hash-table 3 (expand-vector (vector-ref hash-table 3))
(vector-set hash-table 0 (vector-length (vector-ref hash-table 3))
(define expand-vector ...)
Do we have to write code to implement SetOfStrings?
No. Your goal is to consider various options for implementing them and assess their relative efficacy.
Small group task: Describe trees formally.
)
is in child
This somewhat mathematical representation serves multiple purposes
For ordered trees, we add an i (in the natural numbers) to the child relationship, form
, for "c is the ith child of p"
Small group task: Think about what each of these terms means. Be prepared with a definition. (Your definitions can be formal or informal.)
Binary trees are ordered trees in which no parent has more than two children (only valid indices are 0 and 1) without the requirement that having child 1 requires you to have child 0.
When talking about traversal, we focus on when we process a value in the tree. We may visit the values in a slightly different order.
Binary trees in which all the values in the left subtree are less than (or equal to) the node, which is less than (or equal to0 all the values in the right subtree
In general, searcing in a binary search tree is O(height)
A binary tree with N nodes can have height O(logn), so this can be fast.
Can we balance our trees? Let's go for "almost balanced" - the height of subtrees shall not differ by more than 1.
See white board. (They are probably in my outline, too.)