Skip to content

Commit

Permalink
Merge pull request #1399 from TimWSpence/document-binomial-heap-rank
Browse files Browse the repository at this point in the history
Document the definition of the rank of a binomial tree
  • Loading branch information
SystemFw authored Nov 9, 2020
2 parents 49cd99e + 8b782de commit d01832d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class DispatcherSpec extends BaseSpec {
}

_ <- rec.use(_ => gate1.acquireN(2)).start
_ <- gate2.acquireN(2) // if both are not run in parallel, then this will hang
_ <- gate2.acquireN(2) // if both are not run in parallel, then this will hang
} yield ok
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ class BinomialHeapSpec extends Specification with ScalaCheck {
}

/**
* The rank of the top-level trees should be strictly monotonically increasing.
* The rank of the top-level trees should be strictly monotonically increasing,
* where the rank of a tree is defined as the height of the tree ie the
* number of nodes on the longest path from the root to a leaf.
* There is one binomial tree for each nonzero bit in the binary representation
* of the number of elements n
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import scala.annotation.tailrec

/**
* A binomial heap is a list of trees maintaining the following invariants:
* - The list is strictly monotonically increasing in the rank of the trees
* - The list is strictly monotonically increasing in the rank of the trees,
* where the rank of a tree is defined as the height of the tree ie the
* number of nodes on the longest path from the root to a leaf
* In fact, a binomial heap built from n elements has is a tree of rank i
* iff there is a 1 in the ith digit of the binary representation of n
* Consequently, the length of the list is <= 1 + log(n)
Expand Down

0 comments on commit d01832d

Please sign in to comment.