Lecture 9 - The List Type

Lecture 9 - The List Type - The List Type Lecture 9 Hartmut...

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

View Full Document Right Arrow Icon
The List Type Lecture 9 Hartmut Kaiser hkaiser@cct.lsu.edu http://www.cct.lsu.edu/˜hkaiser/fall_2011/csc1254.html
Background image of page 1

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

View Full DocumentRight Arrow Icon
Programming Principle of the Day KISS (Keep it simple, stupid!) ▫ Simplicity (and avoiding complexity) should always be a key goal. Simple code takes less time to write, has fewer bugs, and is easier to modify. ▫ The principle is best exemplified by the story of Kelly Johnson (lead engineer at Lockheed) handing a team of design engineers a handful of tools, with the challenge that the jet aircraft they were designing must be repairable by an average mechanic in the field with only these tools. http://en.wikipedia.org/wiki/KISS_principle 9/27/2011, Lecture 9 CSC 1254, Fall 2011, The List Type 2
Background image of page 2
Abstract Performance of our example is fine for small inputs, but quickly degrades for a larger number of students. Why? Inserting/deleting records in the middle of vectors requires moving big chunks of memory to preserve the random access property. Our program has a time complexity of O(N 2 ). Different data structure is required 9/27/2011, Lecture 9 CSC 1254, Fall 2011, The List Type 3
Background image of page 3

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

View Full DocumentRight Arrow Icon
The List Type We rewrote code to remove reliance on indices ▫ Now: change data structure allowing to efficiently delete elements from the middle of the sequence Common requirement, therefore: std::list<> ▫ Vectors are optimized for fast random access ▫ List are optimized for fast insert and delete at any point Generally, slower than vectors
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/29/2011 for the course CSC 1254 taught by Professor Blanks,l during the Fall '08 term at LSU.

Page1 / 21

Lecture 9 - The List Type - The List Type Lecture 9 Hartmut...

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

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