Quiz 5

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

At most, how many entries in a list of 5000 names will be interrogated when using the binary search algorithm? 6 5000 2500 13

13

What sequence of values would be printed if the procedure xxx described below were executed with the value of N being 9? procedure xxx (N) if (N < 4) then (print the value of N; apply the procedure yyy to the value 7) else (apply the procedure yyy to the value 2; print the value of N) procedure yyy (N) if (N < 5) then (print the value of N; apply the procedure zzz to the value 6) else (apply the procedure zzz to the value 5) procedure zzz (N) if (N = 5) then (print the value 7) else (print the value 8) 8, 2, 9 2, 8, 9 None of the above 9, 2, 8

2, 8, 9

When searching for the entry X within the list R, S, T, U, V, W, Z how many entries will be considered before discovering that the entry is not present if you use a binary search? (Note that the list is in alphabetical order.)

3

When searching for the entry X within the list R, S, T, U, V, W, Z how many entries will be considered before discovering that the entry is not present if you use a binary search? (Note that the list is in alphabetical order.) 2 4 This will cause an infinite loop. 3

3

What sequence of values will be printed when the following instructions are executed? X <- 5; while (X < 7) do (print the value of X; X <- X + 1) print the value of X; while (X > 2) do (print the value of X; X <- X - 2) 5, 6, 7, 5, 3 None of the above 5, 6, 7, 7, 5, 3 5, 6, 7, 7, 5, 4

5, 6, 7, 7, 5, 3

With a list of 10,000 entries, how many entries will a successful sequential search algorithm interrogate on average? 10,000 13 1,000 5,000

5,000

At most, how many entries in a list of 5000 names will be interrogated when using the sequential search (or linear search) algorithm? 13 5000 2500 1

5000

When searching for the entry X within the list R, S, T, U, V, W, Z how many entries will be considered before discovering that the entry is not present if you use a sequential search (also known as a linear search)? 8 3 7 4

7

Judging from it's Big-theta representation, which algorithm is fastest for 100,000 ordered items of data? Sequential search Exchange sort Binary search Bubble sort

Binary search

Which algorithm does this describe? This algorithm keeps dividing the data file in half and checking the middle value each time. Exchange sort Binary search Hash sort Sequential search

Binary search

Examine the following recursive procedure: procedure Dodger (N)if (N = 0) then (print the value of N)else (apply the procedure Dodger to the value N - 1) Which procedure invocation would result in the LONGEST execution time? Dodger(-4) Dodger(44) Dodger(0) Dodger(4)

Dodger(-4)

If you were searching the following list using a sequential search... Linda, Maurice, Nathan, Olivia, Pat, Quincy, Regina, Sue, Tom ... which name would you find first? Linda Tom Pat We can't tell frlom the information given

Linda

Describe the shape of the graph of a sequential search represented by the notation O(N). Logarithmic Parabolic Linear Asymptotic

Linear

Look at the following recursive procedure definition and then answer the following question: procedure Roger (N)if (N < 5) then (apply the procedure Roger to the value N + 1)else (print the value of N) Under the assumption that N takes on only integer values, which of the following is the termination condition in the Roger recursive procedure? None of the above N < 4 N > 4 N < 5

N > 4

Describe the shape of the graph of an insertion sort represented by the notation: O(n2) Asymptotic Linear Logarithmic Parabolic

Parabolic

If you were searching the following list using a binary search ... Linda, Maurice, Nathan, Olivia, Pat, Quincy, Regina, Sue, Tom ... which name would you access first?

Pat

The general shape of the graph of an algorithm reveals how an algorithm performs with larger and larger inputs. True False

True

The shape of an algorithm's Big-theta graph is normally based on the algorithm's ... Best-case analysis Worst-case analysis Average-case analysis

Worst-case analysis

Which of the following set of instructions defines an algorithm in the formal, strict sense? X <- 3;while (X < 5) do(X <- X - 1) X <- 3;while (X < 5) do(X <- X + 1) None of those shown here are algorithms X <- 3;while (X < 5) do(X <- X)

X <- 3;while (X < 5) do(X <- X + 1)

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

X <- 5repeat (print the value of X; X <- X + 1)until (X > 6)

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

big-theta(ln n)

The binary search algorithm is an example of an algorithm in which of the following classes? big-theta(n ln n) big-theta(ln n) big-theta(n) big-theta(n * n)

big-theta(ln n)

Which of the following is a representation? algorithm process program none of the above

program

Which of the following are ways of representing algorithms? programming language stepwise refinement flowchart pseudocode

programming language flowchart pseudocode

Which of the following are means of repeating a block of instructions? recursion posttest loop pretest loop if-then-else

recursion posttest loop pretest loop

Match each term to the most appropriate phrase. -algorithm -loop invariant -primitive -procedure -pseudocode -recursion -sequential search -stepwise refinement A. An informal notation for representing algorithms B. A basic building block C. Less efficient than the binary method of searching D. The fundamental concept in computer science E. The technique of applying a program segment within itself F. A statement that is true each time a specific point in a repetitive process is reached G. A divide and conquer approach to problem solving H. A program segment isolated as a unit

D-algorithm F-loop invariant B-primitive H-procedure A-pseudocode E-recursion C-sequential search G-stepwise refinement

Examine the following recursive procedure: procedure Dodger (N)if (N = 0) then (print the value of N)else (apply the procedure Dodger to the value N - 1) Which procedure invocation would result in the SHORTEST execution time? Dodger(0) Dodger(-4) Dodger(44) Dodger(4)

Dodger(0)

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) X <= 5 X >= 5 X < 5 X > 5

X <= 5

Examine the following loop and then answer the question below: while (X < 5) do( . . . ) Under the assumption that X takes on only integer values, which of the following is the termination condition for the following loop? None of the above X < 5 X > 4 X < 4

X > 4

The insertion sort algorithm is an example of an algorithm in which of the following classes? big-theta(n ln n) big-theta (ln n) big-theta(n) big-theta(n*n)

big-theta(n*n)


Ensembles d'études connexes

Indiana State Life and Health Insurance Exam

View Set

Questions I Missed on PMP Practice Exam

View Set

Ch. 32 Antituberculars, Antifungals, Peptides, and Metronidazole

View Set

NUR318 Exam III Study Guide Maternal Health Nursing

View Set

Project Management Ch. 1 Quizzes

View Set

Issues in International Business :)

View Set