edited by
4,570 views
16 16 votes

Consider the function $F(n)$ for which the pseudocode is given below :

Function F(n)
begin
F1 ← 1
if(n=1) then F ← 3
 else
   For i = 1 to n do
        begin
            C ← 0
           For j = 1 to n – 1 do
           begin C ← C + 1 end
           F1 = F1 * C
       end
 F = F1
end

[$n$ is a positive integer greater than zero]

  1. Solve the recurrence relation for a closed form solution of $F(n)$.

2 Answers

Best answer
15 15 votes
Function F(n)
begin
F1 ← 1
if(n=1) then F ← 3  //if (n==1) then return 3 
 else
   For i = 1 to n do
        begin
            C ← 0
           For j = 1 to n – 1 do //inner loop runs n-1 times outer loop runs for n times 
           begin C ← C + 1 end   //means C=n-1
           F1 = F1 * C  //means n-1 is getting multiplied n times so ans is (n-1)^n for n>=2 
       end 
    F = F1 
end
selected by
Position:
Show:

Related questions

74 74 votes
9 answers 9 answers
39.3k
39.3k views
Kathleen asked Sep 13, 2014
39,348 views
The access times of the main memory and the Cache memory, in a computer system, are $500$ n sec and $50$ nsec, respectively. It is estimated that $80\%$ of the main memor...
21 21 votes
4 answers 4 answers
6.6k
6.6k views
Kathleen asked Sep 13, 2014
6,585 views
Consider the function $F(n)$ for which the pseudocode is given below :Function F(n) begin F1 ← 1 if(n=1) then F ← 3 else For i = 1 to n do begin C ← 0 For j = 1 to n – 1 ...
23 23 votes
6 6 answers
10.2k
10.2k views
Kathleen asked Sep 13, 2014
10,225 views
Let $T$ be a Depth First Tree of a undirected graph $G$. An array $P$ indexed by the vertices of $G$ is given. $P[V]$ is the parent of vertex $V$, in $T$. Parent of the r...
32 32 votes
3 answers 3 answers
7.6k
7.6k views
Kathleen asked Sep 13, 2014
7,603 views
Assume that the last element of the set is used as partition element in Quicksort. If $n$ distinct elements from the set $\left[1\dots n\right]$ are to be sorted, give an...