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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!