Solved

Which of the Following Represents the Sum of Squares

Question 39

Multiple Choice

Which of the following represents the sum of squares?


A) Function Numeric unKnown(Numeric num)
// Call function recursively until reaching 0 or 1
If num == 0 Or num == 1 Then
Return num
Else
Return unKnown(num - 2) + unKnown(num - 1)
End If
End Function

B) Function Numeric unKnown(Numeric num)
// Base case returns 1
If (num == 1) Then
Return 1
Else
Return (num * num) + unKnown(num - 1)
End If
End Function

C) Function Numeric unKnown(Numeric num)
// Declare variables
Declare Numeric fact = 1
Declare Numeric index // loop index
// Loop
For index = num to 1 Step -1
Fact = fact * index
End For
Return fact
End Function

D) Module unKnown(Integer n, sourcePeg, targetPeg, sparePeg)
If (n > 0) Then
MoveDiscs(n - 1, sourcePeg, sparePeg, targetPeg)
// Move disc from sourcePeg to targetPeg
MoveDiscs(n - 1, sparePeg, targetPeg, sourcePeg)
End If
End Module

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents