Hashing and Group Activities

For me, it’s a constant challenge, when planning teaching activities, to figure out how best to help students learn various topics within the constraints of the available resources. A while ago, I was pleased to find what seems to be a good teaching method for hash tables, which is the subject of this post.

More of hash tables later. First, some background:

Usually for a module, we have a large lecture room booked for two hours, followed by multiple small-group rooms booked for one hour. Typically, the larger room is used for a lecture, containing an initial presentation of the module concepts. Whilst there can be a certain amount of participation and interactivity in a lecture setting, it’s the smaller-group sessions (practical classes) that usually offers a better opportunity to engage students and make sure that they are learning the material, because as it’s a smaller group, there’s more opportunity for tutors to help give students individual feedback on how they are doing. Obviously, we want students to attend the small-group sessions because people generally learn better if they are doing some kind of activity where they are active participants, rather than sitting back and watching someone else do it. The idea is that if you have to do it yourself, you have to understand it, because you need the understanding to do the task.

So far, so good, but there’s an issue we have to bear in mind when planning what’s going to happen in the practical classes: like other universities up and down the country, levels of attendance aren’t what they should (or could) be, so how do we best encourage students to attend their practical classes? We asked our students some years ago what affected their attendance: it turns out one of the factors that affects whether they go to practical classes is how much value they see themselves as getting out of that class.

And herein lies the tricky bit.

If we set worksheets that the students have to work through individually, with the idea that the tutor can help when they get stuck, despite the help available, several of them tend to take the line “Oh I can work through this at home”, and I can understand why they’d prefer the comfort of their own desk with all its comforts to one of the University’s computer labs.

On the other hand, if we set worksheets more oriented towards a group activity, that does tend to be more attractive for them: not only is the class an experience they can’t get at home (which contributes to their perception of the practical’s value), but some students like keeping quiet in a group and letting others do the active work, and then they’re not getting as much out of the class as if they were actively participating.

In a nutshell, it’s quite a challenge to both get them through the door and give them the best chance of learning the material once they’re there in the practical class.

And that brings me on to hash tables.

Hash tables are a method of storing data: you have a table with slots in it for data, and understanding hashing is all about understanding which slot to put data into. To get students to understand hashing, as a teacher I feel that I really want each individual student insert data into a hash table table.

I used to have a practical worksheet which involved students being given data to insert into various hash tables, on their own, and I wasn’t happy with this worksheet. One reason was that the time taken to insert the data was quite substantial, and many students didn’t get to try all the different hashing schemes covered on the worksheet. Another reason was that it was the kind of exercise that students might feel that they could do it on their own rather than attend practicals.

Here’s what I did that I felt worked really well:

I had prepared in advance several little cards like this, each with a different number on, and randomly distributed them to the students. We were looking at three different hashing schemes, so each student got three cards, each with a different number on (the number being the data to be inserted into the hash table), one card for each hashing scheme.

Stage 1: students on their own went to the computers (or their pocket calculators) and calculated what the hash values of the three numbers they had, filling the values in on the space on the cards. These “hash values” are useful information, to be used in the second stage.

Stage 2: for each of the three hashing schemes, we started with an empty hash table. This hash table was displayed on an OHP screen, but could have been displayed on a whiteboard or on the floor, just so long as everyone could see it. Then, one by one, the students took it in turns to enter their own individual piece of data for that table. I supervised, to make sure that they were putting the data in the correct place and understanding why they did so.

This seemed to work really well. Every student had to place a piece of data, so every student had to participate and understand why the data gets placed where it does, including the shy students (who need not go first but can do one after their friend has done one). Because students only calculated hash values for one piece of data each, at the beginning 5 minutes of the session, the students didn’t spend so long calculating hash values but instead spent much more time on watching how all the various numbers got inserted into the hash table. That meant we had enough time for all of the students to look at all the hashing schemes, not like before where only the speedy students covered them all.

Of course, it doesn’t have to be numbers for the data. Strings work pretty well where you can base hash values on things like the length of the string, or how many vowels the string has got.

Next time, I think I’ll bring a prop, a kind of large mat, to be placed on the floor where everyone can see it, with the outline of the slots of a hash table, so that students can physically place the numbers in the slots on the hash table mat.

Presenting Research

Yesterday I had a meeting with a fellow researcher, Clare Martin. Some of the research that we work on concerns multirelations (a model for expressing two kinds of non-determinism), and we were pondering how best to write up our latest results on multirelations, so that whoever reads it can see why it’s useful.

Why do we want to motivate the research? A more immediate answer is that if we don’t show the reader why the research is useful, then a reviewer of the paper won’t be inclined to recommend it for publication, but it’s also the case that if we want to write good well-written papers (yes! we do!) then part of writing a good paper is making the reader care about the research presented there.

Sometimes research can be easy to provide motivation for: for example if I have a new algorithm to solve a specific problem then when I write up the research in a paper, it’s pretty easy to show the reader of the paper what the purpose of the work is and thus get the reader to care that that research exists. If the problem is interesting and grabs the reader’s attention, then so much the better. Even if the problem isn’t interesting enough that it could be used for nerd sniping, it still provides a rationale for the paper’s existence.

However, multirelations live in the dry theoretical regions of computer science, and for the more theoretical results, it’s not easy to show the relevance of the mathematics of multirelations to solving actual computational problems because the connection is fairly indirect. So it’s difficult to show why the results are useful and motivate the reader of a paper about multirelations to care about the results.

Coincidentally I’ve just been reading a very useful book “Made to Stick” by Chip and Dan Heath which is about making information more memorable and there’s a lot of lessons in there that can be applied to writing papers.

Made to stick

Some of the information in the book addresses presenting ideas and making people care about them. One example they used concerned a duo piano team who were asked to write a mission statement, and they came up with something like “… Duo Piano exists to protect and preserve the music of duo piano.”. Whilst this was true, it didn’t make the other teams see why they should care about duo piano. But when the other teams started asking the duo piano team questions about why duo piano was important (the questions they asked eventually teased out the information that it combined the breadth of orchestral music with the intimacy of chamber music) then the others started to care.

So the way we’re going to approach writing the paper is something similar. I’ve just had a teaching-heavy semester and haven’t been able to work much on multirelations, so my mind is a bit fresher on the topic. I’m going to play devil’s advocate and ask ourselves lots of questions like

  • “Why do we need this bit about lifting functors in the paper?”
  • “How does this result about set-valued functions tie in to the later section?”
  • “What is this extension an extension of?”
  • “Why do boolean algebras matter in this setting?”

Hopefully, providing the answers to these questions will lead us to be able to articulate what it is that these theoretical results about multirelations contribute, and if we can articulate that ourselves, then we have a fighting chance of being able to convey that to our readers.

Blog Purpose

I know I haven’t posted much yet, I’ve been kept very busy by the constant round of deadlines that is the teaching schedule for the semester, with a fair new teaching material I had to prepare. But I do have several ideas for posts, with many thoughts that I’d like to put down in writing.

One of these thoughts concerns the topic of this blog. I hope that it will be about not so much the content of my teaching and research, but more on an analytical level, looking at what works (and doesn’t), why (or why not?) it works. I hope it’ll be a record of hints and tips to my future self, as well as possibly containing the odd bit of information interesting to others involved in computing research or academia.

I think this is what the pedagogical types would call “reflective practice”. :-)

Algorithms and a Moustache

Me looking silly

I run a course on Data Structures and Algorithms.

The first week of the course introduces students to the ideas of complexity and big O notation, and I wasn’t happy with the existing worksheets used in the practical classes. The questions needed to be better at getting across the idea of time complexity to undergraduates with a wide range of abilities.

I had a vague idea of what I wanted to do: I wanted some algorithms that the students could follow by physically acting them out in the practical session, and then afterwards we could discuss the complexity of the algorithms. I hoped that the “learning by doing” approach would help them to understand and remember the complexity ideas better (i.e. what educational researchers would call experiential learning).

I looked around the web for inspiration, and I came across this web page which presents some course notes for “CS367 Introduction to Data Structures” at the University of Wisconsin (instructor Sally Peterson, web notes hosted by Rebecca Hasti). It had this algorithm suggestion:

“Consider the following three algorithms for determining whether anyone in the room has the same birthday as you.

Algorithm 1: You say your birthday, and ask whether anyone in the room has the same birthday. If anyone does have the same birthday, they answer yes.

Algorithm 2: You tell the first person your birthday, and ask if they have the same birthday; if they say no, you tell the second person your birthday and ask whether they have the same birthday; etc, for each person in the room.

Algorithm 3: You only ask questions of person 1, who only asks questions of person 2, who only asks questions of person 3, etc. You tell person 1 your birthday, and ask if they have the same
birthday; if they say no, you ask them to find out about person 2. Person 1 asks person 2 and tells you the answer. If it is no, you ask person 1 to find out about person 3. Person 1 asks person 2 to find out about person 3, etc.”

This was a nice idea for an algorithm to act out, but it didn’t quite suit my purposes. I wanted to discuss the complexities for all three versions. Once the students have identified their tutor’s birthday from the first run of the algorithm, it seems a bit pointless to run another version of the algorithm to find out something you already know. In addition, this would require people to reveal their birthdays, a fairly personal piece of information often used for identity checks (or students would have temporarily have to pretend to have a different birthday). Rather than do birthdays, I had a different idea: the photo identification algorithm:

The purpose of this exercise is to look at the time complexities of three different algorithms to solve the same problem. The problem is to identify whether any student in the room knows who is in the photo, and if so, who is it?

Algorithm 1
Tutor asks first student, then asks second student, then asks third student etc.
Algorithm 2
Tutor asks first student. If the identity is not known, the tutor passes the photo to the first student and asks them to ask the second student. The information is passed back to the tutor. If not known, the tutor asks the first student to ask the second student to ask the third student… etc.
Algorithm 3
The tutor holds up a photo. All students in the room immediately either speak the name of the person in the photo (if identified) or shake their head otherwise.

These algorithms don’t require personal information and you can run them as many times as you have photos printed out to show them. I chose photos of celebrities that were very well-known in some circles, but not others, as I didn’t want the algorithms to terminate too soon. I chose Benazir Bhutto (twice Prime Minister of Pakistan):

Benazir Bhutto

and Stephen Colbert (US comedian ubiquitous in the US but mostly unknown in the UK):

Stephen Colbert

For the third photo, I had the idea of creating a comedy moment, where the practical tutor shows the photo to the students and it is a photo of the practical tutor in some kind of comic style, like in comedy glasses and moustache. I thought this might make it fun and more memorable for the students. So I sent round an email to the department:

Does anyone have a comedy glasses/noses/moustache kind of thing that they could bring in and I could borrow for a few hours?

(Don’t ask. The short answer is that it’s for a practical class to help explain Big O notation to [...] students.)

In the end I went round the practical tutors who were going to be giving the practical sessions, taking photos of them in a silly jimmy hat (scottish tartan beret with red pom pom and ginger fake wig). All of them looked suitably amusing, except mine! Mine looked too sensible, not nearly comedic enough:

Me in a silly hat

So I donned a fake moustache instead. No I am not posting a picture of that.

Things I learnt as a result:

  • The students (and tutors) did indeed seem to find the practical class more memorable, and fun too.
  • In a practical room, you can hear the peals of laughter from the neighbouring lab.
  • The student grapevine circulates rumours of comedy tutors extremely quickly. Attendance the following week was up!
  • When you send round an email asking for comedy glasses and moustache, all of a sudden you have an instant conversation topic with people you meet in the corridors, who will all want to know what on earth is going on in your practical classes, and can they watch?
  • I have a lot of colleagues who are good sports and not afraid to make fools of themselves for the cause of explaining algorithms concepts.
  • If one of your colleagues looks unexpectedly hilarious in such a getup then he or she may not be too happy if you fall about laughing for half an hour…
  • … but it will make your day!
  • My departmental colleagues are very kind and if you laugh for half an hour straight they will offer to fetch you some oxygen.
  • Everyone will suddenly develop a keen interest in being emailed photos of your colleagues wearing silly hats and/or moustaches.
  • Giving your colleagues your solemn assurance that you are NOT sending electronic copies of the photos to anyone is very important.

Introduction

I’ve set up this blog as a place where I can write about various aspects of my professional activity as a computing lecturer at a UK university. My main activities are teaching and research. I chose the name of this blog because the phrase “towards understanding” seems to encapsulate the common thread running through both my teaching and my research.

In research, I am always trying to find things out. Sometimes I am educating myself by striving to understand what other people have already found out; sometimes I am trying to discover things that no-one has ever found out before, and that is tremendously exciting. I hope when I communicate about my research I can do so in such a way that brings other people towards understanding.

In teaching, my focus is on trying to bring the student(s) towards greater understanding. The topic is the key thing; pondering what vehicles can best convey that understanding I find very interesting. And in attempting to further students’ understanding, I learn a lot as well.