Determine the growth function and order of the following code fragment:

What will be an ideal response?

```
for (int count = 0; count < n; count ++)
{
for (int count2 = 0; count2 < n; count2 = count2 + 2)
{
System.out.println(count, count2);
}
}
```for (int count = 0; count < n; count ++)
{
for (int count2 = 0; count2 < n; count2 = count2 + 2)
{
System.out.println(count, count2);
}
}
The outer loop will be executed n times. The inner loop will be executed (n+1)/2 times. Therefore, the growth function for the code fragment is n*((n+1)/2) = (n2 + n)/ 2. That is order n2.

Computer Science & Information Technology

You might also like to view...

The ________ , included in the Android SDK, allows you to run Android apps in a simulated environment within Windows, Mac OS X or Linux, without using an actual Android device.

a. Android simulator. b. Android emulator. c. Android device. d. None of the above.

Computer Science & Information Technology

Consider optimistic concurrency control as applied to the transactions T and U. Suppose that transactions T and U are active at the same time as one another. Describe the outcome in each of the following cases:

i) T's request to commit comes first and backward validation is used; ii) U's request to commit comes first and backward validation is used; iii) T's request to commit comes first and forward validation is used; iv) U's request to commit comes first and forward validation is used. In each case describe the sequence in which the operations of T and U are performed, remembering that writes are not carried out until after validation

Computer Science & Information Technology