Book Image

Hands-On Data Structures and Algorithms with JavaScript

By : Kashyap Mukkamala
Book Image

Hands-On Data Structures and Algorithms with JavaScript

By: Kashyap Mukkamala

Overview of this book

Data structures and algorithms are the fundamental building blocks of computer programming. They are critical to any problem, provide a complete solution, and act like reusable code. Using appropriate data structures and having a good understanding of algorithm analysis are key in JavaScript to solving crises and ensuring your application is less prone to errors. Do you want to build applications that are high-performing and fast? Are you looking for complete solutions to implement complex data structures and algorithms in a practical way? If either of these questions rings a bell, then this book is for you! You'll start by building stacks and understanding performance and memory implications. You will learn how to pick the right type of queue for the application. You will then use sets, maps, trees, and graphs to simplify complex applications. You will learn to implement different types of sorting algorithm before gradually calculating and analyzing space and time complexity. Finally, you'll increase the performance of your application using micro optimizations and memory management. By the end of the book you will have gained the skills and expertise necessary to create and employ various data structures in a way that is demanded by your project or use case.
Table of Contents (16 chapters)
Title Page
Copyright and Credits
PacktPub.com
Contributors
Preface
5
Simplify Complex Applications Using Graphs
Index

Types of sorting algorithms


We all know that there are different types of sorting algorithms, and most of us would have heard of the names of these different types of algorithms at various times in our programming careers. The big difference between sorting algorithms and data structures is that the former always has the same goal, irrespective of which type of algorithm is used. That makes it very easy and important for us to compare the different sorting algorithms on various fronts, which in most of the cases boils down to speed and memory usage. We need to make this determination before we pick a particular sorting algorithm based on the type of the data that we have at hand.

Keeping the above in mind, we will compare and contrast the following three different types of algorithms:

  • Insertionsort
  • Mergesort
  • Quicksort

Mergesort and Quicksort are the algorithms that v8 engine uses internally to sort the data; when the dataset size is too small (<10) the Mergesort is employed, else quicksort...