100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Summary

Summary CS/COE 1501 Assignment 3 Solution

Rating
-
Sold
-
Pages
1
Uploaded on
11-03-2025
Written in
2024/2025

To explore an advanced application of priority queues in order to gain a deeper understanding of the data structure. High-level description: You will be writing a basic application to help a user select a car to buy. You will write a menu-based user interface driver program (to be run in the terminal, no GUI), but most of the logic will be in implementing a priority queue-based data structure. You should write a PQ-based data structure that stores objects according to the relative priorities of two of their attributes, making it efficient to retrieve objects with the minimum value of either attribute. Your data structure should further be indexable to allow for efficient updates of entered items. You will want users to be able to enter details about cars that they are considering buying. The user should then be able to efficiently retrieve the car with the lowest mileage or lowest price. These retrievals should be possible on the set of all entered cars or on the set of all cars of a specific make and model (e.g., "lowest price Ford Fiesta", "lowest mileage Cadillac Escalade"). Specifications: 1. First you must create a class to store data about cars to buy Specifically, this class must contain the following information: * A unique VIN number (17 character string of numbers and capital letters (but no I (i), O (o), or Q (q) to avoid confusion with numerals 1 and 0) * The car's make (e.g., Ford, Toyota, Honda) * The car's model (e.g., Fiesta, Camry, Civic) * The price to purchase (in dollars) * The mileage of the car * The color of the car 1. You must write a terminal menu-based driver program (again, no GUI). Specifically, your driver must present the user with the following options: 1. Add a car * This will (one at a time) prompt the user for all of the above-listed attributes of a car to keep track of 1. Update a car * This option will prompt the user for the VIN number of a car to update, and then ask the user if they would like to update 1) the price of the car, 2) the mileage of the car, or 3) the color of the car 1. Remove a specific car from consideration * This option will prompt the user for the VIN number of a car to remove from the data structure (e.g., if it is no longer for sale) * Note that this mean you will need to support removal of cars other than the minimum (price or mileage) car 1. Retrieve the lowest price car 1. Retrieve the lowest mileage car 1. Retrieve the lowest price car by make and model * This option will prompt the user to enter (one at a time) a make and model and then return the car with the minimum price for that make and model 1. Retrieve the lowest mileage car by make and model * This option will prompt the user to enter (one at a time) a make and model and then return the car with the minimum mileage for that make and model 1. Retrieval operations should not remove the car with minimum price or mileage from the datastructure, just return information about that car. Cars should only be removed via the "remove a specific car from consideration" menu option. 1. To aid in the testing of your application, you will find an example file with some test data store in this repository (``). Your progam should read in the contents of this file to initialize your data structure each time it is run. You can assume that this file will already exist, and you do not need to write an updated version of the data sturcture back to the file. 1. To ensure efficiency of operations, you must base your data structure around the use of heaps with indirection (making them indexable). Note that operations on either attribute (e.g., retrieve minimum price, retrieve minimum mileage) should have a logarthmic runtime (both for all cars and for a specific make and model). Updates and removals should also have a logarithmic runtime. Take care in selecting your approach to the indirection data structure to account for the types of keys you will need to store and the type and number operations that you will need to perform on them. 1. Because this project requires you to make a number of decisions about how to implement its requirements, you will need to write a documentation file explaining your implementation, and justifying your decisions. Name this file ``. Be sure to describe your carefully document your approach to ease the effort required to trace through your code for grading. Be sure to include descriptions of the runtime and space requirements of your approach and use them in your justification of why you think your approach is the best way to go. Submission Guidelines: * **DO NOT SUBMIT** any IDE package files. * You must name the primary driver for your program `CarT`. * You must be able to compile your game by running `javac CarT`. * You must be able to run your program with `java CarTracker`. * You must document and justify your approach in ``. * You must fill out `info_`. * Be sure to remember to push the latest copy of your code back to your GitHub repository before the the assignment is due. At the deadline, the repositories will automatically be copied for grading. Whatever is present in your GitHub repository at that time will be considered your submission for this assignment. Additional Notes/Hints: * You are free to use code provided by the book authors in implementing your solution. It is up to you to decide if it would be easier to modify the provided code to meet the requirements of this project or if it would be easier to start with a clean slate with all of your own code. * Your program does not need to enforce that users enter properly formatted VIN numbers, but you must design your data structure to operate efficiently on VIN numbers as specified here. This should make testing your program much easier. Grading Rubric: * Adding a car works properly: 10 * Updating a car works properly: 10 * Removing a car works properly: 15 * Retrieval for all cars works properly: 10 * Retrieval for a given make/model works properly: 15 * Operations on either attribute are efficient due to heap-backed data structure: 15 * Validity of justitifications: 15 * Menu-based driver program works properly and has appropriately labeled options: 5 * Assignment info sheet/submission: 5

Show more Read less








Whoops! We can’t load your doc right now. Try again or contact support.

Document information

Uploaded on
March 11, 2025
Number of pages
1
Written in
2024/2025
Type
Summary

Subjects

Content preview

Justifications
I used the textbooks Binary Search Tree data structure to implement my project.
When I read through the code of the binary search tree I noticed that the way the
binary search tree is implemented by Sedgewick keeps track of minimum and maximum
rank of nodes. Which also makes it heap based since the only definition of heap is
keeping the priority element on top.


I originally tried to use IndexMinPQ for my project but there was no way of
searching through the index in a O(logn) fashion. I could only figure out a linear
way to do it. By using a BST that keeps track of min and max ordering I was able to
search must faster.
Since Sedgewick implemented BST like with a heap-like structure I decided use his
code.

If you are reading my code you will notice that I created my 3 BSTS for efficient
searching. Since there was no restriction on space complexity on this project I
decided that this was the best way to have the fastest searches.

One BST was using the vin number as a key and I used that for update and remove
methods.
The other two BST have different compareTo’s implemented. One has a minimum price
style heap and the other BST has a minimum mileage style heap. They have the car as
the key because that was just the easiest way for me to use it due to the way
Sedgewick wrote his code.

The indexing was based on vin and then for the last two methods the indexing was
based on rank.

For updating a cars information,, my implementation has O(logn) runtime because the
BST uses a binary search which is O(logn) runtime to find the requested car. In the
update method there are delete, search and insert calls in sequential order. I have
all three of my BSTS doing this operation. But since all those operations in a BST
are logn its just 9logn which becomes O(logn) .

For removing a car from the heap the 3 BSTS search through the tree/heap to find
the car then delete it. This costs 6logn runtime but it reduces down to O(logn)
once again.

For finding the minimum price in the tree/heap all I call is the minimum method on
the minimum price BST. This is O(1) runtime since it keeps minimum order.

For finding the minimum mileage in the tree/heap all I call is the minimum method
on the minimum mileage BST. This is O(1) runtime since it keeps minimum order.

For finding the minimum price based on make and model I start at the minimum priced
car and work my way up iteratively. I’m not sure the exact runtime on this
actually. I think in the absolute worst case its O(n) since I’m searching through a
BST I think its O(logn)

For finding the minimum mileage based on make and model I start at the minimum
mileage car and work my way up iteratively. I’m not sure the exact runtime on this
actually. I think in the absolute worst case its O(n) since I’m searching through a
BST I think its O(logn)
$59.49
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
myprogrammingsolver

Get to know the seller

Seller avatar
myprogrammingsolver Pittsburg State University
View profile
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
9 months
Number of followers
0
Documents
2
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions