November 2017
Intermediate to advanced
262 pages
4h 34m
English
© Thomas Mailund 2017
Thomas Mailund, Functional Data Structures in R, https://doi.org/10.1007/978-1-4842-3144-9_6
Thomas Mailund1
(1)Aarhus N, Denmark
We saw earlier how we can represent collections of elements such that we can efficiently iterate through them and efficiently merge two such collections. In this chapter, we turn “bags” into “sets” by considering data structures that allow us to efficiently insert, delete, and check for membership of elements:
insert <- function(x, elm) UseMethod("insert")remove <- function(x, elm) UseMethod("remove")member <- function(x, elm) UseMethod("member")
We do this through so-called search trees—trees with the property that all elements in the left subtree of a node will have values ...
Read now
Unlock full access