Question: Given a struct as follows: Struct myStack{ int *data; int size; }; typedef struct myStack Stack; Write a C program to implement the following functions:
Given a struct as follows:
Struct myStack{
int *data; int size;
}; typedef struct myStack Stack;
Write a C program to implement the following functions:
e. void doubleSize(Stack *S);
//doubles the size of the stack by allocating more memory and setting size
f. void halveSize(Stack *S);
//halves the size of the stack (could be destructive to the stack values).
//update the size appropriately
g. int search(Stack *S, int e);
//returns the index of element whose value is e, -1 if not found
h. void destroy(Stack *S);
//destroys the memory allocated to the stack
i. int stackFull(Stack *S);
//returns 1 if stack is full, 0 if not full
j. void Reverse(Stack *S);
//reverses the order of elements in the stack
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
