Data Structure tutorial (Java description) edited by Xu xiaokai-review abstract 04
Chapter 3 stack and queue
Stack sequential storage structure and operation implementation
Public class sequencestack implements stack {final int maxsize = 10; // assume that the initial length of the one-dimensional array of the storage stack is 10 private object [] stackarray; // define the storage Stack Array reference private int top; // define the subscript position of the top element of the stack stored in the array // operate public sequencestack () {} public sequencestack (int n) {} public void push (Object OBJ ){}...}
Stack link storage structure and operation implementation
Public class linkstack implements stack {private node top; // defines top stack pointer // operate public linkstack () {} public void push (Object OBJ ){}...}
Usually, the variable pointing to the first position of the first element is called the first pointer. The subscript position of the first element is obtained after the word is added with 1, the variable pointing to the position of the element at the end of the team is called the team-end pointer, which can directly obtain the subscript position of the element at the end of the team.
Ordered storage structure and operation implementation of queues
Public calss sequencequeue implements queue {final int maxsize = 10; // assume that the initial length of the one-dimensional array of the storage queue is 10 private object queuearray []; // define the storage queue array reference private int front, rear; // define the frontend and backend pointers public sequencequeue () {} public sequencequeue (int n) {} public void enter (Object OBJ ){}...}
Queue link storage structure and operation implementation
Public class linkqueue implements queue {private node front, rear; // define the frontend and backend pointer (reference) // operate public linkqueue () {front = rear = NULL ;}...}