Safe HaskellSafe

BTree

Description

A Module for Binary Trees.

Synopsis

Documentation

data BTree a Source #

A binary tree is either Empty or consists of a Note with at most two direct subtrees.

Constructors

Empty 
Node a (BTree a) (BTree a) 

Instances

Eq a => Eq (BTree a) # 

Methods

(==) :: BTree a -> BTree a -> Bool #

(/=) :: BTree a -> BTree a -> Bool #

Read a => Read (BTree a) # 
Show a => Show (BTree a) # 

Methods

showsPrec :: Int -> BTree a -> ShowS #

show :: BTree a -> String #

showList :: [BTree a] -> ShowS #

size :: BTree a -> Integer Source #

The size of a binary tree is the number of Nodes it contains.

height :: BTree a -> Integer Source #

The height of a binary tree is the length of the longest path from the its root to one of its leafs.

fromList :: [a] -> BTree a Source #

Transforming a list into a binary tree of the same structure.

make :: [a] -> BTree a Source #

Building a balanced binary tree from a list.

searchTree :: Ord a => [a] -> BTree a Source #

Building a binary search tree from a list.

flatten :: BTree a -> [a] Source #

Turning a binary tree into a list by inorder traversal of nodes.