DATA STRUCTURES MIS 102 CHRISTENSON
- 3 -
4. Appropriate Use
- Efficient processing when a large percentage of elements (e.g.,
records) are processed during a run.
- If a list is ordered, the data elements/records may be processed in the
natural order of the list/file.
- Effective when adds and deletes are relatively infrequent, i.e., the data
is relatively “non-volatile”. (These operations are often handled by a
separate operation.)
5. Sorting (ordering)
The elements in the dense list are arranged in logical order by arranging
them in physical order based on the values of a specific key. This will
enhance processing efficiency. (NOTE: We have examined already a
form of the exchange sort in the BUBLSORT program of Assignment 1.)
E. Restricted Forms of Lists – These allow only certain operations. (We will use
dense lists in our examples, but the assignment will use linked list
implementations.)
1. STACK
All additions and deletions are performed at one end of the list. It is
customary to call this the top or the head of the stack. A separate data
item called a STACK POINTER contains the “address” of the top element
of the stack.
If we consider the stack to be in a table, the value of the STACK
POINTER is used as a subscript. It contains the occurrence number (i.e.,
the location) of the element at the top of the stack. The value of this
pointer will change with the addition and with the deletion of an element.
The operation to place a new element on the stack is called a PUSH, just
as one PUSHes a plate on to the top of the stack of plates in a buffet.
The deletion of an element is called a POP. These are the only two
operations allowed on a stack.
These stack operations can be summarized by Last In – First Out.
2. QUEUES
A list for which the removal of an element takes place only at the top or
the head of the list, and the addition of an element takes place only at the
bottom or the tail of the list. Consequently, we need a “pointer” to hold
the address (i.e., the location) of the element at the “head” of the queue,
and another pointer the hold the address of the element at the “tail” of the
queue. These are often have names like Q-HEAD-PTR and