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 graphs


From the preceding description, we can speculate on the types of graphs. There are way too many to cover in this chapter or even in this book. However, let's take a look at some of the most important and popular graphs, which we will be exploring with examples in this chapter:

  • Simple graphs: A simple graph is an undirected, unweighted graph that contains no loops or multi-edge (that is multiple edges between the two nodes also known as parallel edges) nodes: 
  • Undirected graphs: This is a graph in which the edge definitions are interchangeable. For example, in the following image, the edge between nodes 1 and 2 can be represented as (1,2) or (2,1). The nodes are thus joined by a line without the arrows pointing towards any of the nodes:
  • Directed graphs: This is a graph in which the edges are given predefined direction based on a functional or logical condition. The edges are drawn with arrows, indicating the direction of the flow, for example, one user following another user...