2010年9月15日星期三

线性表、堆栈和队列

Lists, Stacks, Queues

Linear structure: an ordered arrangement of elements

list: random insertion and deletion
stack: insertion and deletion only at one end
queue: insertion only at one end and deletion only at the other end

basic organization: contiguous / linked

Implementing a list (Objects & Operations):
Data Set & Relation Set

Lists
a finite, ordered sequence of data items.
Representation:
L=(a[0],a[1], … ,a[n-1])
concepts: head, tail, length, empty,

List Abstract Class:
template <class Emem> class list{
public:
virtual void clear()=0;
virtual bool insert(const Elem&)=0;
virtual bool append(const Elem&)=0;
.. remove, setStart, setEnd, next, prev, int leftLength, int rightLength, setPos, getValue, isEmpty, print

没有评论:

发表评论