(Latest Revision: 04/22/2002)
Week 10 Notes for CS 2500, Section 001 -- Spring 2002
CS 2500, Section 001, Tuesday, April 23, 2002
- Look at Upcoming Schedule
- Class starts at 09:40. I take roll at 09:50
- Announcement(s)
- We have a quiz Thursday in the last 50 minutes of class
-- let's check the topics.
- Program #3 is due today.
- We have a new programming assignment -- #4 -- get
started right away -- you don't have a lot of time.
- I will be away on Thursday, May 2 (any chance of "early
session"?)
- I have to leave campus today at 11:30. I won't be
doing office hours at the regular time of 11:15 to
12:15. I also have to attend a meeting from 2:30 to
4:30. I will try to be in my office in the morning
before class and for a short time in the afternoon.
- Finish up discussing linked lists
- Look at how the ListP code uses new and delete. What
are the results of these calls to new and delete?
- Take a look at how the ListP code defines the list node
data type and the ptrType that is a pointer to a list
node.
- Discuss Definition of the stack data type
- Organization -- Last-In, First-Out
- Elements -- any given homogeneous set
- Operations
- constructor(s)
- destructor(s)
- bool StackIsEmpty()
- void Push(stackItemType NewItem, bool& Success)
- void Pop(bool& Success)
- void Pop(stackItemType& StackTop, bool& Success)
- void GetStackTop(stackItemType& StackTop, bool& Success)
- Discuss applications of the stack data type
- Evaluating postfix expressions
- "Towers of Hanoi" puzzle program
- depth-first search
- Discuss pro's and con's of different implementations of the
stack ADT.
- array-based implementation
- PRO: simple code
- PRO: all operations are O(1) (compare with "list classes")
- CON: static allocation
- pointer-based implementation
- PRO: dynamic memory allocation
- PRO: most operations are O(1) (compare with "list classes")
- CON: destructor is O(N)
- CON: extra memory required for each element.
- "as-a-list" implementations
- PRO: extremely easy to program
- PRO: if done a certain way, can be as efficient as coding
"from scratch."
- PRO: can be done with an array-based list or with a
pointer-based list.
- CON: There is extra function-call overhead.
- CON: can be very inefficient if not done carefully -- the
example code is inefficient if the list has the array
implementation, and is efficient if the list has the
linked implementation.
CS 2500, Section 001,Thursday, April 25, 2002
- Look at Upcoming Schedule
- Class starts at 09:40. I take roll at 09:50
- Announcement(s)
- We have a quiz today in the last 50 minutes of class
- As time allows, discuss as much of the material below as
possible before the start of the quiz.
- Discuss Definition of the queue data type
- Organization -- First-In, First-Out
- Elements -- any given homogeneous set
- Operations
- constructor(s)
- destructor(s)
- bool QueueIsEmpty()
- void QueueInsert(queueItemType NewItem, bool& Success)
- void QueueDelete(bool& Success)
- void QueueDelete(queueItemType& QueueFront, bool& Success)
- void GetQueueFront(queueItemType& QueueFront, bool& Success)
- Discuss applications of the queue data type
- Ready queue in an OS
- Resource queues -- e.g. student registration system
- Simulations -- e.g. traffic, airport, bank
- Radix Sort
- breadth-first search
- Discuss implementations of the queue data type
- array-based implementation
- pointer-based implementation
- "as-a-list" implementations
- Discuss pro's and con's of different implementations
- array-based implementation
- PRO: simple code
- PRO: all operations are O(1)
- CON: static allocation
- pointer-based implementation
- PRO: dynamic memory allocation
- PRO: most operations are O(1)
- CON: destructor is O(N)
- CON: extra memory required for each element.
- "as-a-list" implementations
- PRO: extremely easy to program
- PRO: if done a certain way, can be as efficient as coding
"from scratch." -- take care to make both insertion
and deletion efficient.
- PRO: can be done with an array-based list or with a
pointer-based list.