(Latest Revision: 04/04/2002)
Week 08 Notes for CS 2500, Section 001 -- Spring 2002
CS 2500, Section 001, Tuesday, April 09, 2002
- Look at Upcoming Schedule
- Class starts at 09:40. I take roll at 09:50
- Announcement(s)
- Discuss how the list operations are implemented in the
array-based case by examining the code in
the ListA.cpp file.
- Discuss how linked lists work.
- Refer to
the ListP.h header file.
- Refer to
the ListP.cpp implementation file.
- The interface to our linked list
(see ListP.h)
is the same as the interface to
our array list
(see ListA.h).
This is a case where the ADT remains the same. It is
only the implementation that differs.
- In
ListP.h
note what is different from
ListA.h.
- Look at
the diagrams
illustrating insertion into a linked list and retrieval
from a linked list. Use these diagrams to get a feel
for how linked lists are implemented.
- Discuss the code in
the ListP.cpp implementation file.
Note how the following things are used:
- pointers,
- linking,
- calls of the form "new dataType" to allocate
memory dynamically, and
- calls of the form "delete pointerToData" to
deallocate (recycle) dynamically allocated objects.
- Consider how an element is removed from a linked list.
- Review the pro's/con's and performance differences between
pointer-based and array-based implementations.
- Arrays are easy to use, but they have a fixed size.
- A program that uses an array may run out of memory or
waste storage.
- Using dynamic arrays may waste time and/or storage.
- An array-based implementation does not require
extra storage for pointers.
- A program can access array items quickly (random access).
-
CS 2500, Section 001,Thursday, April 11, 2002
- Look at Upcoming Schedule
- Class starts at 09:40. I take roll at 09:50
- Announcement(s)
- Discuss what the header comments for program #2 should have said.
- finish up discussing linked lists
- the destructor: ~listClass
- ListRetrieve
- the copy constructor: listClass(const listClass&)
- what does it do?
- how do you call it?
-
- If time allows, begin discussing applications of the stack data type
- Evaluating postfix expressions
- "Towers of Hanoi" puzzle program
- depth-first search
-