Define a class HashBag, which does not add multiple instances of the same datum to itself, but instead maintains a counter for each unique datum.
A bag is an unordered collection that can contain duplicate items. Otherwise, it behaves like a set. Define a class HashBag, which does not add multiple instances of the same datum to itself, but instead maintains a counter for each unique datum. This class extends the class HashSet and overrides the definitions of the methods […]
Develop a data model and user interface that allow the programmer to create graphs and use them to test graph algorithms.
1 Although our graph ADT is easy to use, building a complex graph for real applications can be complicated and tedious. In this case study, we develop a data model and user interface that allow the programmer to create graphs and use them to test graph algorithms. 2 A graph is an appropriate ADT to […]
Design and implement an application that allows the user to find the shortest path between two cities.
Design and implement an application that allows the user to find the shortest path between two cities. One input to the program should be a file representing a weighted graph, as described in the case study. The vertices are labeled with the names of cities and the weight on an edge is the number of […]
Modify the Many Queens program so that it displays all the solutions.
The recursive algorithm for the Many Queens problem can be modified to list not just one, but also all the possible solutions. When each solution is found, it is added to a list. The function then removes the queen from the last column to force a failure and a search for another solution. Here is […]
Complete and test the parsing program developed in the case study.
1 Complete and test the parsing program developed in the case study. 2 Add the operator ^ for exponentiation to the language of expressions in the case study. This operation is right associative, which means that consecutive instances of it are evaluated from right to left. Thus, the expression 3 ^ 3 ^ 2 is […]