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 value of uninitialized variable in c?

0 Answers  


please give me answer with details #include<stdio.h> main() { int i=1; i=(++i)*(++i)*(++i); printf("%d",i); getch(); }

3 Answers  


How will you write a code for accessing the length of an array without assigning it to another variable?

0 Answers  


Explain how can you determine the size of an allocated portion of memory?

0 Answers  


Write a program to check palindrome number in c programming?

0 Answers  






what is the meaning of 'c' language

3 Answers  


give an example of type casting by a simple c program

2 Answers   TCS,


simple c program for 12345 convert 54321 with out using string

7 Answers   TCS,


write a c code "if you give a any decimal number then print that number in english alphabet"? ex: i/p: 552 o/p: five hundred fifty two ...

1 Answers   Philips,


What is a #include preprocessor?

0 Answers  


What is the use of clrscr?

0 Answers  


#include<stdio.h> main() { char s1[]="Ramco"; char s2[]="Systems"; s1=s2; printf("%s",s1); } what will happen if you executed this code?

4 Answers   Ramco,


Categories