Q1:What does each of the following print? Explain each outcome. 1.System.out.println(2 + "bc"); 2.System.out.println(2 + "bc" + 3); 3.System.out.println( 2 + 3 + "bc"); 4.System.out.println("bc"...

1 answer below »

Q1:What does each of the following print? Explain each outcome.

1.System.out.println(2 + "bc");

2.System.out.println(2 + "bc" + 3);

3.System.out.println( 2 + 3 + "bc");

4.System.out.println("bc" XXXXXXXXXX) );

5.System.out.println("bc" XXXXXXXXXX );


Q2:

Write out a program traceto find out what operation the following Java method performs, using the following example inputs:N=17,N=25.

public static Boolean mystery (int N) {
if (Nfor (int i=2; i*i
if (N%i==0) {
return false;
}
}
return true;
}

Q3: Show, using a memory trace, how an insertion sortsorts the sequence of characters below:

E A G E R N E S S

Q4:

A program that processes a file of input numbers is run a number of times, each time doubling the size of the input. The running time for each input was recorded, and the data are presented below.

N

250

500

1000

2000

4000

8000

t (s)

14

160

1813

20596

233983

2658252

Use the doubling hypothesis to find a power law relationship that approximately describes the program's performance. Show all your workings.

Q5:

Perform one single partitioning operation on the following sequence of random characters, as part of a quicksort operation. Show all your workings.

I R T H U D O A N E Q S

Q6:

Explain the steps taken to add a sequence of (key, value) pairs to an initially empty binary search tree (BST). The keys are as follows:

D I S T R I B U T E

In your answer, include an explanation of each step, and a diagram showing the final BST.

Q7:

Horner’s methodis a popular way of implementing hash codes for strings. Describe Horner’s method, and give an example of its operation on the string “flew”, given the following data.

Char

Unicode

‘f’

102

‘l’

108

‘e’

101

‘w’

119

Answered Same DayMay 10, 2021

Solution

Kshitij answered on May 10 2021
27 Votes
Q1:What does each of the following print? Explain each outcome.
1. System.out.println(2 + "bc");
2. System.out.println(2 + "bc" + 3);
3. System.out.println( 2 + 3 + "bc");
4....
SOLUTION.PDF

Answer To This Question Is Available To Download

Submit New Assignment

Copy and Paste Your Assignment Here