(i) Node* pop(Node* top) – which removes the top element of the stack, and (ii) bool compare(Node* topA, Node* topB) - which returns true if the both stacks have identical data. The function returns false if the data in both stacks are not identical. In the function definitions, top, topA, and topB point the top elements of corresponding stacks.
Suppose a node of a linked list is defined as follows in your program:
typedef struct{
char data;
struct Node* link;
} Node;
Write the definitions of two functions (i) Node* pop(Node* top) – which removes the top element of the stack, and (ii) bool compare(Node* topA, Node* topB) - which returns true if the both stacks have identical data. The function returns false if the data in both stacks are not identical. In the function definitions, top, topA, and topB point the top elements of corresponding stacks.
You must use the following function definitions in your answer. The peek function has already been defined. You need to write the definition of pop and compare functions. You are not allowed to modify the parameters and/or return types of the functions.
Node* pop(Node* top){ //write the function definition }
char peek(Node* top){ return top->data; }
bool compare(Node* topA, Node* topB){ //write the function definition }
Write the time complexity in Big-O notation for each of the functions (pop, peek, and compare).

Step by step
Solved in 2 steps









