Write a C language program... The following code will implement three functions supported by a stack. Push
Question:
Write a C language program...
The following code will implement three functions supported by a stack.
Push ( ): It adds elements on top of the stack. It takes O (1) O (1) time as each element is inserted starting from the table of the array; there is no need to shift existing elements to make room for the new element.
Pop (): It removes the element on top of the stack. It also takes O (1) O (1) time as the top contains the index of the most recently added element.
Top (): It returns the element on top of the stack. It takes O (1) O (1) time as finding the value stored at a particular index in an array is a constant time operation.
Vector Mechanics for Engineers Statics and Dynamics
ISBN: 978-0073212227
8th Edition
Authors: Ferdinand Beer, E. Russell Johnston, Jr., Elliot Eisenberg, William Clausen, David Mazurek, Phillip Cornwell