Write short notes on:

  1. Tail recursion
  2. Collision resolution techniques

Answers

This answer is not selected as best answer. This answer may not be sufficient for exam.

Your limit has been exceed. We have implemented this system because, We got difficulty on managing our servers. Please donate some amount to remove this limit.

Quota: 0 / 30

Donate

Tail Recursion:

A function that returns the value of its recursive call is said to be tail recursion. Simply a  function is said to be tail recursive if there are no any calculations occur in the recursive stage and it only returns the value.

Example:

#include<stdio.h>

Fact(n, accumulator){
    if(n == 0)
        return accumulator;
    else
        return Fact(n-1, n * accumulator);
}

Factorial(n){
    return Fact(n, 1);
}

void main(){
    int num, f;
    printf("Enter any number");
    scanf("%d", &num);
    f = Factorial(num);
    printf("Factorial of given number is %d", f);
}

The output of above program is

Enter any number

10

Factorial of given number  = 3628800

If you found any type of error on the answer then please mention on the comment or submit your new answer.
Leave your Answer:

Click here to submit your answer.

Discussion
0 Comments
  Loading . . .