{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lec0302-resizing

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

This preview shows pages 1–8. Sign up to view the full content.

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

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

View Full Document
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
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 ]

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

View Full Document
Stack array based implementation: (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: What’s the resizing scheme? We examine 3.
Stack array based implementation: (what if array fills?) How does this scheme do on a sequence of n pushes?

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

View Full Document
Stack array based implementation: (what if array fills?) 3 4 6 2 3 4 How does this scheme do on a sequence of n pushes?
Stack array based implementation: (what if array fills?) How does this scheme do on a sequence of n pushes?

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 13

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

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

View Full Document
Ask a homework question - tutors are online