Question: Assignment Help with racket language following the template ;; Constructs a tree from two trees and a value (define (tree left value right) 'todo) ;;
Assignment Help with racket language following the template
;; Constructs a tree from two trees and a value (define (tree left value right) 'todo) ;; Constructs a tree with a single node (define (tree-leaf value) 'todo)
;; Accessors (define (tree-left self) 'todo) (define (tree-value self) 'todo) (define (tree-right self) 'todo)
;; Copies the source and updates one of the fields (define (tree-set-value self value) 'todo) (define (tree-set-left self left) 'todo) (define (tree-set-right self right) 'todo)
;; Function that inserts a value in a BST (define (bst-insert self value) 'todo)

3. (7 points) Your goal is to implement a Binary Search Tree (BST) in Racket, as we learned in Lecture 3 (user data-structures). To this end, you will need to implement the constructor and selectors of each field, as well as the operation to insert a node in the BST. Please use the function names declared in the homework assignment template, as otherwise you will get 0 points in this assignment. The following code is a Java implementation of binary tree taken from the Wikipedia page on BST" class Tree { Tree left, right; float value; Tree (Tree left, float value, Tree right) { this.left = left; this.value = value; this.right = right; Tree setLeft (Tree left) { return new Tree (left, this.value, this.right); } Tree setValue(float value) { return new Tree (this.left, value, this.right); } Tree setRight (Tree right) { return new Tree(this. left, this.value, right); } static Tree insert(Tree node, float value) { if (node == null) { return new Tree (null, value, null); if (value == node.value) { return node.setValue(value); if (value
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
