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
What is selection sort in c?
Between macros and functions,which is better to use and why?
Write a code to generate divisors of an integer?
What is the use of a conditional inclusion statement in C?
the constant value in the case label is followed by a a) semicolon b) colon c) braces d) none of the above
What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.
any "C" function by default returns an a) int value b) float value c) char value d) a & b
How do shell structures work?
What is ctrl c called?
What is the purpose of sprintf?
c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above
Why cant I open a file by its explicit path?
Which header file is essential for using strcmp function?
What is c language in simple words?
What is difference between structure and union?