9-Containers - Containers Hold data and provide access to...

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

View Full Document Right Arrow Icon
Hold data and provide access to it. Random-access containers: - Allow accessing any element by index - arrays, vectors Sequential containers: - Allow accessing elements sequentially (i.e. not by index) - queues, stacks, linked lists - Require iterators to locate elements Containers Containers
Background image of page 1

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

View Full DocumentRight Arrow Icon
In principle one can solve any problem with arrays or vectors. In practice queues, stacks and linked lists are more convenient and more efficient performance- wise for select applications. Why Sequential Containers? Why Sequential Containers?
Background image of page 2
Suppose we are dealing with N points organized in array. To copy them from one location to another will take an order of N operations – O(N). To get i-th point – pt[i] – from array would always take the same constant time – O(1). To sort the array via brute force approach would take order N*N operations – O(N 2 ). To sort the array via quick sort would take order N*log 2 (N) – O(N logN). Efficiency: Big-O Notation Efficiency: Big-O Notation
Background image of page 3

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

View Full DocumentRight Arrow Icon
Huge collection of generic classes at your disposal! string, vector, queue, dequeue, list, etc.
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 03/18/2010 for the course CSE 122 taught by Professor Yoxheimer,ericch during the Spring '07 term at Pennsylvania State University, University Park.

Page1 / 16

9-Containers - Containers Hold data and provide access to...

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