liveBook · Manning

Data structure

As explained in Machine Learning Algorithms in Depth

A data structure is a scheme for storing and organizing data to support particular access and update operations.

A data structure stores and organizes data to support operations such as insertion, search, deletion, and update. Each structure makes different performance tradeoffs, so choosing one can simplify an algorithm and improve its runtime. section 4.1 section 1.5.1

Common structures and their implementation roles include:

  • Fixed-size arrays provide constant-time O(1) element access when the size is known. section 4.1.1
  • Dynamically resizable arrays, such as Python lists or C++ vectors, handle unknown or changing sizes. section 1.5.1 section 4.1.1
  • Maps and sets provide nonlinear organization; ordered variants use self-balanced binary search trees with O(n log n) insertion, search, and deletion. section 1.5.1
  • Hash tables or unordered maps offer expected O(1) access when collisions do not undermine the assumption. section 1.5.1
  • Stacks support O(1) push and pop operations in last-in, first-out order, while linked lists require linear-time search. section 4.1.1

Choosing an array operation

A linear scan searches an array in O(n). If the array is sorted, binary search reduces the search to O(log n). Naive selection and insertion sorts take O(n²), whereas merge sort, heap sort, and quicksort generally take O(n log n). section 4.1.1

How Machine Learning Algorithms in Depth covers it

How deep it goes
Defines structures, classifies them, and compares operation complexities, but does not derive their internal implementations in detail.
Examples
Uses arrays, dynamic arrays, maps, sets, hash tables, linked lists, stacks, binary search, and comparison-based sorting.
What you can do after
Apply it via from-scratch implementations by selecting structures according to required operations and runtime constraints.
How it connects
Connects data structures with algorithmic complexity, binary search, sorting algorithms, binary search trees, hash tables, and machine-learning implementation.

Also explained in

Compare how 10 books explain data structure →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning Algorithms in Depth. The section links point to the parts of the book it draws on.