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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write the control statements in C language

637


Why & is used in scanf in c?

609


What is self-referential structure in c programming?

646


What is ambagious result in C? explain with an example.

2041


A text file that contains declarations used by a group of functions,programs,or users a) executable file b) header file c) obj file d) .cfile

634






Can we replace the struct function in tree syntax with a union?

765


What is typedef struct in c?

573


What is pass by value in c?

588


Is there a built-in function in C that can be used for sorting data?

735


What header files do I need in order to define the standard library functions I use?

526


What is #define size in c?

634


What is static and auto variables in c?

548


how to introdu5ce my self in serco

1517


Give differences between - new and malloc() , delete and free() ?

598


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

587