asit said:
> we kno during call of a subroutine, the address of next
> instruction( from which the execution is supposed to start after the
> subroutine is executed ) is stored in stack.
We don't actually know that, because the C Standard doesn't guarantee it,
but it is certainly true that some systems work in that way.
> in case of recursion
> (e.g. we are sorting an array having length one million using heap
> sort), we have to call a particular subroutine thousands time. Is
> their any chance of stack overflow ??
It's unlikely. If you're sorting a million items in a recursive O(n log n)
algorithm, you're unlikely to have to recurse more than twenty calls deep,
and that's really no big deal. (2^20 == 1048576)
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
|