Binary Trees in Haskell
Tree data structure, and tree depth function taken from futurelearn
A tree can be empty, or it can be a node with a left and right subtree as its children
Traversals
An array is returned containing the traversal order
- In order
- Pre order
- Post order
Functions
Insert tree toInsert
InserttoInsert
as a leaf into the binary search treetree
createBST xs
Create a binary search tree whose keys are the values of arrayxs
createBST' tree xs
Create a binary search tree given an existing treetree
and insert the values of arrayxs
as its keyrotateLeft tree
rotate the treetree
to the left along the root noderotateRight tree
rotate the treetree
to the right along the root nodeminimumBST tree
return the minimum element in the treetree
maximumBST tree
return the maximum element in the treetree
Specs
- GHC 8.6.5