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 associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;
What are the uses of a pointer?
How to throw some light on the b tree?
What is dangling pointer in c?
Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]
What is a #include preprocessor?
Does sprintf put null character?
The number of bytes of storage occupied by short, int and long are a) 2, 2 and 4 b) 2, 4 and 4 c) 4, 4 and 4 d) none
Write a program to input the price of 1 burger and the number of burgers eaten by a group of friends .print the total amount to be paid by the group?
What is the newline escape sequence?
what is the function of pragma directive in c?
What is wild pointer in c with example?
What is modeling?
In which header file is the null macro defined?
What is the difference between text and binary modes?