For years JavaScript was only used in the web browser, this all changed with the emergence of platforms such as Node and Spidermonkey.
Now that JavaScript has begun its shift from only client side programming, programmers will find more need for tools provided by conventional languages such as C++ and Java.
Among these tools are the classic data structures such as linked lists, stacks, queues, and graphs, as well as classic algorithms for searching and sorting data.
Why is Data Structures and Algorithms important
From the title of Nicklaus Writh programming textbook "Algorithms + Data Structures = Programs (Prentice-Hall)", it show the essence of computer programming.
Any computer program that goes beyond the trival "Hello world!" will require some type of data structure to manage the type of data the program is written to manipulate, along with some other form of algorithms for translating the data from its input form to its output form.
Most programmers are only familiar with the Array data structure, Arrays are great for some problems, but for many complex problems, there aren't sophisticated enough.
Most Experienced programmers will admit that for many programming problems, once they come up with the appropraite data structure the algorithms needed are easier to design and implement.
An example of a data structure that leads to efficient algorithms is the binary search tree (BST). A binary search tree is designed so that it is easy to find the minimum and maximum values of a set of data, yielding an algorithm that is more efficient than the best search algorithms available. Programmers unfamiliar with BSTs will instead probably use a simpler data structure that ends up being less efficient.
Studying algorithms is important because there is always more than one algorithm that can solve a problem, and knowing the efficient ones is imprtant for a productive programmer.
Example
- There are at least six or seven ways to sort a list of data, but knowing that the Quicksort algorithm is more efficient than the selection sort algorithm will lead to a much more efficient sorting process.
- It’s fairly easy to implement a sequential or linear search algorithm for a list of data, but knowing that the binary sort algorithm can sometimes be twice as efficient as the se‐ quential search will lead to a better program.
Study of data structures and algorithms not only teaches which data structures and algorithms are most efficient, but you also learn how to decide which data structures and which algorithms are the most appropraite for the problem at hand.
There will always be trade-offs when writing a program, especially in Javascript, knowing the ins and outs of the various data structures and algorithms covered in this book will help you make the proper decisions for any programming problem you are trying to solve.
Credits
Image made with Canva
Reference from Data Structures And Algorithms With JavaScript by [Michael McMillan]
Top comments (0)