Linked_lists

Linked_lists - LINKED LIST VS. ARRAY A linked list can only...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
CMPE13 L INKED L IST VS . A RRAY A linked list can only be accessed sequentially . To find the 5 th element, for instance, you must start from the head and follow the links through four other nodes. Advantages of linked list: Dynamic size Easy to add additional nodes as needed Easy to add or remove nodes from the middle of the list (just add or redirect links) Advantage of array: Can easily and quickly access arbitrary elements 19-14
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CMPE13 E XAMPLE : C AR L OT 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. Since we don’t know how many cars might be on the lot at one time, we choose a linked list representation. 19-15
Background image of page 2
CMPE13 C AR DATA STRUCTURE Each car has the following characterics: vehicle ID, make, model, year, mileage, cost. Because it’s a linked list, we also need a pointer to
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

Linked_lists - LINKED LIST VS. ARRAY A linked list can only...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online