How to work with algorithms?

I solved many javascript cirriculum problems with modification of some algorithms found in internet. Where are the algorithms for a hierarchikal navigation from a website for example?
And where can I learn how and when to use known algorithms to solve problems? And which algorithms are used in the javascript intermediate course.? How can I work with algorithms to solve problems fast and efficient, instead breaking every problem in smallest pieces, and creating algorithms by myself?

That’s how you work with algorithms, really. Eventually you start recognizing patterns in the code and data and reach for an existing algorithm you already know as a building block of your custom algorithm. As you learn more, you pick up more.

Where are the algorithms for a hierarchikal navigation from a website for example?

There isn’t one – not until you get more specific. Algorithms are specific instructions for doing specific things. An algorithm has an input, a procedure, and creates an output. We can infer that the graph of links of the website is your input. If your desired output is “the content of every linked page”, then you’re looking at a graph coverage algorithm of some sort. If it’s “shortest path of clicks from one page to the next”, you want a shortest path algorithm. If it’s “most relevant page for this topic”, you’re looking at some kind of scoring algorithm, probably made up of several other algorithms.

Algorithms are all over the place: for example, every time you look up a property on an object, you’re using a string hashing algorithm behind the scenes. But one doesn’t really say they’re using a hash algorithm unless they’re writing their own hash table implementation. Except maybe for the cash register problem which pretty much demands a Greedy Match algorithm, the JS intermediate course doesn’t use any algorithms that are front-and-center to the solution. It’s all just program logic, and algorithms are just way of many ways to look at it.

1 Like