Consider a language that does not have arrays but does have
stacks as a data type.and PUSH POP..are all defined .Show
how a one dimensional array can be implemented by using two
stacks.
Answer Posted / abdur rab
The arrays are always sequential, since we are going to use
stack, ther is no possibility for random access.
PUSH all the values in the stack1, then pop the value from
stack1 into stack2.
so whenever ther is a PUSH to stack1, we need to POP all
the elements from stack2 to stack1 and then PUSH the new
value. Now POP all the values from stack1 to stack2. It ud
work like a queue then.
Is This Answer Correct ? | 4 Yes | 3 No |
Post New Answer View All Answers
What is sizeof int?
What is an array in c?
How do you construct an increment statement or decrement statement in C?
What is a pointer in c plus plus?
Why do we use stdio h and conio h?
What is the use of void pointer and null pointer in c language?
What is integer constants?
What extern c means?
What does a pointer variable always consist of?
Is r written in c?
I need testPalindrome and removeSpace
#include
How can you access memory located at a certain address?
How are variables declared in c?
What are keywords in c with examples?
What are the 5 types of organizational structures?