Set Object Recall the SET abstract data type, which must implement insert, element?, and empty?…

(8 points) Set Object Recall the SET abstract data type, which must implement insert, element?, and empty?. Recall that a binary-search tree is a binary tree which satisfies an extra condition: all elements appearing in the left subtree of a given node have values less than the value of the node; likewise, all elements appearing in the right subtree of a node have values that are larger than the value of the node. (You may assume there are no duplicates.) For this problem, you will define a SCHEME object which implements the SET ADT using a binary search tree to store the set elements. Use the tree conventions we adopted in class: a node of a tree is represented as a list containing the numeric value of the node and the two subtrees. We would like to use this set object for sets of many different types of elements, even objects! Therefore, we will need to generalize or set object to be able to store different types of objects in the binary-search tree. To support this, our insert and element? functions must be generalized to work with different data elements. Their implementations must be supplied with functions to determine if one data element is “less than” another and if one data element is “equal to” another. These functions will be passed to our object creator function make-set as the arguments indicated below. For our purposes, we will be storing the locations adjacent to a particular city, as well as the distance between the two locations, together to form set elements. We will place locations into the set based on their location name. But, we will need to be able to retrieve the distance to that location later. Therefore, it is not enough to be able to see if a location is in the set or not. We must be able to retrieve the full element to get the distance between the two locations. To support this need, we will add a “get” method to the standard set operations for this object as shown below. Finally, we include a “list-elements” method which provides a list of all elements in the set, sorted in the order determined by the before? function. Write an entire SCHEME object (make-set is-equal? before?) which implements the SET ADT using binary search trees. Your object should have the form: (see attachment

Attachments:

You don't know how to answer this question. We can help you find the right answer.

We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount! Use Discount Code "save15" for a 15% Discount!

Get Started

No need to wonder who can do my homework. You can always reach our team of professionals to do your homework at a low price.