Hacker News new | ask | show | jobs
by songzme 3267 days ago
From my experience working with people learning programming, many students have a fear of linked list and trees. They buy coding books and practice problem sets about linked list and trees.

Little do they know (a few years down the road), most of them will get work experience and complain that nobody uses linked list and trees. Heck, when a problem presents itself where linked list might be a great solution, they probably won't think to use it.

I think that this system of constantly bringing up linked lists, stacks, and queues for data structure is broken. A better format for teaching data structures would be to train the student's ability to come up with the right data structure for the problem they are solving. The ability to come up with solutions specific to a problem is the real skill and this skill will empower engineers come up with stacks, queues, linked lists when they need it.

Here's how I would teach data structures:

Ask student: 1. Let's say you want to build an elevator system. What classes would you need, and what properties / methods would each of them have?

2. You need to build a restaurant game. What classes would you need, and what properties / methods would each of them have?

+ a list of many other questions

Follow up to each of these questions would be for students to implement their data structures with provided assets to see their implementation come to life. Throw in firebase (realtime db) so students can interact with each other's games helps them see flaws in their implementation / data structure design. Its a great data structure + application development practice.

2 comments

I think that your method for teaching data structures wouldn't work in practice. I don't think many students can arrive at such data structures on their own. How many students can you expect to come up with the implementation for a dictionary who have only ever heard of and used lists and arrays?

The analogy in math would be to expect students to derive the pythagorean theorem from scratch. Not only would this be a difficult task for most newbie mathies, you would also have a significantly smaller proportion of students arriving at the formula than by conventional means. It would be much more effective and efficient for a larger demographic of learners to show them the formula, explain how it's derived, and have them then apply it over multiple examples.

I see where you are coming from, pythagorean theorem is a bit of a stretch. Here's one:

First you teach someone how to carve wood and basic physic. Then you give them different hypotheticals and have them build things that solve these problems. This helps them really understand the problem and how to solve different problems using their skillset. With this, they will be able to build what they need (boats, house, tables, chairs, etc.). Conversely, if you teach a student how to build a boat over and over again, I doubt they would be able to build a house.

Fundamentals: Classes, arrays, objects

Everything else is derived. Linked lists, trees, are not fundamentals.

Again, this is just my observations and I wanted to share.

I see where you're coming from there. It's basically a corollary of a recent topic on HN, which was that you in practice rarely encounter a problem that requires you to do anything algorithmically interesting. But then again, if you do, how would you have any idea of how to work on a graph if you couldn't even do a linked list?
I believe that students should work on the ability to come up with data structures that solves different sets of real life problems, and get good at it. If they can do that, then they should be able to easily implement a linked list or graph when they need to.