Answered step by step
Verified Expert Solution
Link Copied!

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!image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions