liveBook · Manning

Logarithmic time complexity

As explained in Advanced Algorithms and Data Structures

Logarithmic time is a running-time bound that grows proportionally to the logarithm of the input size or another stated size parameter.

Logarithmic time complexity describes running time that grows with the logarithm of an input size or another stated parameter. For a balanced tree with n elements, a height of log(n) makes operations proportional to that height rather than to every element. section 2.9.1 section 9.3.3

Use logarithmic bounds to evaluate structures and operations under explicit assumptions:

  • A binary heap guarantees logarithmic worst-case running time for its common operations, with comparisons proportional to log₂(N). section 2.9.1
  • A D-way heap performs insertion in at most logD(n) swaps while restoring heap order. section 2.6.3
  • A dynamic array can make an otherwise logarithmic insertion bound amortized rather than worst-case because resizing occurs periodically. section 2.6.3
  • A balanced k-d tree supports worst-case logarithmic insertion and search when constructed from a known point set and left mostly unchanged. section 9.3.3

Priority queues and heaps

A task manager that consumes tasks one at a time does not need a totally sorted list. A priority queue preserves partial ordering, allowing common operations to require logarithmic time. In a ternary max-heap, inserting a task with priority 9.5 appends it and bubbles it upward until the heap properties are restored. section 2.3.1 section 2.6.3

O(log2(N)) = O(log3(N)) = O(log(N))

Compare logarithms with different bases through asymptotic notation: changing the base alters only a constant factor. section 2.9.1

How Advanced Algorithms and Data Structures covers it

How deep it goes
Explains height and comparison bounds, worst-case versus amortized guarantees, logarithm bases, and practical constant-factor trade-offs.
Examples
Uses task-priority insertion, binary-heap comparisons, cache performance tables, and balanced k-d-tree construction.
What it assumes
Assumes familiarity with data structures, heaps, trees, and Big-O notation while defining logarithmic bounds through height and comparisons.
What you can do after
Evaluate data structures by separating asymptotic growth, balance assumptions, worst-case guarantees, amortization, and implementation constants.
How it connects
Connects priority queues, binary heaps, d-way heaps, balanced trees, k-d trees, dynamic arrays, and Fibonacci heaps.

Also explained in

Compare how 4 books explain logarithmic time complexity →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Advanced Algorithms and Data Structures. The section links point to the parts of the book it draws on.