ECE318 J Algorithms, Autumn 2025
Mon, Wed, 5:05-6:20 in Memorial 110

The Book

Useful information and things

Examinations:

Assignments

1    Due: Sat 30th August.
Binary tree database with deletion.
Remember the rules about what is not allowed. On top of that, no sstream.
Also remember about efficiency: no unnecessary wasted effort.
2 Due: Sat 13th September
Interaction with a hash table of all named U.S. places.
3 Due: Sat 4th October
User guided step-by-step exploration of the road map.
4 Due: Sun 9th November
2-3-trees with the red-black implementation trick.
5 Due: Sun 23rd November
Find the shortest route between two named places.

PC log in - use Putty or your own preferred SSH app.
OR mac users: start the terminal app, windows users: start powershell, then type the command
ssh username@rabbit.eng.miami.edu and type your password when prompted.
Windows users beware: you can't use ctrl-V in pico, but page up and page down will do the job.

Class History

Class 1 - Mon 18-8-2025    Quick introductions.
Review of Binary Trees.
Class 2 - Wed 20-8-2025 Perfect binary trees
Proving by induction that the recursive tree-printing function must work.
Deleting from a tree, nodes with two children are the only complicated case.
Class 3 - Mon 25-8-2025 The mystery function is a "hash function" - how hash functions should behave.
Today's sample code: Overflow demonstration,
Digital fingerprint for a whole file,
Peter Pan word count.
Class 4 - Wed 27-8-2025 Finding out the number of unique strings: split; sort; uniq -c
Handle hash collisions/clashes with table entries being linked lists.
Finding the distribution of linked list lengths (how many are of length X?).
The Poisson distribution shows wht a perfect hash function would do.
Comparing our hash to the ideal.
Day Off Mon 1st Sept.
Class 5 - Wed 3-9-2025 back to last week for a moment: open/closed addressing/hashing.
All officially named U.S. places, and the states.
intersections.txt,
connections.txt,
the file formats.
Class 6 - Mon 8-9-2025 A useful fact from topology: V + F - E - C = 0.
A map of nebraska, (also at night), and as a a text file.
and as a tree, (also at night), and as a a text file.
and as a lattice, (also at night), and as a a text file.
Graphs can be exlored as though trees if a closed set is used,
if the closed set is implemented as a vector recursion is unnecessary.
Introducing the "army of ants" method.
Class 7 - Wed 10-9-2025 Implementing the army of ants: vector of objects each containing:
      place * A, * B; int length, progress. A & B are places joined by a road
      loop: each iteration every object's progress += 1
      when progress == length note time of arrival at B, new objects for each exit.
Important observation - simulation only cares about arrivals, any progress < length can be skipped.
Min-heap: add new item with given prio, find and remove item with smallest prio.
Implementations: Array/vector/linkedlist all have O(N) ops, tree won't be balanced.
Array/vector impl of full tree ordered only so that prio(node) <= prio(left) and prio(right).
Working through the operations, worst O(NlogN); seeing second half of heapsort.
Class 8 - Mon 15-9-2025 HKN Resumé Workshop 22nd September, Engineering Career Day on 25th September.
Reminders about the importance of using pointers and references,
and some of the less common parts of class definitions,
and how to use the debugger.
Hashing a pointer, finding the maximum int, and some more bit-wise operations.
Tree-like shortest path in Nebraska.
Class 9 - Wed 17-9-2025 A decorative but very bad program.
Animated heap operations.
Animated shortest path with a heap,
Heap sort.
The Floyd-Warshall algorithm.
Class 10 - Mon 22-9-2025 Back to the two making-change problems, here's the blank table,
Also the number of different possible frat parties.
Memoisation - record all questions and answers so far computed to avoid repeated work,
Dynamic programming - complete the table in advance of the questions, need to find a pattern.
Usually find a recursive solution, if it involves repeated identical calls, try d.p.
How Floyd-Warshall fits the pattern.
Class 11 - Wed 24-9-2025 (Perhaps a wordier explanation of Floyd-Warshall will help).
"Can it be done" questions can often solve the more useful "How do you do it" questions.
Making change and knapsack are very similar. Connecting the recursive and D.P. solutions.
Table for Maximal Sum Contiguous Subsequence, try to think of how to solve it.
Class 12 - Mon 29-9-2025 Max sum contig. subs: brute force is cubic, easy improvement for quadratic,
easy dynamic programming linear time solution, little realisation makes it constant space.
Generating all combinations just in case there is no other way.
Generating all permutations using tons of memory: loop, recursion.
Sad attmept at a memory-efficient method.
Class 13 - Wed 1-10-2025 The good way to generate permutations with comments to re-explain how it works.
Easier to read without the explanation but harder to understand.
The not very good way: with a loop, with a neat recursion.
2-3-trees, how they work in general, and
seeing worst case time for 2-3 = best case time for binary tree, and time for search does not depend on configuration.
Class 14 - Mon 6-10-2025 Mostly questions about the test,
but some more about 2-3-tree insertions and node implementation.
Class 15 - Wed 8-10-2025 First mid-term exam. Topics:
        Hash functions and hash tables,
        Graphs: constructing, searching, traversing, shortest path,
        Priority queues, Heaps and Heap-sort,
        Dynamic programming,
        2-3-trees.
Some sample questions, some are for the second test.
Day off 13th
Class 16 - Wed 15-10-2025 Implementing 23nodes simple way wastes space and lots of cases to consider for insertion.
How to colour a pointer.
234 trees are a logical possibility and easy to understand now, but would have more cases for insertion.
Red-black trees are just an implementation trick for 23trees (really for 234trees).
Class 17 - Mon 20-10-2025 Things to be learned from the test.
Viewing the internal structure of numeric data.
A mystery file, and viewing it with od.
Class 18 - Wed 22-10-2025 Lots of things about fstreams.
Binary chop search on a file, not in memory - good for giant files.
The infamous file again, and finally seeing its contents.
Making .bmp image files: makebmp.cpp, makebmp.h and makebmpdemo.cpp.
Class 19 - Mon 27-10-2025 23-tree and red-black representation: insertion and deletion in detail.
Class 20 - Wed 29-10-2025 Python program for tree experiments - improved, works on latest python version now.
Class 21 - Mon 3-11-2025 A program with nested recursion to be eliminated: a start.
Here is the final result we reached right at the end.
Class 22 - Wed 5-11-2025 Seeing the interruptible recursion when comparing trees,
I think this is a better demonstration than you saw: see the short comment at the beginning.
Processing complex structured input: making our own programming language, a start at least.
Class 23 - Mon 10-11-2025 A more sophisticated and flexible way to make a lexical analyser.
The next job is parsing: building a tree that represents the structure of a program: a beginning.
This is roughly what we had at the end.
Class 24 - Wed 12-11-2025 Where we got today with the language implementation: print. while, and { }.
---------------------------------------------------------------
Here is the expanded tree experimenter python program,
(here is the older version in case any of my improvements go wrong),
This is how to install and run it,
and this is a 23-tree diagram that you can load to get started.
Class 25 - Mon 17-11-2025 Test review as necessary.
The complete parser.
Class 26 - Wed 19-11-2025 Second mid-term exam. Topics:
        2-3-trees,
        Working with binary files,
        Recursion elimination,
        Parsing complex input, interpreters.
The sample questions again, some are for the first test.
Class 27 - Mon 24-11-2025 Remote class or special reading assignment.
Break 25th to 30th
Class 28 - Mon 1-12-2025