Skip to content

Commit 6f847d5

Browse files
committed
Commit IsPerfectTree() test predicate
1 parent 0a34cf7 commit 6f847d5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

binarytree.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,11 @@ func (n *Node[T]) IsCompleteTree() bool {
485485
return true
486486
}
487487

488+
// IsPerfectTree returns true, if the binary tree is full and complete
489+
func (n *Node[T]) IsPerfectTree() bool {
490+
return n.IsFullTree() && n.IsCompleteTree()
491+
}
492+
488493
// AddAttribute associates an attribute with the node, which will be
489494
// used when generating the Dot representation of the tree.
490495
func (n *Node[T]) AddAttribute(name, value string) {

0 commit comments

Comments
 (0)