Data Structures and Algorithms with JavaScript cover

Data Structures and Algorithms with JavaScript

Rating 3.3
Word count
278K words
Chapters
14
Series
Turing Programming Series
ISBN
9787115363398

Tags

Summary

Once JavaScript moved beyond the browser and entered server-side programming through platforms such as Node.js, developers likewise needed classic data structures—linked lists, stacks, queues, graphs—as well as algorithms for sorting and searching. This book addresses exactly that question: in a JavaScript environment where arrays are objects, global variables are everywhere, and objects are built on prototype chains, how can traditional data structures and algorithms actually be implemented, and how can one make trade-offs among readability, code size, and execution efficiency? The book begins with JavaScript's programming environment and object model, first sorting through arrays' various accessor, mutator, and iterator methods to lay a foundation for the custom structures that follow. It then implements, in turn, lists, stacks, queues, linked lists (including doubly linked and circular lists), dictionaries, hashing (including separate chaining and linear probing for collision handling), sets, binary trees and binary search trees, and graphs for modeling network relationships, with graph algorithms including depth-first search, breadth-first search, shortest paths, and topological sorting. The final part turns to algorithms: first comparing basic sorts such as bubble, selection, and insertion sort with a timing platform, then introducing Shell sort, merge sort, and quicksort; the searching section covers sequential search, self-organizing data, and binary search; the last chapter discusses dynamic programming and greedy algorithms, using the Fibonacci sequence, longest common substring, knapsack problem, and coin-change problem as examples. Each chapter includes exercises, and the sample code can be run and modified directly.

Editor's review

这本书的价值在于“就地取材”:它不要求你先去学 C 或 Java,而是直接用 JavaScript 把数据结构与算法亲手实现一遍。每一章都从一个具体问题出发,比如用栈做数制转换、判断回文和演示递归,用队列模拟方块舞会分配舞伴,用列表做一个影碟租赁管理的小程序,读起来更像是在跟着作者一起写代码,而不是在读定义。 书中对 JavaScript 语言自身的“坑”也有坦率讨论:数组本质上是对象、原型式继承与类的差异、散列函数如何设计才不至于让所有键挤在同一个桶里。第 8 章的冲突处理、第 12 章用计时平台横向比较各种排序的实际耗时,都是很有实操味道的部分。 需要提醒的是,本书成书较早(英文原版 2014 年),示例以 ES5 写法为主,没有涉及 ES6 的 Map、Set、class 以及现代前端框架中的场景。把它当作理解原理的第一本书很合适,但读完仍需结合新的语言特性与工程实践再做迁移。

Who it's for

A good fit for

  • 已经会写 JavaScript、想补上计算机基础的前端开发者
  • 非计算机专业转行、没系统学过数据结构的学习者
  • 准备技术面试、需要手写实现常见结构的人
  • 想把课堂上的数据结构知识用 JavaScript 落地复现的学生

Not a good fit for

  • 完全零编程基础、还不熟悉函数与对象的初学者
  • 只想寻找 ES6、TypeScript 现代写法与工程实践的人
  • 需要系统学习算法复杂度理论、竞赛级算法的高阶读者

Reading tips

  1. 先通读第 1、2 章,确认自己熟悉书中的对象与数组写法,再按顺序往下推进。
  2. 每章的练习不要跳过,尤其是散列冲突和图算法两章,动手实现比看懂更重要。
  3. 读第 12、13 章时用计时平台亲自跑一遍各种排序与查找,感受数据规模对性能的影响。
  4. 遇到 ES5 写法可顺手用现代语法改写,但注意保留原型式实现与 class 实现的差异对比。

About the publisher

Posts & Telecom Press China · Founded in 1953

Posts & Telecom Press is known for its strengths in science and technology, computing, and information and communications titles, and has extended its publishing into photography, art, software learning, and inspirational growth, giving it a fairly diverse range. Its catalog includes computing and communications works such as Refactoring and Patterns (Revised Edition) and Huawei Switch Learning Guide (Second Edition), alongside bilingual collector's editions such as The Little Prince (Chinese-English-French illustrated collector's edition), The Great Gatsby, and Three Days to See. Beijing Ten Years: 1980-1990 and Ghost Blade: WLOP Personal Illustration Collection reflect its presence in photography and art. Its authors include Antoine de Saint-Exupéry, Helen Keller, Joshua Kerievsky, Wang Da, Zhang Zhaozeng, and WLOP.

Contents

  1. Chapter 1 JavaScript Programming Environment and Model
  2. Chapter 2 Arrays
  3. Chapter 3 Lists
  4. Chapter 4 Stacks
  5. Chapter 5 Queues
  6. Chapter 6 Linked Lists
  7. Chapter 7 Dictionaries
  8. Chapter 8 Hashing
  9. Chapter 9 Sets
  10. Chapter 10 Binary Trees and Binary Search Trees
  11. Chapter 11 Graphs and Graph Algorithms
  12. Chapter 12 Sorting Algorithms
  13. Chapter 13 Searching Algorithms
  14. Chapter 14 Advanced Algorithms

FAQ

这本书适合零基础学 JavaScript 的人吗?
不太适合。书中默认读者已能熟练使用函数、对象和数组,重点在数据结构与算法本身。若还没写过完整项目,建议先补语言基础,再回来看这本。
书中代码是 ES5 还是 ES6?
以 ES5 写法为主,用函数和原型模拟类与集合,未涉及 Map、Set、class 等新特性。学习原理没问题,但迁移到现代项目时需要自行改写。
和《学习JavaScript数据结构与算法》有什么区别?
两者主题相近。本书更侧重用原生 JavaScript 手写实现、语言特性讨论较多,出版较早;后者覆盖 ES6 之后的语法和更多算法类型,可以互为补充。
需要边读边敲代码吗?
强烈建议。书中示例篇幅不大,但很多细节只有在运行、调试后才会真正理解,尤其是散列冲突处理和图遍历部分。
读完能应付技术面试吗?
能建立扎实的基本功,常见结构的实现思路都有覆盖。但面试还涉及复杂度分析、题目变体与语言新特性,需要配合刷题与专项复习。

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

More by the same author

Top rated in the same category