Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedplease 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, *ptr

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

JDBC Database Programming With J2ee

Authors: Art Taylor

1st Edition

0130453234, 978-0130453235

More Books

Students also viewed these Databases questions