Aspire Faculty ID #18813 · Topic: UGC NET Computer Science Nov 2021 (Paper II) · Just now
UGC NET Computer Science Nov 2021 (Paper II)

Consider the following recursive function $F()$ in Java that takes an integer value and returns a string value:

public static String F(int N){
if (N <= 0) return "-";
return F(N - 3) + N + F(N - 2) + N;
}

The value of $F(5)$ is:

Solution

Given function is $F(N)=F(N-3)+N+F(N-2)+N$ and if $N\le 0$, then $F(N)=-$.
Now,
$F(1)=F(-2)+1+F(-1)+1=-1-1$
$F(2)=F(-1)+2+F(0)+2=-2-2$
$F(3)=F(0)+3+F(1)+3=-3-1-13$
Now find $F(5)$:
$F(5)=F(2)+5+F(3)+5$
$F(5)=(-2-2)+5+(-3-1-13)+5$
$F(5)=-2-25-3-1-135$

Previous 10 Questions — UGC NET Computer Science Nov 2021 (Paper II)

Nearest first

Next 10 Questions — UGC NET Computer Science Nov 2021 (Paper II)

Ascending by ID
1
Match List I with List II:List IList IIA. JNDII. Runtime support for running Java programB. RMIII. The API in support o…
Topic: UGC NET Computer Science Nov 2021 (Paper II)
2
Match List I with List IIList IList IIA. ImperativeI. Declarative, clausal representation, theorem provingB. Object-ori…
Topic: UGC NET Computer Science Nov 2021 (Paper II)
3
Suppose you have eight black and white images taken with a $1$-megapixel camera and one $8$-color image taken by an $8$…
Topic: UGC NET Computer Science Nov 2021 (Paper II)
4
Which of the statements given below are correct?The midpoint or Bresenham algorithm for rasterizing lines is optimized …
Topic: UGC NET Computer Science Nov 2021 (Paper II)
5
&nbsp;What is the transformation matrix $M$ that transforms a square in the $xy$-plane defined by $(1,1)^T,(-1,1)^T,(-1…
Topic: UGC NET Computer Science Nov 2021 (Paper II)
6
Suppose a Bezier curve $P(t)$ is defined by the following four control points in the $xy$-plane:$P_0=(-2,0),\ P_1=(-2,4…
Topic: UGC NET Computer Science Nov 2021 (Paper II)
7
Given below are two statements:Statement I: The maximum number of sides that a triangle might have when clipped to a re…
Topic: UGC NET Computer Science Nov 2021 (Paper II)
8
In software testing, beta testing is the testing performed by ____________.
Topic: UGC NET Computer Science Nov 2021 (Paper II)
9
The V components in MVC are responsible for:
Topic: UGC NET Computer Science Nov 2021 (Paper II)
10
In software engineering, what kind of notation do formal methods predominantly use?
Topic: UGC NET Computer Science Nov 2021 (Paper II)
Ask Your Question or Put Your Review.

loading...