Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following method. public static void sort ( String [ ] arr ) { for ( int pass = arr.length - 1 ; pass

Consider the following method.
public static void sort(String[] arr)
{
for (int pass = arr.length -1; pass >=1; pass--)
{
String large = arr[0];
int index =0;
for (int k =0; k <= pass; k++)
{
if ((arr[k].compareTo(large))>0)
{
large = arr[k];
index = k;
}
}
arr[index]= arr[pass];
arr[pass]= large;
}
}
Assume arr is the following array.
"Ann" "Mike" "Walt" "Lisa" "Shari" "Jose" "Mary" Bill
What is the intermediate value of arr after two iterations of the outer for loop in the call sort(arr)?
Responses
"Ann" "Mike" "Walt" "Lisa" "Shari" "Jose" "Mary" Bill"Ann" "Mike" "Walt" "Lisa" "Shari" "Jose" "Mary" Bill
"Ann" "Mike" "Lisa" "Shari" "Jose" "Mary" Bill "Walt""Ann" "Mike" "Lisa" "Shari" "Jose" "Mary" Bill "Walt"
"Ann" Bill "Jose" "Lisa" "Mary" "Mike" "Shari" "Walt""Ann" Bill "Jose" "Lisa" "Mary" "Mike" "Shari" "Walt"
"Ann" "Mike" Bill "Lisa" "Mary" "Jose" "Shari" "Walt""Ann" "Mike" Bill "Lisa" "Mary" "Jose" "Shari" "Walt"
"Walt" "Shari" "Ann" "Lisa" "Mike" "Jose" "Mary" Bill

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Database Programming With Visual Basic.NET

Authors: Ying Bai

1st Edition

0521712351, 978-0521712354

More Books

Students also viewed these Databases questions

Question

=+8.3(i)). If j is transient, then fi= C PH) /(1+2 Pc)

Answered: 1 week ago