Skip to Content
Advanced Algorithms and Data Structures
book

Advanced Algorithms and Data Structures

by Marcello La Rocca
July 2021
Intermediate to advanced
768 pages
25h 23m
English
Manning Publications
Content preview from Advanced Algorithms and Data Structures

3 Treaps: Using randomization to balance binary search trees

This chapter covers

  • Solving the problem of indexing data according to multiple criteria
  • Understanding the treap data structure
  • Keeping a binary search tree balanced
  • Using treaps to implement balanced binary search trees (BST)
  • Working with Randomized Treaps (RT)
  • Comparing plain BSTs and RTs

In chapter 2 we saw how it is possible to store elements and retrieve them based on their priorities by using heaps, and how we can improve over binary heaps by using a larger branching factor.

Priority queues are especially useful when we need to consume elements in a certain order from a dynamically changing list (such as the list of tasks to run on a CPU), so that at any time we can get the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

A Common-Sense Guide to Data Structures and Algorithms

A Common-Sense Guide to Data Structures and Algorithms

Jay Wengrow
Data Structures & Algorithms in Python

Data Structures & Algorithms in Python

John Canning, Alan Broder, Robert Lafore

Publisher Resources

ISBN: 9781617295485Supplemental ContentPublisher SupportOtherPublisher WebsiteSupplemental ContentErrata PagePurchase Link