Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using F# only, thank you! Part 3 Write the following binary search tree functions for a binary search tree of integers. (This will essentially be
Using F# only, thank you!
Part 3 Write the following binary search tree functions for a binary search tree of integers. (This will essentially be a tree set, i.e., a set data structure implemented using a tree.) Use the following type definition for a BST (copy this into your solution): // Tree definition for problem 3 type BST = Empty | TreeNode of int * BST * BST 1. insert value tree o Inserts the value into the tree and returns the resulting tree. The resulting tree does NOT need to be balanced. If the value already exists in the tree, return the tree without inserting the value. 2. contains value tree o Returns true if the value is in the tree or false if it is not. 3. count func tree o The parameter func is a Boolean function that takes a single parameter and returns true or false. The function tests the value of each node with func and returns the number of nodes that evaluate to true. 4. evenCount tree o Returns the number of nodes that contain even integers. O REQUIREMENT: This function may not call any other function by name, except for the count function. However, you may use lambda functions (which do not have a name). Part 3 Write the following binary search tree functions for a binary search tree of integers. (This will essentially be a tree set, i.e., a set data structure implemented using a tree.) Use the following type definition for a BST (copy this into your solution): // Tree definition for problem 3 type BST = Empty | TreeNode of int * BST * BST 1. insert value tree o Inserts the value into the tree and returns the resulting tree. The resulting tree does NOT need to be balanced. If the value already exists in the tree, return the tree without inserting the value. 2. contains value tree o Returns true if the value is in the tree or false if it is not. 3. count func tree o The parameter func is a Boolean function that takes a single parameter and returns true or false. The function tests the value of each node with func and returns the number of nodes that evaluate to true. 4. evenCount tree o Returns the number of nodes that contain even integers. O REQUIREMENT: This function may not call any other function by name, except for the count function. However, you may use lambda functions (which do not have a name)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started