How to Code: Complex Data Pt. 2

I left off describing what I learned in the first half of the HtC Complex Data course offered by UBC on edX. While I completed the course back in November, I never got around to summarizing my highlights. I learned a lot from this course. Not only did I learn a lot of helpful programming paradigms, but I also learned “how to learn” and how to push myself beyond perceived limits.

Shortly after finishing the Sudoku solver portion, I felt really overwhelmed by the increase in pacing. I could follow along with the videos, but I didn’t feel confident or comfortable in my own abilities. I unenrolled from the course and locked my old files. I decided to start fresh, go a bit more slowly, and really try to absorb as much as possible. Recompleting the first few weeks was much easier the first time around, then I started to struggle in Abstraction again. My number one issue was not keeping active track of data types, especially in the abstract fold functions. Coming up with a signature took me longer than solving the actual problem: 
;; (String Integer Y -> X) (X Y -> Y) Y Element -> X
 ;; the abstract fold function for element
I just kept doing the same task over and over, with more focus each time until I was able to rewire my brain.

After I felt a bit better (not great still), I reviewed the Sudoku solver and moved forward through the course. Week 11: Accumulators. I had experience with these a bit, thanks to JavaScript Allongé, where the author describes tail recursion. Tail recursion is just one small application for accumulators. We get three in this course. Context Preserving Accumulators: These help the function keep track of “where you are” in the program. You want to print every third item in a list? What about print the longest word in a list? You’ll need to preserve context. Tail Recursion: So you want to compute 100! (factorial), well it’ll take forever if your function isn’t tail recursive. Worklist Accumulators: These guys are a real doozy. They specifically work with mutually referential data. They keep track of which “nodes” you’ve already worked on, so you don’t look at them twice.

The beauty of all these accumulators, is that they’re written in local definitions, so the outer function doesn’t know or care.


Graphs are an even more abstract type of data. The example given is like a house, you have many rooms which connect to each other in different ways. How can you traverse all the rooms without cycling in an infinite loop? Well you’ll need a Worklist Accumulator to keep track. The representation on graphs in Racket is strange and can take some getting used to, and requires we graduate to Advanced Student Language.

insert meme here

Graphs are pretty cool, and are important for the … Final … Project!

The final project of this course is a two-part problem. The first problem requires you to solve a twitter-like problem with followers. I didn’t have too much trouble completing this one, especially after reviewing the Graphs module. Part two is a more difficult challenge: given a list of TAs with their availabilities, can you fill a shift schedule? This problem incorporated a lot of things learned in the course. I’m not going to give anything away, but I really enjoyed working on (or at least solving) the problem.

I’m proud of my work to complete these two courses. I’m starting now with the Java-based coursework, and working simultaneously on some JavaScript review via reading + algorithm scripting. Watch this space!

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.