What is your strategy for learning data structures and algorithms?

What is your strategy for learning data structures and algorithms?
0

#1

This is a thread that I hope to get some people talking and sharing their methods on learning data structures and algorithms.

Some of us like myself, did not obtain a computer science degree. I actually have a business degree. I have been studying, learning, and building things with JavaScript for the past two years. With that said, I find learning algorithms difficult to grasp.

How I have been learning it and I don’t think it is the most effective way is to read the question, try to solve it, within 30 minutes, I give up, look at solution, then repeat the solution, reading the solution, until I memorize/understand it.

The memorizing and understanding part may sometimes become forgetful. I have spent countless hours but I still don’t feel comfortable or prepared for a technical interview.

I work off problems from FCC and codewars.

What are some effective ways you campers have found that works for you?


#2

It’s different for everybody. I myself never look at the solution. That means I end up with the problems I cannot solve. So I just go and choose another challenge and try to solve it. After a while I go back to the problem I failed to solve and I try again. Sometimes I succeed sometimes fail again. And sometimes even if I manage to solve a problem I end up with a spaghetti code which means there is still room for improvement. So basically I learn by doing it over and over again always by myself. I noticed that analyzing the solutions provided by someone else doesn’t do me any good. I cannot learn like this. I need to get there myself.


#3

@francisngo Check this Udacity course out.


#4

I am not a very good at solving algorithms, but what I do is try to understand what the problem is, then I try to replicate it on paper to find a pattern.

Not the most efficient way. But is a start. If you’re talking about solving algorithm like proving mathematics, that’s something I want to know. Lol


#5

As someone who has a CS degree, I definitely encourage more people to learn about both data structures and algorithms (commonly abbreviated to “DS&A”), but I also feel compelled to add that like everything else on FCC, neither are particularly “easy” subjects to properly learn. Someone who really wants to learn them should be prepared for at least a 3-month commitment (approximately the same as a school semester) to each subject to gain a proper understanding of them, and that’s assuming at least 10-20 hours per week (naturally, the more hours you can put in per week, the better).

And while MOOCs on each subject can be found on the Internet, some of them very good, the way that I personally learned them was through a combination of old-style printed textbooks, classroom teaching, and “lab” style feedback through a TA (Teaching Assistant). Of course, I know most people won’t have access to a classroom or a TA, so in lieu of that I’d have to highly recommend a good textbook instead of a MOOC, and I make that recomendation because: (1) good textbooks are far easier to come by than a good MOOC, and (2) Even the best MOOC won’t be able to go into sufficient depth on the material to be able to cover everything that should be learned, due to lack of time and/or resources.

To summarize the data structures that I’d consider essential to know:

  • Arrays (aka “Lists” in certain programming languages like Python and JavaScript)
  • Stacks & Queues
  • Linked Lists
  • Hash Tables
  • Trees & Heaps
  • Graphs

And to summarize the most important categories of algorithms and related subjects, particularly for those who intend on eventually applying to companies like Google, Microsoft, Facebook, or Amazon (although plenty of smaller companies in Seattle and Silicon Valley will also have similar expectations):

  • Asymptotic analysis
  • Recursion
  • Sorting (on arrays)
  • Sorting (on trees)
  • Searching (on arrays)
  • Searching (on trees)
  • Searching & Finding Shortest Paths (on graphs)
  • Dynamic programming **
  • Greedy algorithms **

** Maybe not totally necessary for the average programmer to learn, but still very good to know, and could very well come up in a technical interview at one of the large software companies

There are only two online-based resources that I can recommend for learning DS&A:

But since I’d rather recommend printed textbooks, these are the best ones I know of:

For those who would really, really rather take a MOOC over reading a textbook, the best MOOCs I know of are at Coursera, but as good as they are, they really don’t cover enough of the material to be comprehensive. But I would certainly say that they’re better than nothing, and they cover just enough that they can be called cursory. Note that they’re all intermediate-level courses, and they all use Java for implementations. I recommend taking these MOOCs in the order listed:


I also want to add at this point that I wouldn’t say a formal venture into any of the algorithm-related books or MOOCs that are listed above are actually necessary to do the algorithm challenges on FCC. I’d say instead that only the data structure-related books/MOOCs are necessary for that, because knowing how an array works and what you can do with it, is kinda important to knowing how to solve some of the challenges on FCC.


What is the most efficient practice to learn computer science and programming?
#6

I forgot to mention my resources. I am currently going through Front End Masters Data Structures and Algorithms. It is taught by one of the founders at Telegraph Academy. I really enjoyed her Fundamentals to Functional JavaScript, which I also highly recommend. Front End Masters is $39/month but it has really good materials you can’t find anywhere else.

I am also reading Learning JavaScript Data Structures And Algorithms - so far it is very easy to follow in comparison to some other algorithm books. I have a copy of Intro to Algorithms and Cracking the Code Interview but I think its too dense for me at the moment. I plan on returning to those books when I get a strong understanding.


#7

@astv99 thanks for taking the time to put this post together.

Do you need to know calculus to use Sedgewick & Wayne’s book?

I had the Princeton MOOCs on my list of courses to take but will try the UC San Diego first on your recommendation.

Thanks again! It really helps to have this sort of input on courses and books before tackling this.


#8

No problem, and no you don’t need to know calculus for Sedgewick & Wayne’s Algorithms book. It’s not as much of a math-oriented book as “CLRS” (Introduction to Algorithms) is, and doesn’t assume any advanced math knowledge. You should know high school-level algebra though, and the book does assume basic familiarity with Java as well (but if you know only JavaScript, most of the code shouldn’t be hard to figure out).

There’s a companion website for the book here as well: http://algs4.cs.princeton.edu/home/


#9

check out the beta.freecodecamp there is a section for DS I encourage you to share and help shape the new freecodecamp with DS&A and also technical interview questions! :fire::fire::fire:


#10

Thanks, I’ll check that out!


#11

You might find the following link useful for learning data structures:

Itsy Bitsy Data Structures: super simplified examples of many of the common data structures written in easy to read JavaScript.


#12

I personally follow this approach, it is a lot of hard work but I think pays off in the long run-

Step 1 - Programming Language

  • Js is all fun and great but choose a more powerful language like C++, java or python to implement algos.
  • Learn the basics concepts of the language from multiple online resources
  • use a book for supplement resource.
  • focus primarily on fundamentals, to understand what is going on under the hood.
  • solve the problems of [yourLanguage] track of HackerRank
  • Learn STL in the case of C++.

I personally prefer C++ due to Js like syntax and more fundamental approach that help to understand the basics.

Step 2 - Now let’s come on data structure

  • read from various online sources. Tutorialspoint is a good one for beginners and topcoder blogs are good too.
  • MyCodeSchool youtube channel is a great resource, One of the bestI have ever encountered.
  • solve data structure questions on data structure track of HackerRank.

Step 3 - For algorithms -

  • read from various online sources.
  • Read from Introduction to Data Structure and Algorithms by CLRS.
    (don’t go cover to cover, instead try to read specific topics as you come across them)
  • Solve Algortihm section of HackerRank and also try other resouces like topcoder,codechef,hackerearth(whatever works for you)

This is by far the best approach to becoming a quality programmer I came across.
I learned this hard way but I wish it help to save your precious time.


#13

Dan Abramov (who is one of the best software engineers in the world imo) and other big names in JS community recommend Grokking Algorithms for people without cs background.
source


#14

Just started reading this. Thanks for the tip.


#15

I think you really have to learn these things by doing. I was an Electrical Engineering major years ago (before switching to music) and still remember some of the coding classes I took.

I would recommend getting a book about algorithms and data structures and work through every example. Then apply the examples to your own invented problems and learn from them. Start with very simple problems and think your way through them. Write out the formulas, etc.

That being said, I don’t know if JS is the best language for learning data structures. Maybe I’m being harsh, but I was a little taken aback by how loose and free it is with data typing. But maybe I’m just being too pedantic (having initially learned in Pascal and C). But algorithms should be the same.

Even if you DO cheat and look at someone else’s solution, give it a week and then come back and try it again from scratch. The most important thing is that you understand the concept.


#16

interactive java tutorial for learning structures
java course


#17

I’m just at the start of my programming journey myself but, for me CS50 was a big help in understanding data structures, at least the basic ones. CS50 starts with C, a bare-bones programming language that doesn’t come with ready-made convenient abstractions like objects (that means no strings either!) or hash tables or dynamic arrays. You get to implement some of those things yourself! It gives you a greater appreciation for higher-level languages like JS, and gives you an idea on how things like JS objects might be implemented under the hood.

For algorithms, I usually give a problem a lot more than 30 minutes if I can’t solve it, but that’s partly because I’m in no great hurry. Others may be in a different situation. Occasionally I sit on a problem for a few days. There were a couple times I came up with the solution as I was in bed, falling asleep. If you’re stuck it can help to switch learning focus on something else for a bit, like doing some coding on your personal project, brushing up your CSS, or watching some youtube tutorials. Maybe try a different algorithm on codewars or one of those sites, then come back to the one you’re stuck on.