CrazyEngineers
  • Advantages & Disadvantages of Recursion..

    Dixsita

    Member

    Updated: Oct 27, 2024
    Views: 1.1K
    Hi!!! friends ;-)

    1)How stack is useful in recursion?
    2)Advantages and Disadvantages of recursion??
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Manish Goyal

    MemberSep 27, 2009

    Re: Recursion..

    see recursion means a function calls repeatedly

    It uses system stack to accomplish it's task....as stack uses last in last out approach
    and when a function is called the controlled is moved to where function is defined which has it is stored in memory with some address this address is stored in stack

    second recursion is very interesting ....
    it reduces a time complexity of a program for eg
    say you have created a program for mergesort which uses recursion ie divide and conquer approach and insertion sort which uses normal programming
    now from time complexity point of view you will choose only merge sort to sort a array
    as it has time complexity of nlogn
    and insertion sort has n*n
    2:-it haS disadvantage also
    it involves a lot of memory wastage
    and very much typical concept to understand
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register