Hands-On Data Structures and Algorithms with JavaScript
eBook - ePub

Hands-On Data Structures and Algorithms with JavaScript

Kashyap Mukkamala

Compartir libro
  1. 332 páginas
  2. English
  3. ePUB (apto para móviles)
  4. Disponible en iOS y Android
eBook - ePub

Hands-On Data Structures and Algorithms with JavaScript

Kashyap Mukkamala

Detalles del libro
Vista previa del libro
Índice
Citas

Información del libro

Increase your productivity by implementing complex data structures and algorithms using JavaScriptAbout This Book• A step by step guide, which will provide you with a thorough discussion on the analysis and design of fundamental JavaScript data structures• Get a better understanding of advanced concepts such as space and time complexity to optimize your code• Focus more on solving the business problem and less on the technical challenges involvedWho This Book Is ForIf you are a JavaScript developer looking for practical examples to implement data structures and algorithms in your web applications, then this book is for you. Familiarity with data structures and algorithms will be helpful to get the most out of this book.What You Will Learn• Build custom Back buttons embedded within your application• Build part of a basic JavaScript syntax parser and evaluator for an online IDE• Build a custom activity user tracker for your application• Generate accurate recommendations for credit card approval using Decision Trees• Simplify complex problems using a graphs• Increase the performance of an application using micro-optimizationsIn DetailData 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.Style and approachStep-by-step topics will help you get started with solutions for implementing classic data structures and algorithms. Learn by doing with hands-on code snippets that give you practical experience of the subject.

Preguntas frecuentes

¿Cómo cancelo mi suscripción?
Simplemente, dirígete a la sección ajustes de la cuenta y haz clic en «Cancelar suscripción». Así de sencillo. Después de cancelar tu suscripción, esta permanecerá activa el tiempo restante que hayas pagado. Obtén más información aquí.
¿Cómo descargo los libros?
Por el momento, todos nuestros libros ePub adaptables a dispositivos móviles se pueden descargar a través de la aplicación. La mayor parte de nuestros PDF también se puede descargar y ya estamos trabajando para que el resto también sea descargable. Obtén más información aquí.
¿En qué se diferencian los planes de precios?
Ambos planes te permiten acceder por completo a la biblioteca y a todas las funciones de Perlego. Las únicas diferencias son el precio y el período de suscripción: con el plan anual ahorrarás en torno a un 30 % en comparación con 12 meses de un plan mensual.
¿Qué es Perlego?
Somos un servicio de suscripción de libros de texto en línea que te permite acceder a toda una biblioteca en línea por menos de lo que cuesta un libro al mes. Con más de un millón de libros sobre más de 1000 categorías, ¡tenemos todo lo que necesitas! Obtén más información aquí.
¿Perlego ofrece la función de texto a voz?
Busca el símbolo de lectura en voz alta en tu próximo libro para ver si puedes escucharlo. La herramienta de lectura en voz alta lee el texto en voz alta por ti, resaltando el texto a medida que se lee. Puedes pausarla, acelerarla y ralentizarla. Obtén más información aquí.
¿Es Hands-On Data Structures and Algorithms with JavaScript un PDF/ePUB en línea?
Sí, puedes acceder a Hands-On Data Structures and Algorithms with JavaScript de Kashyap Mukkamala en formato PDF o ePUB, así como a otros libros populares de Informatique y Développement Web. Tenemos más de un millón de libros disponibles en nuestro catálogo para que explores.

Información

Año
2018
ISBN
9781788397544
Edición
1
Categoría
Informatique

Exploring Types of Algorithms

An algorithm in the computer science world is a set of instructions that takes finite space and time to execute. It starts at an initial state of the application and then performs a set of instructions step by step to achieve the end result.
Algorithms come in all shape and sizes, and all of them will fit the bill when you compare it with the overly generic definition of what an algorithm is. The big question is to decide which algorithm to use in which case and to make modifications to enhance its functionality based on the application's needs.
As I have shown in the use cases in previous chapters, most of the times, the algorithms that exist out there do not directly apply to the problems at hand. This is when a thorough understanding of the algorithm comes in handy. That is exactly what we will be doing in this chapter; we will take a look at a series of algorithms and then try to understand them better with the help of some examples.
In this chapter, we will discuss the following algorithms with some examples:
  • Recursion
  • Dijkstra
  • Breadth First Search (BFS)
  • Dynamic Programming
  • Greedy Algorithm
  • Branch And Bound
Let's set up a bare-bones Node.js project before we start looking at the use cases.

Creating a Node.js application

For this chapter, we will use a very simple and light Node.js application, which will be holding our example scripts. The main goal here is to be able to run each of the use cases individually and not have an entire web (client or server) application for each of them. This helps us to have a uniform base project.
  1. The first step is to create your application's project folder. From the Terminal, run the following command:
mkdir <project-name>
  1. Then, to initialize a Node.js project, run the init command in the root folder of the project. This will prompt a series of questions to generate the package.json file. You can fill out the answers you wish or just click on return to accept default values for the prompts:
cd <project-name>
npm init
  1. Let's also install our beloved lodash to help us out with some of the trivial array and object manipulations and utilities:
npm install --save lodash

Use cases

Once your project is ready to go, we can now add the necessary scripts in the project's root and then run them independently.

Using recursion to serialize data

Recursion is a very popular programming paradigm in which a problem statement can be broken down into several smaller problems, which can be defined in terms of itself. Recursion is usually confused with divide and concur, in which the problem statement is broken into non-overlapping sub-problems which can be solved simultaneously.
In the following section, we will take a simple tree in which we have a root element followed by some child elements. We will be serializing this tree data, which can then be easily sent to the UI or persisted in the database.
Let's first create a folder called recursion within our project, which we created based on the preceding section. Then, we can create our serializer.js file within this folder, which will contain the class for serializing tree data.

Pseudocode

Let's formulate our algorithm in pseudo code before implementing the recursive serializer:
INITIALIZE response

FOR each node

extract child nodes

add current node info to serialized string

IF childNodes exist

repeat process for child nodes

ELSE

add ^...

Índice