1 design a data structure intset that can hold a set of integers hide the private im 5346534

1. Design a data structure IntSet that can hold a set of integers. Hide the private implementation: a binary search tree of integer objects.

Provide the following methods:

– A constructor to make an empty set

– void add(int x) to add x if it is not present

– void remove(int x) to remove x if it is present

– void print() to print all elements currently in the set

– boolean contains(int x) to test whether x is present

Test every method

2. Write a program that includes a method converting a two-dimensional array of ints to a two-dimensional array of boolean values. If the integer value is greater than or equal to 0, then the corresponding boolean vlaue is true; otherwise it is false. Add the necessary code to count how many statements are executed in the innermost loop. Run several simulations depending on the number of rows and columns in the argument integer array. What is the running time of the method as a function of the number of rows and columns of the parameter array?(You should assume that each row has the same number of columns.

3. Insert all words from a large file (such as the novel “War and Peace”, which is available on the internet) into a hash set and a tree set. Time the results. Which data structure is faster?

"Get 15% discount on your first 3 orders with us"
Use the following coupon

Order Now