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