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.

Answers were Sorted based on User's Feedback



Consider a language that does not have arrays but does have stacks as a data type.and PUSH POP..are..

Answer / barun

In one stack keep values and in another stack keep index of
array. In other wards a[0] = 10. Then keep in bottom of
stack1 value 10 and in bottom of stack2 0. Both needs to be
synchronized in such implementation. Of course random access
is not possible.

Is This Answer Correct ?    6 Yes 2 No

Consider a language that does not have arrays but does have stacks as a data type.and PUSH POP..are..

Answer / gingercpu

One to pop and the other to push. Have to maintain all the
elements. Index converted to the # of push and pop

Is This Answer Correct ?    4 Yes 2 No

Consider a language that does not have arrays but does have stacks as a data type.and PUSH POP..are..

Answer / 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

More C Interview Questions

What is the difference between class and object in c?

0 Answers  


char S; char S[6]= " HELLO"; printf("%s ",S[6]); output of the above program ? (0, ASCII 0, I,unpredictable)

7 Answers   Mascot,


how c source file in converted to exe file

5 Answers   KPIT,


What are file streams?

0 Answers  


What are the 5 types of organizational structures?

0 Answers  






Why pointers are used in c?

0 Answers  


A C E G H +B D F A I ------------ E F G H D

1 Answers   Infosys,


Can i use “int” data type to store the value 32768? Why?

0 Answers  


Explain how do you view the path?

0 Answers  


WRITE A PROGRAM TO PRINT THE FOLLOWING OUTPUTS USING FOR LOOPS. A) * B) ***** *** * * ***** * * *****

2 Answers  


What is a function in c?

0 Answers  


Is it possible to run a c program without using main?If yes HOW??

13 Answers   Wipro,


Categories