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


Please Help Members By Posting Answers For Below Questions

Explain threaded binary trees?

775


Which is better between malloc and calloc?

770


What is the scope of local variable in c?

671


Why we use conio h in c?

756


Why C language is a procedural language?

700






What is file in c language?

671


Write a program to swap two numbers without using third variable?

917


A c program to display count values from 0 to 100 and flash each digit for a secong.reset the counter after it reaches 100.use for loop,. pls guys hepl me.. :(

1838


What is mean by Data Driven framework in QTP? Can any one answer me in details on this regard.

1877


What is the meaning of 2d in c?

703


What are types of preprocessor in c?

716


What are the 5 types of organizational structures?

659


How reliable are floating-point comparisons?

721


Explain what’s a signal? Explain what do I use signals for?

686


What are the 32 keywords in c?

747