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

What is 2 d array in c?

653


What is the advantage of a random access file?

737


Is main is user defined function?

691


Explain how can you check to see whether a symbol is defined?

755


What is string function in c?

620






Explain what is meant by high-order and low-order bytes?

725


An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?

793


Why clrscr is used after variable declaration?

1152


How does placing some code lines between the comment symbol help in debugging the code?

650


c language interview questions & answer

1562


What is the importance of c in your views?

680


Is printf a keyword?

869


How does normalization of huge pointer works?

742


Why n++ execute faster than n+1 ?

2080


What are qualifiers and modifiers c?

640