41

A Guide to JavaScript Algorithms — Graph and Tree Traversal

 5 years ago
source link: https://www.tuicool.com/articles/hit/ieY36b3
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Algorithms and data structures have always been connected together. Without data structures, we would not have any objects by which we can implement our logic to solve the problem statement, and without algorithms, our objects cannot be consumed.

An algorithm is a function that takes in some data structure as input and manipulates it into some kind of output. The type of output that we get is based on the logic of the algorithm. To do all this, it is important that the developer clearly understands the problem statement and what is asked of him.

Understanding the logic behind the algorithm is fairly easy. things get more complicated when you are required to turn the logic into actual code.

In this post, we will take a look at some the common traversal algorithms in JavaScript. Some of these are very commonly asked in coding interviews, while others are not so common and will usually make you scratch your head in order to solve them.

Tip: Discover and share JS components in Bit’s component platform, and use components like Leko to build applications faster with your team. Give it a try.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK