Math, asked by shivankrastogi2, 9 months ago

the condition top= -1 indicates that​

Answers

Answered by nmsrinutaragalla
6

please see in Google and found that the answer is yes

Answered by ankhidassarma9
0

Answer:

The condition top= -1 indicates that​ the Stack is empty.

Step-by-step explanation:

  • A Stack is an ordered collection of items into which new items may be inserted and from which items may be deleted at one end, called the top of the stack.
  • Unlike that an array , the definition of the stack provides for the insertion and deletion of the items, so that a stack is a dynamic, constantly changing object.
  • In C, a stack can be declared as a structure containing two objects; an array to hold the elements of the stack, and an integer to indicate the position of the current stack top within the array.

        struct stack {

         int top;

         float items[30];

         } s;

        here, stack can contain 30 floating type elements. s is a stack type    

        variable.

  • The empty stack contains no elements and can therefore be indicated by top equaling -1.
  • To initialize a stack s to the empty state, we initially execute

          s.top = -1;.

  • To determine, during the course of execution, whether or not a stack is empty the condition s.top== -1 may be tested in an if statement as follows:

            if (s.top== -1)

            /* Stack is empty */

            else

            /* stack is not empty */

Similar questions