Question: A single array, stk[MAXELEMS], is used to implement two stacks. The two stacks are grown in an array one from each end. Two variables, head1
A single array, stk[MAXELEMS], is used to implement two stacks. The two stacks are grown in an array one from each end. Two variables, head1 and head2 (head1 < head2), hold the index of the location of the top element in each of the stacks. Which of the following is the best for implementing the check for a full stack, given we want a space efficient algorithm.
(head1 = MAXELEMS / 2) and (head2 = MAXELEMS / 2+1)
head1 + head2 = MAXELEMS
(head1 = MAXELEMS / 2) or (head2 = MAXELEMS)
head1 = head2 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
