1. 程式人生 > >Ask HN: How to best teach algorithms and data structures?

Ask HN: How to best teach algorithms and data structures?

Here's what I try to do:

1. Start with the intuition. (The big concepts i.e. for BigO trying to figure out the best, worst and average number of steps it takes to run a function as the input size grows). Make sure everyone gets the big picture, core concepts, and intuition before moving on.

2. Use as many graphics and visual aids as possible.

3. Let people work step-wise up to getting the full solution i.e. get them to just sort one element in a list. Then change the algorithm to sort two elements, etc..

4. Start very easy, I mean very easy (like sorting a list of 1,2 and then 3 elements), then let people slowly step up in difficulty until they implement full algorithms and data structures. Also make sure everyone can at least describe, draw, and sketch out solutions that may not necessarily be precise but cover the "gist" of what the algorithm is about.

5. Use Stories: If you can tell them stories with algorithms / data structures its even better. (For stacks I like using the example of the professor grading essays on his desk, or a person browsing the internet, for binary search I like looking for a book in the library, etc)

6. Use Lots of Examples: When explaining the mathematics be sure to have exercises/examples which let them play a lot with the parameters (RStudio or jupyter is nice for this), make sure each expression is clearly broken down and clarified. Also having positive examples (for how it should work) and negative examples (for common mistakes and when things are incorrect) can help improve understanding too.

hope some of these tips help. Good luck!