GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Concepts  >  Data Structures
Go To First  |  Previous Question  |  Next Question 
 Data Structures  |  Question 193 of 202    Print  
Stack Overflow
How will you identify Stack Overflow?


  
Total Answers and Comments: 4 Last Update: June 07, 2009     Asked by: swetha_joein 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: manihclcodc
 
Stack overflow will happen only in static stack.

Suppose consider a[10] as a stack, top is the last available elment in the stack, max is the index of the top i.e 9. Overflow will happen only at pushing en element. Here is the code.

push(int value)
{
  if(top >= max)
    printf("Stack overflow");
  else
    a[top++] = value;
}


Above answer was rated as good by the following members:
zezond
October 11, 2008 10:45:56   #1  
sgnanam_prakash Member Since: October 2008   Contribution: 1    

RE: Stack Overflow
Stack Overflow means when stack is get fullfilled then a new elements for stack is not push into the stack.
 
Is this answer useful? Yes | No
March 06, 2009 01:02:07   #2  
bhavnajoshi Member Since: February 2009   Contribution: 3    

RE: Stack Overflow
In software stack will overflow when there will more amount of memory required to call the stack. As we all know in every language there are different rules with the memory requirement for the stack call.

In programming if the start On modern operating systems a typical stack has at least 1 megabyte which is sufficient for most purposes. Under anomalous conditions the program exceeds its stack limit. This causes a stack overflow.
The two most common causes for a stack overflow is an infinite recursion as in:
 int f(){ g(); } int g() { f(); } 

 
Is this answer useful? Yes | No
March 06, 2009 01:47:15   #3  
manihclcodc Member Since: March 2009   Contribution: 3    

RE: Stack Overflow
Stack overflow will happen only in static stack.

Suppose consider a[10] as a stack top is the last available elment in the stack max is the index of the top i.e 9. Overflow will happen only at pushing en element. Here is the code.

push(int value)
{
if(top > max)
printf("Stack overflow");
else
a[top++] value;
}

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
June 06, 2009 10:40:21   #4  
anurag007 Member Since: June 2009   Contribution: 1    

RE: Stack Overflow
Stack overflow condition is raised when Top max-1 where max is the size of the array n Top is the topmost element.
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape