Recursion
Sorts
Functions
Classes
Arrays
100

What is the name of a condition that appears at the very inside of a recursion method to stop the recursion?

What is a base case?

100

What sorting method uses checks that make direct comparisons between two numbers and swaps the larger term up in the list, essentially "floating" the largest numbers higher?

What is bubble sort

100

What is the name of a criterion put into a method as an initial condition?

What is a parameter?

100

What is the name of a class that inherits attributes from another class by extending it?

What is a subclass?

100

Observe the following code:

int[] nums = new int[3];

How long is the list?

3 integers long.

200

What would happen if a recursive method had no base case?

It would repeat forever.

200

What is the name of the number used for comparisons in quick sort?

What is a pivot?

200

What is another name for a function commonly used in the APCS term list?

What is a method?

200

What is the most parent class of the parent classes?

Object

200

Observe the following code:

int[] nums = new int[];

How long is the list?

10 integers long.

300

4.   Consider the following recursive method. 

public void printStars(int n)

{

  if(n==1)

    System.out.println("*");

  else

  {

    System.out.print("*");

    printStars(n-1)

  }

}

What will be printed when printStars(4) is called?

****

300

Are selection sorts as efficient, more efficient, or the same efficiency as insertion sorts when the lists get into very large sizes?

They are the same (both go to n^2)

300

Declare an integer num equal to 0 that exists INSIDE a method.

int num = 0;

300

Declare an empty class named Question.

public class Question

{

}

300

Which is easier to change the size of, an ArrayList or an array?

ArrayList

400

What will return from factorial(3)?


public int factorial(int n) {

  //baes case

  if(n==0 || n==1)

    return 1;


    return n*factorial(n-1);

}


6

400

Look at this list:

{7,8,2,4,6,3}

What would it look like after the first step in a quicksort?


{2,4,6,3,7,8}

400

What do you call the process of making classes made several times to take in different types of parameters?

What is overloading?

400

Are interfaces abstract?

They are implicitly abstract.

400

What method would you get the size of an ArrayList?

ArrayList.size();

500

We have a number of bunnies and each bunny has two big floppy ears. We want to compute the total number of ears across all the bunnies recursively (without loops or multiplication). Write the missing line of code.


public int bunnyEars(int bunnies) {

  //base case

  <<MISSING CODE>>

    return 0;

  else

    return 2 + bunnyEars(bunnies-1);

}

if(bunnies ==0)

500

The algorithm below can best be described as:

public static int mystery(int[] array, int a)

{

  int low = 0;

  int high = array.length-1;

  while(low<=high)

  {

    int mid = (high + low)/2;

    if(a< array[mid])

      high = mid-1;

    else if(a>array[mid])

      low = mid +1;

    else

      return mid;

  }

  return -1

}

Binary Search

500

What number for the parameter will produce a result of __?

public boolean only14(int[] nums) {

  boolean hasYucky = true;

  for(int i = 0; i<nums.length;i++)

  {

    if(nums[i]!=1&&nums[i]!=4)

      hasYucky = false;

  }

  return hasYucky;

}



If an array only contains 14's 

500

Where does an abstract method in a superclass gets called into a concrete method?

Inside of a subclass (child)

500

This array fills itself with int of the position inside the list. Replace the missing line of code.

public int[] fizzArray(int n) {

  int[]array=new int[n]; 

  for(int i = 0; i<n; i++)

  {

    //Make the arraylist at the position into that integer.

    <<MISSING CODE>>

  }

  

  return array;

}

array[i] = i;