answersLogoWhite

0

If the program correctly checks the error-conditions, it will terminate -- otherwise it will do... something, e.g. using memory-garbage as data.

User Avatar

Wiki User

13y ago

What else can I help you with?

Continue Learning about Engineering

What is the operation of delete in stack?

Delete is mostly commonly known as pop in stack. The last element inserted into the stack is removed from the stack. Here is an illustration:Consider the stack with the elements 1,2,3,4 inserted in order.1->2->3->4\topThe top of the stack will be pointing to 4. When pop operation is performed, 4 is removed from the stack and the top is made to point to 3. The stack then becomes:1->2->3\top


Why is the constructor of the Stack Linked List class empty?

The default constructor of a stack is empty because the default value of any container, including a linked list, is an empty container which requires no arguments (all members default to zero).


You must write a program in C that uses a stack to check a file for unbalanced parenthesis any suggestions?

Parse the character stream from the beginning of the sequence to the end, counting characters as you go. Every time you encounter an opening parenthesis, push the current character count onto the stack. Every time you encounter a closing parenthesis, ensure the stack is not empty before popping the top value from the stack. You can discard the value -- you've found a matching pair. If you attempt to pop from an empty stack, then you have a closing parenthesis at the current character position that has no matching opening parenthesis. If you reach the end of the test and the stack is not empty, you have at least one opening parenthesis without a matching closing parenthesis. Pop the character positions off the stack to determine where the opening parenthesis are.


Why must the stack pointer be initialized at the beginning of every program?

Because the stack pointer marks the top of the stack. If it is not initialised, it is not possible to determine where the next stack frame will go.


What is the meaning of stack underflow?

Stack underflow occurs when an operation is attempted on an empty stack, resulting in an attempt to access a nonexistent element at the top of the stack. This can lead to errors or unexpected behavior in programs that rely on stack data structures. To prevent stack underflow, it is important to check the stack's current size before performing operations that could potentially lead to underflow.

Related Questions

Why you will declare top as -1 for stacks to be empty in c program?

You would do this if you implement a stack using an array. Using a zero-based index to keep track of the top of the stack (the end of the array) means we must use the value -1 to indicate an empty stack. This is because an array of n elements will have indices 0 through n-1, where index n-1 represents the element at top of the stack. An empty stack has 0 elements, therefore the top of the stack is represented by index -1.


What is stackunderflow?

An error condition that occurs when an item is called for from the stack, but the stack is empty.


'write a simple program for stack operation in c plus plus?

void push(int y) { if(top>stackSize) { cout<<"stack full"<<endl; return; } else { top++; stack[top]=y; } } int pop() { int a; if(top<=0) { cout<<"stack is empty"<<endl; return 0; } else { a=stack[top]; top--; } return(a); }


What is the difference between stack pointer and program counter?

The stack pointer keeps track of the top of the stack used by the current thread. The program counter keeps track of the next instruction in a program. Both are registers and both store a memory address.


What is the operation of delete in stack?

Delete is mostly commonly known as pop in stack. The last element inserted into the stack is removed from the stack. Here is an illustration:Consider the stack with the elements 1,2,3,4 inserted in order.1->2->3->4\topThe top of the stack will be pointing to 4. When pop operation is performed, 4 is removed from the stack and the top is made to point to 3. The stack then becomes:1->2->3\top


How do you single an item out of a stack in Minecraft?

Click on the stack to pick the whole stack up, then right click on an empty inventory slot to deposit a single unit of the stack.


What is the minimal unit of code in an application or system that can be scheduled for execution?

The smallest program is a program that does nothing... int main (int argc, char ** argv) {} ... if you execute this, it will setup the library and the stack frame, only to back-out a release everything after doing nothing.


What are processes in operating system?

To put it in simple terms, we write our computer programs in a text file and when we execute this program, it becomes a process which performs all the tasks mentioned in the program. When a program is loaded into the memory and it becomes a process, it can be divided into four sections ─ stack, heap, text and data


What is the difference between static and stack data?

Depending on the use , Static data is data that cannot change it is Static so is usually set at the start of the program and cannot change, In the Forth programming language the stack is the work area of memory you place data onto the stack to manipulate it (example Place 2 and 3 onto the stack, execute the + command removes the top 2 items off the stack adds them together and places the result back onto the stack.)


What are process states in operating system?

To put it in simple terms, we write our computer programs in a text file and when we execute this program, it becomes a process which performs all the tasks mentioned in the program. When a program is loaded into the memory and it becomes a process, it can be divided into four sections ─ stack, heap, text and data


Why is the constructor of the Stack Linked List class empty?

The default constructor of a stack is empty because the default value of any container, including a linked list, is an empty container which requires no arguments (all members default to zero).


What is part of a software program that can be executed independently of the entire program?

You cannot have any one part of a program execute independently of the entire program. What you can do is instantiate a thread of execution that runs concurrently with the main (primary) thread. Concurrent threads are not independent of the primary thread since they all share the same memory, but they each have their own stack. The only way to execute a completely independent program is to spawn a completely separate process, however separate processes cannot be regarded as being part of the same program, even if they happen to be separate instances of the same program.