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
Explain how do I determine whether a character is numeric, alphabetic, and so on?
How do I send escape sequences to control a terminal or other device?
Where is c used?
What is difference between array and structure in c?
code for quick sort?
what is the diffrenet bettwen HTTP and internet protocol
What are nested functions in c?
How to Throw some light on the splay trees?
What is signed and unsigned?
Can we replace the struct function in tree syntax with a union?
What are local static variables? How can you use them?
What are the different data types in C?
Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.
How many data structures are there in c?
Which one to choose from 'initialization lists' or 'assignment', for the use in the constructor?