Book description
Solidify your computer science fundamentals and choose the right data structures and algorithms for your programs – with new TypeScript focus and exercises. Purchase of the print or Kindle book includes a free eBook in PDF format.
Key Features
- Explore the most common data structures and algorithms you’ll encounter at work and in interviews
- Connect theory with real-world implementations in JavaScript and TypeScript
- Walk through solutions to LeetCode and HackerRank problems with the author
Book Description
Data structures and algorithms are foundational topics for software developers.
This easy-to-follow book from experienced developer and trainer Loiane Groner will help you to fill in the gaps in your knowledge – whether you’re a self-taught developer, you’re preparing for technical interviews, or you just want to write better code and improve your problem-solving skills.
This fourth edition covers essential data structures, algorithms, and their usage in the context of JavaScript. You’ll follow examples in both JavaScript and TypeScript, in line with the latest standards and best practices, learning how to do complexity analysis along the way. New to this edition are LeetCode and HackerRank exercises at the end of each chapter, which you'll be guided through solving. You’ll also find brand-new chapters on the tries data structure, and string and math algorithms.
By the end of the book, you will know how to develop programs using the best data structures and algorithms for the job.
What you will learn
- Declare, initialize, add, and remove items from arrays, stacks, and queues
- Learn how to think about and use recursion
- Create and use linked lists, doubly linked lists, and circular linked lists
- Store unique elements with hash tables, dictionaries, and sets
- Explore the use of binary trees, binary search trees, and tries
- Dive into the use of graphs and well-known graph algorithms
- Sort data structures using algorithms like bubble sort and quick sort
- Search elements in data structures using sequential sort and binary search
Who this book is for
This book is for JavaScript developers who want to understand or improve their knowledge of how data structures and classic algorithms work. This includes those preparing for technical interviews, and self-taught or bootcamp developers who may lack formal computer science grounding and want to fill in the gaps. A basic understanding of JavaScript syntax and general programming concepts is needed to get the most out of this book.
Table of contents
- Learning JavaScript Data Structures and Algorithms, Fourth Edition: Enhance your problem-solving skills in JavaScript and TypeScript
- 1 Introducing Data Structures and Algorithms in JavaScript
- 2 Big O notation
-
3 Arrays
- Why should we use arrays?
- Creating and initializing arrays
- Accessing elements and iterating an array
- Adding elements
- Removing elements
- Adding and removing elements from a specific position
- Iterator methods
- Searching an array
- Sorting elements
- Transforming an array
- References for other JavaScript array methods
- Two-dimensional arrays
- Multi-dimensional arrays
- The TypedArray class
- Arrays in TypeScript
- Creating a simple TODO list using arrays
- Exercises
- Summary
-
4 Stacks
- The stack data structure
-
Creating an array-based Stack class
- Pushing elements to the top of the stack
- Popping elements from the stack
- Peeking the element from the top of the stack
- Verifying whether the stack is empty and its size
- Clearing the elements of the stack
- Exporting the Stack data structure as a library class
- Using the Stack class
- Reviewing the efficiency of our Stack class
- Creating a JavaScript object-based Stack class
- Creating the Stack class using TypeScript
- Solving problems using stacks
- Exercises
- Summary
-
5 Queues and Deques
- The queue data structure
-
Creating the Queue class
- Enqueueing elements to end of the queue
- Dequeuing elements from beginning of the queue
- Peeking the element from the front of the queue
- Verifying if it is empty, the size and clearing the queue
- Exporting the Queue data structure as a library class
- Using the Queue class
- Reviewing the efficiency of our Queue class
- The deque data structure
- Creating the Deque class
- Creating the Queue and Deque classes in TypeScript
- Solving problems using queues and deques
- Exercises
- Summary
-
6 Linked Lists
- The linked list data structure
-
Creating the LinkedList class
- Appending elements to the end of the linked list
- Prepending a new element to the linked list
- Inserting a new element at a specific position
- Returning the position of an element
- Removing an element from a specific position
- Searching and removing an element from the linked list
- Checking if it is empty, clearing and getting the current size
- Transforming the linked list into a string
- Doubly linked lists
- Circular linked lists
- Creating a media player using a linked list
- Reviewing the efficiency of the linked lists
- Exercises
- Summary
- 7 Sets
-
8 Dictionaries and Hashes
- The dictionary data structure
-
Creating the Dictionary class
- Verifying whether a key exists in the dictionary
- Setting a key and value in the dictionary
- Removing and clearing all values from the dictionary
- Retrieving the size and checking if it is empty
- Retrieving a value from the dictionary
- Retrieving all the values and all the keys from the dictionary
- Iterating each value-pair of the dictionary with forEach
- Using the Dictionary class
- The JavaScript Map class
- The hash table data structure
-
Creating the HashTable class
- Creating the lose-lose hash function
- Putting a key and a value in the hash table
- Retrieving a value from the hash table
- Removing a value from the hash table
- Using the HashTable class
- Collisions between keys in a hash table
- Handling collisions with separate chaining technique
- Handling collisions with the linear probing technique
- Creating better hash functions
- The hash set data structure
- Maps and TypeScript
- Reviewing the efficiency of maps and hash maps
- Exercises
- Summary
Product information
- Title: Learning JavaScript Data Structures and Algorithms - Fourth Edition
- Author(s):
- Release date: December 2024
- Publisher(s): Packt Publishing
- ISBN: 9781836205395
You might also like
book
Learning JavaScript Design Patterns, 2nd Edition
Do you want to write beautiful, structured, and maintainable JavaScript by applying modern design patterns to …
book
Advanced Algorithms and Data Structures
As a software engineer, you’ll encounter countless programming challenges that initially seem confusing, difficult, or even …
book
Head First JavaScript Programming, 2nd Edition
What will you learn from this book? Now in its second edition, this brain-friendly guide is …
book
JavaScript: The Definitive Guide, 7th Edition
JavaScript is the programming language of the web and is used by more software developers today …