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
to find the closest pair
What is array of structure in c programming?
When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?
What is nested structure?
i want to know the procedure of qualcomm for getting a job through offcampus
What does c value mean?
cin.ignore(80, _ _);This statement a) ignores all input b) ignores the first 80 characters in the input c) ignores all input till end-of-line d) iteration
Is linux written in c?
Explain pointer. What are function pointers in C?
Is it possible to pass an entire structure to functions?
What are qualifiers?
When the macros gets expanded?
write a program to concatenation the string using switch case?
What are the different types of control structures in programming?
How can I implement a delay, or time a users response, with sub-second resolution?