Question: Create an inventory database for a used car lot. Support the following actions: Search the database for a particular vehicle. Add a new car to

Create an inventory database for a used car lot. Support the following actions: Search the database for a particular vehicle. Add a new car to the database. Delete a car from the database. The database must remain sorted by vehicle ID. Each car has the following characteristics: vehicle ID, make, model, year, mileage, cost. Because its a linked list, we also need a pointer to the next node in the list:

typedef struct carType Car; struct carType { int vehicleID; char make[20]; char model[20]; int year; int mileage; double cost; Car *next; /* ptr to next car in list */ } Searching, adding, and deleting all require us to find a particular node in the list. We scan the list until we find a node whose ID is >= the one were looking for. Create a new node with the proper info. Find the node (if any) with a greater vehicleID. Splice the new node into the list: Find the node that points to the desired node at a position. Redirect that nodes pointer to the next node (or NULL). Free the deleted nodes memory.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!