Set #4

The following questions make up Set #4 of the Untimed Practice Exam Questions. The questions resemble, both in format and substance, what you might see on the AP CS Principles exam. You should finish these questions within 17 minutes to satisfy the time constraints of the AP exam. You may refer to the AP CS Reference Sheet, which can be found here.

You will not be able to change your answers after you hit the “Finish Exam” button.

    25-4-1: Which of the following is true about linear and binary search?

  • Linear search is more efficient for large data sets than binary search.
  • Incorrect. Linear search will generally take longer since it looks at one element at a time.
  • Binary search does not work on ordered lists.
  • Incorrect. Binary search can only be used on ordered sets.
  • Linear search looks at one element at a time.
  • Correct. Linear search looks at just one element at a time.
  • Binary search is better for smaller lists.
  • Incorrect. Linear search is generally preferred for smaller data.

    25-4-2: Which of the following statements is NOT true?

  • An unsolvable problem cannot be solved using any algorithm.
  • Incorrect. If a problem is unsolvable, not even an algorithm can solve it.
  • A solvable problem can be solved using an algorithm.
  • Correct. An algorithm can solve an a solvable problem.
  • Some solvable problems will not run in reasonable time.
  • Incorrect. Some solvable problems will take long to solve with an algorithm and will, therefore, not run in reasonable time.
  • An unsolvable problem can be solved using an algorithm.
  • Incorrect. If a problem is unsolvable, an algorithm will not solve it.

    25-4-3: Which of the following is NOT true about a program?

  • Instructions may involve variables which may change or be output from the program.
  • Incorrect. A program can have variables which may be changed or be output by the program.
  • Instructions are processed sequentially.
  • Incorrect. Code in a program is read sequentially line by line.
  • A program always has a return value.
  • Correct. A return value is not a necessity for a program.
  • A program automates processes in a computer.
  • Incorrect. A program is an automated process that runs on a computer.

    25-4-4: Imagine you want to create a procedure to find and print the smallest item in a list. Take the code below for example:

    PROCEDURE showMin(aList)
    
     {
      min ← 0
    
      FOR EACH item IN aList
    
       {
        if (min > item)
    
         {
                 min ← item
         }
       }
      DISPLAY(“smallest item in list is “ + min)
     }
    

    In what situation would this procedure fail to correctly display the minimum?

  • In no situation; this procedure works as intended
  • Incorrect. This procedure does not work in every case.
  • In all situations; this procedure will DISPLAY the maximum, not the minimum
  • Incorrect. This code does obtain a minimum value, but fails to do so under certain circumstances.
  • If every item in the list is greater than zero
  • Correct. If every item in the list is positive, "min" never gets updated because it is initialized to 0 and every value in the list is being compared to it.
  • If every item in the list is less than zero
  • Incorrect. The code will work as intended if every value is negative.

    25-4-5: Which of the following is NOT true about abstraction?

  • Abstraction reduces or removes details to help understand something new.
  • Incorrect. Abstraction removes unnecessary information that is not needed to understand something.
  • A lower-level abstraction is less specific than a higher-level abstraction.
  • Correct. The opposite is true. A lower the level of abstraction means there is more detail.
  • Abstraction helps you manage the details and code of a program.
  • Incorrect. Abstraction is a way of managing details because it emphasizes the details that are relevant.
  • Lower-level abstractions can be combined to make higher-level abstractions.
  • Incorrect. Since lower-level abstractions are more detailed, they cannot be combined to make higher-level abstractions.

    25-4-6: Which of the following is NOT true?

  • All digital data is an abstraction.
  • Incorrect. Digital data is represented by different levels of abstractions.
  • All data eventually becomes binary digits (bits) that the computer interprets.
  • Incorrect. Computers read binary digits to interpret data.
  • Programming commands are a source of bits.
  • Incorrect. Commands are data which can be broken down into bits.
  • Abstractions occur only in hardware applications.
  • Correct. Abstractions occur in software applications.

    25-4-7: Which of the following is most likely to be a part of a phishing attack?

  • Someone using your social media information to show you specific advertisements.
  • Incorrect. Although your personal information is being used in this situation, showing specific advertisements is not considered phishing.
  • Someone requesting your personal information through an online chat room.
  • Correct. Phishing involves someone else trying to obtain personal information from you through electronic communication.
  • Clicking a button that results in all of your passwords being open to hackers.
  • Incorrect. Although your sensitive information is being revealed, this is not phishing because there is not another person disguising themselves as a trustworthy source.
  • Having all of your email accounts deleted from too many failed login attempts
  • Incorrect. This is not phishing because there is no one trying to steal personal information from you.

    25-4-8: Which of the following is true?

  • Converting data from one file type to another usually comes at a cost.
  • Correct. For example, you may lose the ability to edit a document when you convert to a PDF file.
  • Data is never lost in conversion.
  • Incorrect. For example, the quality of a photo may decrease when you convert from JPG to PNG.
  • Data is never changed in conversion.
  • Incorrect. Data may lose readability in conversion and may be changed as a result.
  • Data can always be converted without a loss.
  • Incorrect. There are instances in which data is lost through conversion.

    25-4-9: Which of the following is most likely an example of an overflow error?

    (A)
    
    z ← ⅓
    
    
    (B)
    
    z ← 1/0
    
    
    (C)
    
    nums ← (1, 2, 3)
    
    n ← 0
    
    REPEAT 4 TIMES
    
    n ← n + 1
    
    DISPLAY(nums(n))
    
    
    (D)
    
    n ← 0
    
    REPEAT UNTIL NOT n = 0
    
    n ← n * 100
    
  • Correct. This is a repeating decimal which will result in an overflow error.
  • Incorrect. Though the solution is undefined, it will not result in an overflow error.
  • Incorrect. This will not result in an overflow error but rather a value error.
  • Incorrect. This will result in an infinite loop.

    25-4-10: Which of the following statements is true?

  • Problems that have a “yes” or “no” answer for all inputs are called decidable.
  • Correct. A decidable problem is solvable.
  • Problems that have a “yes” or “no” answer for all inputs are called undecidable.
  • Incorrect. If a problem is solvable, it cannot be undecidable.
  • Undecidable problems always have a solution.
  • Incorrect. It is impossible to construct an algorithm that solves an undecidable problem.
  • Problems that cannot be solved with an algorithm are called solvable.
  • Incorrect. Problems than cannot be solved with an algorithm are called unsolvable.

    25-4-11: Which of the following correctly converts 167 to the binary number system? (Hint: Binary numbers have place values that are powers of 2.)

  • 11100101
  • Incorrect. 11100101 = (1 × 2⁷) + (1 × 2⁶) + (1 × 2⁵) + (0 × 2⁴) + (0 × 2³) + (1 × 2²) + (0 × 2¹) + (1 × 2⁰) = 229
  • 10100111
  • Correct. 10100111 = (1 × 2⁷) + (0 × 2⁶) + (1 × 2⁵) + (0 × 2⁴) + (0 × 2³) + (1 × 2²) + (1 × 2¹) + (1 × 2⁰) = 167
  • 0000111
  • Incorrect. 0000111 = (0 × 2⁶) + (0 × 2⁵) + (0 × 2⁴) + (0 × 2³) + (1 × 2²) + (1 × 2¹) + (1 × 2⁰) = 7
  • 1010101
  • Incorrect. 1010101 = (1 × 2⁶) + (0 × 2⁵) + (1 × 2⁴) + (0 × 2³) + (1 × 2²) + (0 × 2¹) + (1 × 2⁰) = 85

    25-4-12: Algorithms will exponential behavior (e.g. x^n) are:

  • Expected to run in reasonable time
  • Incorrect. Algorithms with exponential will continually change over time.
  • NOT expected to run in reasonable time
  • Correct. Since an exponential function is continually changing, it may not run in reasonable time.
  • Impossible to calculate
  • Incorrect. They can be solved for a specific value.
  • Easier to do by hand
  • Incorrect. It is not necessarily easier to calculate by hand.

    25-4-13: Data compression that allows for all of the original data to be retrieved is called:

  • Lossy
  • Incorrect. Data is lost in lossy compression.
  • Lossless
  • Correct. All original data can be retrieved through lossless compression.
  • Data manipulation
  • Incorrect. Data manipulation is not a specific form of data compression.
  • Sticky
  • Incorrect. There is no such thing as sticky data compression.

    25-4-14: A group of two or more systems linked together is called:

  • The internet
  • Incorrect. The internet is the global system of connected computer networks.
  • A network
  • Correct. A network is a group of multiple systems.
  • A model
  • Incorrect. A model represents the relationship between elements or objects.
  • Memory
  • Incorrect. Memory is the storing of information.

    25-4-15: What is the value of n after the above code executes?

    i ← 1
    
    n ← 2
    
    REPEAT until i = 4
    
      {
      n ← n * 2
    
      i ← i + 1
      }
    
  • 0
  • Incorrect. The value of n increases every time this code repeats.
  • 22
  • Incorrect. The block of code will repeat 3 times and the value of n will be 16. If it repeats a fourth time, n would equal 32.
  • 16
  • Correct. The block of code will repeat 3 times and the value of n will be 16.
  • 4
  • Incorrect. The value of n equals 4 after repeating one time, but the block of code will repeat until i = 4.
You have attempted of activities on this page