Good ways of learning algorithms? Your advices?

So after I finished HTML and CSS courses here on FCC, I started JavaScript course, and it seemed so easy up till those algorithm challenges. I mean I could solve them (not most of them) by myself, and I would usually come up with some strange but my own solutions(were not functional). The thing is I really love JavaScript, and I am not lacking motivation. I have been learning how to code for a half year now(did each day a little bit of coding). But I wanted to know what are the good ways to understand how algorithms work, how to create your own algorithms, and how to think like a programmer. Right now, beside FCC I am constantly doing little projects, but the thing is that I cant do them by myself (JavaScript part). So guys, the question is should I rewrite already someone else’s code (for projects for instance), and then analyze the code, experiment with it etc? Is that good way of learning JS?

P.S. sorry for the edit, I realized my question was not that precise as it should be.


I don’t have time atm for a long answer. I will say that most people struggle with algorithms, and programming is hard. And algorithms are just one part of it. But the more you do, the better you get.

Cut yorself a break. This is hard.


This quote is referring to javascript " ‌If you’re learning on your own, it can take six to nine months to become proficient in JavaScript. Some of that time is spent learning how to think like a programmer — helpful for when you move on to learning other programming languages."

Three months is not a whole lot of time at all, and there is a lot to try to understand. When working on your own it is not uncommon to freeze, and feel like you’re lost. The lessons here are great, but they are no substitute for trying different things with what you learned. It is going to take practice and it is going to take a lot of time to be honest. Dont feel bad because you didnt get it right away. I doubt there is anyone here who can say they grasped all of this their first time around, its impossible. The best thing you can do is keep coding, keep practicing, and keep asking questions when you run into trouble. That’s why a forum like this, and many others exists. They want you to succeed, and are here to help if you need it. The ones who don’t ask question, and do not try to get help are the ones that are not being smart.

When working on a project, try and break it up into smaller parts. For example, what does a calculator need? Well, it needs buttons for the numbers and operators and a place to display the answer. Start there, do not worry about getting the buttons working right away and work a little bit at a time. Remember, google is also your best friend there is not a programmer out there who does not use it when they run into issues as well


So I can’t seem to find the original message, but if you’re all talking about the difficulties of javascript. I’m relatively new to it. I’ve been learning on my own and there have been at least 2 times where I took a bit of a break from it.

For what it’s worth I’ve found that in the past I had been resistant to reaching out for help from the community. Had I done this sooner I think I would have developed faster.

Other things worth doing (that I need to get better at for sure!)

  • asking thoughtful questions
  • maintaining a dialogue until you’ve got a better picture of the topic. Even if you don’t understand every little detail, you’ll at least have a bigger picture view and that’s progress.
  • Leave your ego at the door. There are other people with more experience and it’s kind of helpful to bow down to their expertise, although having said that definitely question it for yourself.
  • Have more than one source to provide help and support. Part of your journey will be to network and meet lovely devs. Both people your senior and your peer. The bigger your community the better.
  • remember some programmers and devs are a bit mean and weird, BUT they’re a minority. Keep asking questions and thinking about js and you’ll get better in no time!

Yeah js is kind of hard and I feel for ya, but as others have said you’ve got this. We’re all here routing for you!

EDIT Just realised I said routing instead of rooting, but it feels like a good programmer pun (in a dad kind of a joke way)


V good advice, I can whole heartedly recommend reading the pragmatic programmer for solid gold advice like this…

1 Like

Hi @ahmedev !

Welcome to the forum!

It is not a good idea to delete your original message because these replies are missing the context.

It is important to remember that people took the time to respond to your post.

Please keep that in mind for future posts.


1 Like

sorry for the edit, I realized my question was not that precise as it should be.

Yeah, that happens, but you should post in the thread or start a new post if it is a different question.

1 Like

I have a little more time now and it looks like your question is a little more focussed on algorithms.

An algorithm is just a procedure to solve a problem. Some are very easy. If you want to find a name in a phone book (if we can remember what those are), you could open it in the middle, then figure out if the name is in the first or second part. Then you open that part in half and keep repeating the process until you find your page. That is an algorithm we would do instinctually. In CS, it is known as a binary search.

And some algorithms are complicated. They take a lot of thinking and preparation. Don’t let them get you down. Don’t assume that people are breezing through these. I had worked as a semi-professional programmer decades ago and even had a class in algorithms. I still struggled with some of these.

Some people put too much emphasis on algorithms (and some people put too little). They are cool little tricks that come in handy sometimes. But as a professional developer for 3 years, I could easily count on one hand the number of “true” algorithms I needed. Of course, that will vary depending on the type of thing on which you are working.

Why learn algorithms? For one thing, they are excellent training for your “coder brain”. Also, sometimes they will save your life, with a complex problem, Also, they tend to show up on interviews and can impress hirers.

I sometimes wonder if FCC puts too much emphasis. Or more accurately, that they lump them all together, so you have this wall of algorithms to get through, that frustrates people. I wonder if it would be better to sprinkle them throughout the curriculum, a few at a time - but that might not fit with the FC format. But I might suggest top put a bookmark there and hop ahead - most of the projects are not going to be using algorithms anywhere near what you learn in the algorithm section.

How do you get better at algorithms? I think you get better by doing them. I think each algorithm is its own way of thinking and to some extent they have to be learned individually. But at a certain point as you learn more and more, they start to get easier.

So, do algorithms. If you solve one, go online and see how others have solved them - that is a great teacher. Don’t do it for an algorithm you are attempting, but there are also a lot of great youtube videos of people walking you through solutions. The book Cracking the Coding Interview is great - it’s written in Java, but you’ll get the idea. There are a lot of web sites with algo challenges - I like leetcode. One cool thing is that after you solve it you can see other people’s solutions.

In short, cut yourself some slack, this is hard from everyone, and realize that you don’t have to become an expert in algorithms right now. Think of it as a long term project. Everyone struggles with these, but the more you do, the easier they get - but it will improve frustratingly slowly,


Thank you so much Kevin ! Your advices are really helpful and motivating :slight_smile:

Hello @ahmedev,

I wanted to know what are the good ways to understand how algorithms work, how to create your own algorithms, and how to think like a programmer.

understand how algorithms work

I think a better approach is study a specific algorithm using books, papers, blog posts, courses, etc. . A better approach if you definition of an algorithm is “a finite sequence of well-defined instructions”[0]. You always have the option of try to recreate the “classic algorithms” from scratch … but I think that is a really difficult task.

how to create your own algorithms

I think that there is a misconception that make learn how to program really difficult:
the idea that the code the programmer writes is an algorithm.

The code is not an algorithm, the code is an implementation of an algorithm.
Identify the code with the algorithm is problematic, an example: most people doesn’t have problems understanding a recursive algorithm, but they have problems implementing the algorithm in JS. Why? because JS uses a call stack and nested (function) calls, things that the algorithm doesn’t have.
You can create an algorithm without write a single line of code. Most of the time is better to use pen and paper and not use a programming language (because programming languages are difficult to use).

how to think like a programmer

I think that most of the time programmers use a heuristic[1] approach to problem solving.

An example of heuristics problem solving using the exercise “DNA Pairing”[2]:
Problem Explanation, (exercise “DNA Pairing”)[3]:

There are four potential characters that exist in DNA: “A”, “T”, “G”, and “C”.
“A” and “T” are always paired together, and “G” and “C” are always paired together.

Heuristic/rule of thumb:

Forms of data descriptions[4]:

a. enumerations
- collection with a finite number of element
- lists every single piece of data that belongs to it

b. intervals
- collections of elements that satisfy a specific property
- collection with infinitely many elements
- specifies a range of data

c. itemizations
- specifies ranges in one clause of its definition
- and specific pieces of data in another clause

If we read the problem explanation we can try to solve the exercise using an enumeration:

4.3 Enumerations[5]

The main idea of an enumeration is:

  • it defines a collection of data as a finite number of pieces of data

Each item explicitly:

  • spells out which piece of data belongs to the class of data that we are defining. A data representation in which every possibility is listed

  • When a function’s input is a class of data whose description spells out its elements on a case-by-case basis:

  • The function should distinguish just those cases

  • and compute the result on a per-case basis

  • To distinguish in code requires:

    • conditional functions: functions that choose different ways of computing results depending on the value of some argument.

Example of a conditional function and enumeration:

; TrafficLight -> TrafficLight
; yields the next state given current state s

(define (traffic-light-next s)
   [(string=? "red"    s) "green"]
   [(string=? "green"  s) "yellow"]
   [(string=? "yellow" s) "red"]))

In JS you can use if...else[6] or switch[7] statements.

Why is a rule of thumb:

Because “The function should distinguish just those cases and compute the result on a per-case basis” is not an algorithm, is just a “recipe”/recomendation that you can use (the exercise can be solved in multiple ways).

Cheers and happy coding :slight_smile:

[0] Algorithm - Wikipedia

[1] Heuristic - Wikipedia

A heuristic … (from Ancient Greek εὑρίσκω (heurískō) ‘I find, discover’), or heuristic technique, is any approach to problem solving or self-discovery that employs a practical method that is not guaranteed to be optimal, perfect, or rational, but is nevertheless sufficient for reaching an immediate, short-term goal or approximation…

… Examples that employ heuristics include using trial and error, a rule of thumb or an educated guess.


[3] freeCodeCamp Challenge Guide: DNA Pairing

[4] I Fixed-Size Data

[5] I Fixed-Size Data

[6] if...else - JavaScript | MDN

[7] switch - JavaScript | MDN

1 Like

Thank you so much @Diego_Perez ! This Heuristic approach seems somehow less stressful to work with, since it doesn’t indicates immediate “perfect” answer to a specific problem. I really like it! Thank you once again. :slight_smile:

1 Like

I think for algorithm you need to think little logical start from basic questions in algorithm

i recommend kevin smith’s approach. i have a 3 inch book on algorithms and data structures. and many of the models and problems are very intensely mathematical. involving probabilities , stuff such as erlang pi functions, poisson, gaussian pdf’s , and many systems that you will never see in real life coding. but it gets you into the mindset of problem solving which is a necessity in programming. that was the biggest takeaway i got in the algorithms section so i recommend struggling through it. especiually if u never went to a university and took a class that involves quantitative analysis and problem solving .

Before learning algorithms in Computer Science, I had a good understanding of programming concepts such as variables, functions, classes and especially, Object-Oriented Programming (OOP) concepts. These concepts act as a foundation to understand more advanced concepts in computer science.

I think you just learn basic of Algorithms and have a deep knowledge how to use it in many situations.
Then go into a project, the important thing is how to solve a problem in fast way than learn all whats they told you. It is waste time.

I am a person who didn’t know how to construct functional algorithms in JS(been in the same situation as you are), and I realized that in the first few challenges of the basic JS section of the JS curriculum. And I was determined to learn it anyhow.
Then I went to Codecademy completed the JS course. And by the time I had finished the course on Codecademy; I had already developed the ability to construct algorithms. Then came back to FCC and was able to solve the scripting challenges/projects(wasn’t easy, though; as you need to think a lot when you try to solve it on your own without going to the hint section or googling the solution). Then learned DOM manipulation, which improved my ability to write algorithms (more than I could imagine)and helped me translate my ideas into functional algorithms.
Eventually, I fell in love with JavaScript. All glory to God for His guidance and understanding that He gave me throughout a very difficult phase of learning programming. :pray:
On a side note: You can do it just like every other human has. You can accomplish anything, just believe and be consistent with what you’re doing. All the best. :blush:

Learning raw DOM manipulation isn’t really needed - nobody does that professionally. But tackling something more complex will definitely help you build up the skills to think about bigger problems.

People learn ‘algorithmic thinking’ lots of different ways. The important thing is to find the way that works for you.

1 Like

Maybe that’s true. But just like you don’t use raw JS too much when using library and frameworks but you still learn JS, so that you can know of the underlying concepts.
I think having a strong foundation and understanding of the basic concepts can help you understand the complex ones that are built on top of that.
And i agree with you that we learn differently.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.