#' Get the size of a tree
#'
#' Returns the number of nodes in a binary search tree
#'
#' @param tree A \code{bst}
#' @export
size <- function(tree) UseMethod("size")
#' @export
size.bst <- function(tree) size(tree$root)
size.bstnode <- function(node) {
node$n
}
size.NULL <- function(nada) 0L
#' Is the tree empty?
#'
#' @param tree A \code{bst}
#'
#' @export
is_empty <- function(tree) {
size(tree) == 0L
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.