Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please answer in c 3. (20pt) Recall the stack ADT. Followings are the important things from its interface stack.h #ifndefstackh - - define _stack h
please answer in c
3. (20pt) Recall the stack ADT. Followings are the important things from its interface stack.h #ifndefstackh - - define _stack h #include "genlb.h" typedef void *stackElementT typedef struct stackCDT stackADT; void Push (stackADT stack, stackElementT element) stackElementT Pop (stackADT stack) endif Please note that the stackElementT is void *. But you need to push/pop double values in your application. In this case, you need to first dynamically allocate memory space for your data, save your data at that space, and push its address. When you need the data, you can pop its address, dereference it and get the value, then free the memory space. Instead of doing these things whenever needed, you can simply implement the following two functions that can push and pop a double value as described above, then you can call them when needed. (Don't forget to check if memory is allocated or not in push, and to free it in pop) void myPushDouble (stackADT stack, double value) // 14pt double *ptr; double myPopDouble (stackADT stack) // 6pt double tmp, *ptrStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started