Stack-empty (S)
If s.top = = 0
Return TRUE
else return FALSE
PUSH (s,x)
S.top = s.top + 1
S[s.top] = X
POP (S)
If Stack-empty (S)
Error "Underflow"
else S.top = s.top-1
return s[s.top+1]
Queue
INSERT, ENQUEUE
DELETE, DEQUEUE
ENQUEUE (q,x)
Q[q.tail]=x
if Q.tail = = Q.length
Q.tail = 1
else Q.tail = q.tail + 1
DEQUEUE (q.x)
x = Q[q.head]
if (Q.head = = q.length)
Q.head = 1
else Q.head = q.head + 1
return x
Linked list, doubly linked list, unidirectional linked list, circular link list
List-search (L,k)
x = L.head
While x! = NULL and X.key! = k
x = X.next
return x
List-insert (l,x)
X.next = L.head
If l.head! = NIL
L.head.prev = X
L.head = X
X.prev = NIL
List-delete (l,x)
If X.prev! = NIL
X.prev.next = X.next
else L.head = X.next
If X.next! = NIL
X.next.prev = X.prev
Sentinel
List-search (L, K)
x = L.nil.next
While x! = L.nil and X.key! = k
x = X.next
return x
List-insert (l,x)
X.next = L.nil.next
L.nil.next.prev = X
L.nil.next = X
X.prev = L.nil
Pointers and Object implementations
Objects and most groups represent
object and singular group representations
Allocation and release of objects
Suppose that the array length in most group notation is M, and the dynamic collection contains n<=m elements at a given moment. n objects represent the existing dynamic
The elements in the collection, while the remaining M-n objects are free, and these free objects can be used to represent the elements to be inserted into the dynamic collection
Free Form
Allocate-object ()
If free = NIL
Error "Out of space"
else x = Free
Free = Free.next
return x
Free-object (x)
X.next = Free
Free = X
Multi-linked list majority group notation
Basic Data Structures