Tskafli5

15 Questions | Attempts: 342
Share

SettingsSettingsSettings
Tskafli5 - Quiz

Spurningar úr kafla 5


Questions and Answers
  • 1. 

    The binary search algorithm is an example of an algorithm in which of the following classes?

    • A.

      O(n^2)

    • B.

      O(lg n)

    • C.

      O(n)

    • D.

      O(n lg n)

    Correct Answer
    B. O(lg n)
  • 2. 

    Which of the following is a representation?

    • A.

      Process

    • B.

      Algorithm

    • C.

      Program

    Correct Answer
    C. Program
  • 3. 

    Which of the following is a loop invariant at the point at which the test for termination is performed in the following loop structure? X <-- 3; repeat (X <-- X + 2) until (X > 5)

    • A.

      X < 8

    • B.

      X =< 6

    • C.

      X >= 5

    • D.

      X > 5

    Correct Answer
    A. X < 8
  • 4. 

    Under the assumption that X takes on only integer values, which of the following is the termination condition for the following loop? While (X < 5) do (....)

    • A.

      X < 5

    • B.

      X > 4

    • C.

      X < 4

    Correct Answer
    B. X > 4
  • 5. 

    When searching within the list: Lewis, Maurice, Nathan, Oliver, Pat, Quincy, Roger, Stan, Tom. which of the following entries will be found most quickly using the binary search algorithm?

    • A.

      Pat

    • B.

      Tom

    • C.

      Lewis

    Correct Answer
    A. Pat
  • 6. 

    Which of the following is an activity?

    • A.

      Process

    • B.

      Program

    • C.

      Algorithm

    Correct Answer
    A. Process
  • 7. 

    Which of the following set of instructions defines an algorithm in the formal, strict sense? x <-- x +1. The other 2 create an infinite loop. The definition of algorithm states that it has to terminate. a. X <-- 3;  while (X < 5) do  (X <-- X – 1) b. X <-- 3;  while (X < 5) do  (X <-- X) c. X <-- 3;  while (X < 5) do  (X <-- X + 1)  

    • A.

      A

    • B.

      B

    • C.

      C

    Correct Answer
    C. C
    Explanation
    x

    Rate this question:

  • 8. 

    The insertion sort algorithm is an example of an algorithm in which of the following classes?

    • A.

      O(lg n)

    • B.

      O(n)

    • C.

      O(n lg n)

    • D.

      O(n^2)

    Correct Answer
    D. O(n^2)
  • 9. 

    Which of the following is not a way of representing algorithms?

    • A.

      Psuedocode

    • B.

      Flowchart

    • C.

      Stepwise refinement

    • D.

      Programming language

    Correct Answer
    C. Stepwise refinement
  • 10. 

    When searching within the list: Lewis, Maurice, Nathan, Oliver, Pat, Quincy, Roger, Stan, Tom. which of the following entries will be found most quickly using the sequential search algorithm? 

    • A.

      Tom

    • B.

      Pat

    • C.

      Lewis

    Correct Answer
    C. Lewis
  • 11. 

    Which of the following is not a means of repeating a block of instructions?

    • A.

      Posttest loop

    • B.

      Pretest loop

    • C.

      Recursion

    • D.

      Assignment statement

    Correct Answer
    D. Assignment statement
  • 12. 

    Which of the following does not print the same sequence of numbers as the others? a. X <-- 5while (X<6) do (print the value of X;X<-X+1while (X < 6) do (print the value of X; X <-- X + 1)   b. X <-- 5 repeat (print the value of X;X <-- X+1 until (X>6)repeat (print the value of X; X <-- X + 1)until (X > 6)   c. X <-- 4 while (X<5) do (X <-- X +1; print the value of X) while (X < 5) do ( X <-- X + 1; print the value of X )  

    • A.

      A

    • B.

      B

    • C.

      C

    Correct Answer
    B. B
    Explanation
    a .X

    Rate this question:

  • 13. 

    Which of the following is a loop invariant at the point at which the test for termination is performed in the following loop structure? X <-- 3; while (X < 5) do (X <-- X + 2)

    • A.

      X >= 5

    • B.

      X < 5

    • C.

      X > 5

    • D.

      X =< 5

    Correct Answer
    D. X =< 5
  • 14. 

    Preconditions, postconditions, and loop invariants are examples of which of the following?

    • A.

      Recursion

    • B.

      Pseudocode

    • C.

      Assertions

    • D.

      Iterative structures

    Correct Answer
    C. Assertions

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Oct 30, 2013
    Quiz Edited by
    ProProfs Editorial Team
  • Nov 28, 2012
    Quiz Created by
    Viddz1
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.