Array Stacks
Complete the int isempty (stack S) function, which determines whether the stack is empty and returns 0 if NULL returns 1.
Complete the int isfull (stack S) function, which determines whether the stack is full and returns 0 if full returns 1.
typedef int ELEMTYPE;
struct Stackrecord;
typedef struct STACKRECORD *stack;
struct Stackrecord
{
int Capacity;//stack capacity
int top;//Stack tops, initially 1
elemtype *array;
};
int IsEmpty (Stack S)
{
if (s‐>top==‐1)
{return
1;
}
else
{return
0;
}
}
int Isfull (Stack S)
{
if (s‐>top==s‐>capacity‐1)
{return
1;
}
else
{return
0;
}
}
Chain Stacks
Complete the int isempty (stack s) function, which determines whether stack s is empty, empty stack returns 1, or 0, known S is the chain stack of leading nodes.
typedef int ELEMTYPE;
struct Node;
typedef struct NODE * PTRTONODE;
typedef ptrtonode Stack;
struct Node
{
elemtype data;
Ptrtonode Next;
int IsEmpty (Stack S)
{return
s‐>next==null?1:0;
}
array Queues
completes the int isempty (queue q) function, which determines whether the queue Q is empty, returns 0 if it is empty, or 1, where Q is an array-based, non-circular queue.
Complete the int isfull (queue q) function, which determines whether the queue Q is full and returns 0 if the full returns 1, where q is an array-based, non-circular queue.
typedef int ELEMTYPE;
struct Queuerecord;
typedef struct QUEUERECORD * QUEUE;
struct Queuerecord
{
int Capacity;//Queue Total capacity
int Front;//Team First initial value is 0
int rear;//team tail, initial value is 1
int Size;// The number of data in the queue, the initial value is 0
elemtype *array;
int IsEmpty (Queue Q)
{return
q‐>size==0;
}
int Isfull (Queue Q)
{return
q‐>rear==q‐>capacity‐1?1:0;
}
Chain Queues
Complete the int isempty (queue q) function, which determines whether the queue Q based on the linked list is empty, the empty queue returns 1, and the Non-empty queue returns 0, where Q is a linked list queue that does not lead the node.
typedef int elemtype; struct node; typedef struct node node; struct queue; typedef struct Queue *
Queue;
struct Node {elemtype data;
Node * NEXT;
};
struct Queue {node * Front/Team First Node * rear;//team tail int size;//queue data}; int IsEmpty (Queue q) {return q‐>size==0?1:0;}