lec0302-resizing - Column Statistics for: MT1ckh Count: 253...

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

View Full Document Right Arrow Icon
1 Column Statistics for: MT1ckh Count: 253 Average: 79.2 Median: 84.0 Maximum: 99.5 Minimum: 25.5 Standard Deviation: 14.43 Hide Histogram
Background image of page 1

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

View Full DocumentRight Arrow Icon
Today’s announcements: MP4 available, EC due 3/4, due 3/11, 11:59p. Exam 1 returned in section this week. Today: Stacks Resizing array-based linear structures Queues
Background image of page 2
Stack array based implementation: template<class SIT> class Stack { public: Stack(); ~Stack(); // etc. bool empty() const; void push(const SIT & e); SIT pop(); private: int capacity; int size; SIT * items; }; template<class SIT> Stack<SIT>::Stack(){ capacity = 4; size = 0; items = new SIT[capacity]; } template<class SIT> void Stack<SIT>::push(const SIT & e){ if (size >= capacity) { // grow array somehow } items[size] = e; size ++; } 3 6 8 top of stack items[ size - 1 ]
Background image of page 3

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

View Full DocumentRight Arrow Icon
(what if array fills?) Analysis holds for array based implementations of Lists, Stacks, Queues, Heaps… General Idea: upon an insert (push), if the array is full, create a larger space and copy the data into it. Main question:
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 01/26/2012 for the course CS CS 225 taught by Professor Heeren during the Spring '09 term at University of Illinois, Urbana Champaign.

Page1 / 13

lec0302-resizing - Column Statistics for: MT1ckh Count: 253...

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