Stack
1stack-EMPTY (S)2 iftop[s]=03ThenreturnTRUE4 Else returnFALSE5 6 PUSH (s,x)7top[s]←top[s]+18 s[top[s]]←x9 Ten POP (S) One ifstack-EMPTY (S) AThen error"underflow" - Elsetop[s]←top[s]-1 - returns[top[s]+1]
Queue
1 ENQUEUE (q,x)2 q[tail[q]]←x3 iftail[q]=Length[q]4Then tail[q]←15 Elsetail[q]←tail[q]+16 7 DEQUEUE (Q)8 X←q[head[q]]9 ifhead[q]=Length[q]TenThen head[q]←1 One Elsehead[q]←head[q]+1 A returnX
Linked list
1list-SEARCH (l,k)2 X←head[l]3 whileX!=nil and key[x]!=k4 DoX←next[x]5 returnx6 7list-INSERT (l,x)8 Next[x]←head[l]9 ifhead[l]!=NilTen Then prev[head[l]]←x One head[l]←x A Prev[x]←nil - -list-DELETE (l,x) the ifprev[x]!=Nil - Then Next[prev[x]]←next[x] - ElseHead[l]←next[x] - ifnext[x]!=Nil +Then Prev[next[x]]←prev[x]
There is a root tree
Binary tree, using the domain P,left,right to represent the parent of the tree T, left dial hand, right child.
There is no limit to the number of branches of a root tree, using the domain P,left-child[x],right-siblling[x] to represent the parent of the tree T, left child element and right sibling element.
Introduction to Algorithms learning Notes--10th. Basic Data structure