3
$\begingroup$

Should one first understand its logic and see its implementation? Or should one try to implement it first oneself?

How should one learn so that one can quickly implement the algorithm or data structure quickly if needed? By practising implementing it repeatedly?

All in all, please throw light on the ways you find it efficient to learn algorithms.

$\endgroup$
3
  • 1
    $\begingroup$ Honest answer: the best way to learn to implement an algorithm or data structure quickly is to make sure you can quickly pull up the Wikipedia page on each! Or, if you want to get straight to the punch, google stack exchange for it. (be sure to read the alt text) $\endgroup$
    – Cort Ammon
    Jul 19, 2019 at 20:11
  • $\begingroup$ @CortAmmon Sir, what do you mean by alt text? You mean the standard books? $\endgroup$ Jul 20, 2019 at 6:26
  • $\begingroup$ Alt text is the text which appears when you hover over an image.. The linked XKCD has some relevant text. (It's called "alt text" because in HTML, you specify it with the "alt" attribute) $\endgroup$
    – Cort Ammon
    Jul 20, 2019 at 6:33

2 Answers 2

3
$\begingroup$

First, if you aren't taking a course, get a good book that has a lot of exercises. Use the exercises to guide your learning. Try to find a way to get some feedback on your attempts.

The way you learn just about anything deeply is to get a lot of reinforcement and feedback.

On the other hand, it is seldom necessary with today's languages and libraries to implement standard data structures. It is however, necessary to understand the fundamental of each and their relationship to various sorts of efficiencies when applied to various sorts of problems.

One way to get a deep understanding is to learn the technique of developing algorithms (not just data structures) from pre and post conditions.

My go-to book for doing that is by David Gries. It isn't cheap, but it can change the way you think about programs. I've mentioned it elsewhere here.

If you don't have other ways to get feedback, you might be able to form a group of like minded people who exchange work and comment on each other's attempts.

$\endgroup$
1
$\begingroup$

You need to understand the problem the data structure is trying to solve, how it is used (algorithms around it). You need to be able to see any alternatives and their advantages and disadvantages, specially when managing lots of data.

You need some guide, concrete problems to solve, somebody who tells you the relevant mathematics (yes, understanding why one alternative is better than another is mathematics). And try your hand at writing your own programs.

There are many texts available for free, like the series Open Data Structures (available in several programming languages, rather decent); Jeff Ericson's Algorithms text is very good, if somewhat heavy going; there are many sets of (more or less) polished lecture notes and textbook drafts floating around, like the one by Dasgupta et al. The classic book by Cormen et al "Introduction to algorithms" is encyclopaedic; Sedgewick and Wayne's "Algorithms" is very nice.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.