logo

Crowdly

Looking for test answers and solutions? Browse our comprehensive collection of verified answers for at moodle.lsu.edu.

Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!

Consider the sort method shown below for selection sort:

public static void sort(int[] a)

{

   for (int i = 0; i < a.length – 1; i++)

   {

      int minPos = minimumPosition(i);

      swap(minPos, i);

   }

}

Suppose we modify the call to the swap method call to read swap(i, minPos). What would be the result? 

0%
100%
0%
0%
View this question

Consider the sort method shown below for selection sort:

public static void sort(int[] a)

{

   for (int i = 0; i < a.length – 1; i++)

   {

      int minPos = minimumPosition(i);

      swap(minPos, i);

   }

}

Suppose we modify the loop condition to read i < a.length. What would be the result? 

100%
0%
0%
0%
View this question

In each iteration, selection sort places which element in the correct location? 

0%
0%
0%
100%
View this question

What type of algorithm places elements in order?

0%
0%
100%
0%
View this question

If a recursive method does not simplify the computation within the method and the base case is not called, what will be the result? 

0%
100%
0%
0%
View this question

____ recursion can occur when a recursive algorithm does not contain a special case to handle the simplest computations directly. 

0%
0%
0%
100%
View this question

Consider the following recursive code snippet:

public int mystery(int n, int m) 

{

   if (n == 0)

   {

      return 0;

   }

   if (n == 1)

   {

      return m;

   }

   return m + mystery(n - 1, m);

}

What parameter values for n would cause an infinite recursion problem in the following method?

100%
0%
0%
0%
View this question

A recursive method without a special terminating case would _________ 

0%
100%
0%
0%
View this question

 If recursion does not have a special terminating case, what error will occur? 

0%
0%
100%
0%
View this question

Insert the missing code in the following code fragment. This fragment is intended to recursively compute xn, where x and n are both non-negative integers:

public int power(int x, int n)

{

   if (n == 0)

   {

      ____________________

   }

   else

   {

      return x * power(x, n - 1);

   }

}

0%
100%
0%
0%
View this question

Want instant access to all verified answers on moodle.lsu.edu?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!