Introduction to Algorithms, 2020-1
Week 8: Exercises

1. Array Queue

Write a class ArrayQueue that implements a fixed-size queue using an array.

2. Dynamic Array Queue

Write a class DynamicArrayQueue that implements a dynamically resizing queue using an array.

3. Linked Queue

Write a class LinkedQueue that implements a queue using a linked list.

4. Maximum Value

Write a function max_in_tree(t) that returns the maximum value in a binary tree.

5. Complete Tree

Write a function completeTree(h) that builds a complete binary tree of height h. Every node's value should be that node's depth.

6. Mirror Image

Write a function mirror(t) that modifies a binary tree, flipping it from left to right so that it looks like a mirror image of the original tree.

7. Tree Compare

Write a function equal(t, u) that takes two Node objects representing the roots of two binary trees. The function should return True if the binary trees are identical, i.e. they have the same structure and the same values in corresponding nodes.

8. Ancestor Check

Write a function isAncestor(p, q) that takes pointers to two nodes p and q in a binary tree and returns true if p is an ancestor of q.

9. Counting Sundays

Solve Project Euler's problem 19.