Following code intends to implement a dynamic stack.
struct node{ float data; struct node* next; }; struct stack{ struct node* sp; };
struct node* makenode(float item){ // make a new node with item ... }
void init(struct stack * s){...} // initialize sp
int full(struct stack * s){...} // return 1 if full
int empty(struct stack * s){...} // return 1 if empty
int push(struct stack *s, float item){ ... }
float pop(struct stack *s){ ... }
float top(struct stack *s){...}
(a) Write a clear diagram to show the status of the stack structure instance, nodes, stored values and node linking after pushing the values 2.0, 6.2 and 7.0.
(b) Write code for each function above to complete the stack implementation.
Me prashna deka kohomada bn karanne
struct node{ float data; struct node* next; }; struct stack{ struct node* sp; };
struct node* makenode(float item){ // make a new node with item ... }
void init(struct stack * s){...} // initialize sp
int full(struct stack * s){...} // return 1 if full
int empty(struct stack * s){...} // return 1 if empty
int push(struct stack *s, float item){ ... }
float pop(struct stack *s){ ... }
float top(struct stack *s){...}
(a) Write a clear diagram to show the status of the stack structure instance, nodes, stored values and node linking after pushing the values 2.0, 6.2 and 7.0.
(b) Write code for each function above to complete the stack implementation.
Me prashna deka kohomada bn karanne
me wage welawata amaruwe wetena un innawa neda office wala ?