Assignment
8
The Stack ADT
Use a linked list to implement
a stack containing character elements. Implement the following
functions for manipulating the stack.
Constructor,
namely,
stack
*create_stack(void)
that constructs a data structure of type stack, empty for the moment,
and returns a pointer to it,
Access functions,
namely,
boolean
stack_is_empty(stack *s)
that, given a pointer s to a stack, returns TRUE if the stack is empty
and returns FALSE otherwise,
stack_object
*top_of_stack(stack *s)
that, given a pointer s to a nonempty stack, returns a pointer to the
object on the top of the stack,
Manipulator functions, namely,
void
push_on_stack(stack *s, stack_object *object);
that, given a pointer s to a stack and given a pointer object to an
object, pushes the object on the top of the stack,
void
pop_stack(stack *s);
that, given a pointer s to a nonempty stack, pops the stack.
Use the above stack ADT in a main()
function which checks whether an input character string is a
palindrome, i.e., symmetrical from start and end. The string "hannah"
is an example of a palindrome.