CS1500 Algorithms and Data Structures for Engineering, FALL 2012

 LAB 7: Double Linked Lists

As a special case of particularly important topic, LAB7 must be completed by all students, even if late (the sooner the better). 
30 points total, might fail the course if not completed.


FIRST PART OF LAB7 (one lab)

You have to build a car inventory using a double-linked list.
A) First design a struct/class called carobject that can be linked both ways (has next and prev pointers), and that contains the data members
B) Write a function that appends a new car to the inventory. Your inventory list *must be sorted by year* at all times, so the new car will be inserted in the list at appropriate location, rather than simply appended at the end.
void car_append (int ID, char* brand, int year, int price, carobject** listhead)

C) Write a function that lists all cars in the inventory with a certain manufacturing year. You should take advantage of the fact that the list is sorted by year
void listallcars_by_year (int year, carobject* listhead)

D) Write a function that lists "adjacent" cars for a given car - that is, all the other cars in the list that have the same manufacturing year and the same brand. Again, you should take advantage of the fact that the list is sorted by year
void list_similar_cars (carobject* car)

E) Write a function that deletes a car form inventory. Make sure to handle all the next and prev pointers around the deleted car.
void delete_car (carobject* car)

SECOND PART OF LAB7 (second lab)

F) List all the cars in the inventory sorted alphabetically by brand. You do not have to rearrange the existing list, but rather create a new data structure (list, array, hash etc) in order to produce the required output.
void listallcars_by_brand (carobject* listhead)

G) Compute an average asking price for all cars of a given brand
double avg_price_by_brand(carobject* listhead, char* mybrand)