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


Answer: B

Computer Science & Information Technology

You might also like to view...

XYZ is a large real estate firm. Their core competence is their understanding of the real estate market, and their understanding of their customers and the customer needs. Their most critical tools are their CRM and email servers. They are growing, and so is their customer list and their IT and marketing costs are growing at an alarming rate. They currently use managed services to run their CRM, email, etc software but they have had to deal with significant delays as each growth spurt is bogged down by the time and cost it takes to provision new servers, install the software, test it and bring it online. Which cloud delivery model would be best suited for them?

IaaS PaaS SaaS

Computer Science & Information Technology

To develop software you need all these except ?________.

A. ?a compiler B. ?an integrated development environment C. a ?debugger D. personal application software

Computer Science & Information Technology

(Counter Application) Create a Counter application (Fig. 4.13). Your Counter appli- cation’s GUI will consist of a JTextField and a JButton. The JTextField initially displays 0, but each time a user clicks the JButton, the value in the JTextField increases by



) Copying the template to your working directory. Copy the C:Examples Tutorial04ExercisesCounter directory to your C:SimplyJava directory.

b) Opening the Command Prompt window and changing directories. Open the Com- mand Prompt window by selecting Start > Programs > Accessories > Command Prompt. Change to your working directory by typing cd C:SimplyJavaCounter.

c) Compiling the template application. Compile your application by typing javac

Counter.java.

d) Running the template application. Run the Counter template application by typing java Counter. The GUI of the Counter template application should appear as shown in Fig. 4.14. Note the differences from Fig. 4.13.



e) Opening the template file. Open the Counter.java file in your text editor.

f) Customizing countJTextField. After

Computer Science & Information Technology

Why is the concept of behavioral addiction controversial?

What will be an ideal response?

Computer Science & Information Technology