Training high school teachers to teach AP Computer Science Principles
Select Page
Algorithms Quiz
Results
#1 What is the time complexity of f(n) in terms of Big-O-Notation?
O(n^6)
O(n^4)
O(n^7)
#2 The picture depicts a sorting technique called?
Insertion Sort
Selection Sort
Merge Sort
Quick Sort
#3 There are two bulbs A and B. ON(A) – represents that the bulb A is ON OFF(A) – represents that the bulb A is OFF Similarly, ON(B) and OFF(B) represents the ON and OFF states of bulb B respectively. Which of the following Boolean expression is true? (Consider ON state as True and OFF state as False)
( ON(A) AND OFF(B) ) OR ( OFF(A) AND ON(B) )
( OFF(A) AND OFF(B) ) OR ( ON(A) AND OFF(B) )
( ON(A) AND ON(B) ) OR ( OFF(A) AND OFF(B) )
( OFF(A) AND OFF(B) ) OR ( OFF(A) AND ON(B) )
#4 Which of the following is false about algorithms?
Algorithms are building blocks of computer programs. They are as important to programming as recipes are to cooking.
We write an algorithm after the execution of a program to maintain proper documentation.
Algorithms are sequence of steps which are textual or mathematical in nature.
Algorithm is a procedure that takes input and produces output.
#5 Algorithm A has a time complexity of O(n^2 ) and Algorithm B has a time complexity of O(n) where n is an integer such that n > 0. If both the algorithms are made to run at the same time on two different machines that have exactly same features, which algorithm halts first?
Algorithm A
Algorithm B
Both algorithms A and B halt at the same time.
Cannot be determined
#6 Choose the algorithm
(i) is correct
(ii) is correct
Both (i) and (ii) are correct
Neither of them is correct
#7 Consider the following insertion sort program. How will the array “a” look like after the first iteration of the for loop?
5, 4, 3, 20, 10
4, 5, 3, 20, 10
. 4, 4, 3, 20, 10
4, 3, 5, 20, 10
#8 In which of the following sorting techniques, does the last element of the array get sorted first?
Bubble sort
Insertion sort
Merge sort
Quick sort
#9 What is the time complexity of the above code? (v4)
O(nlogn)
O(n)
O(n * (logn)^2)
O((n^2) * logn)
#10 Which of the following statements is true about Average case time complexities of the given sorting algorithms?
(i) and (iv)
(ii) and (iii)
(i) and (ii)
(iii) and (iv)
#11 Following is a code segment for Selection sort. Analyze the code and determine the final array ‘ a ‘.
{0, 12, 13, 14, 15, 30, 55, 77, 100}
{100, 77, 55, 30, 15, 14, 13, 12, 0}
{100, 15, 13, 30, 12, 55, 0, 14, 77}
{77, 14, 0, 55, 12, 30, 13, 15, 100}
next
#12 What is the output of the following code segment which does binary search. Here, ‘a’ is an array and “target” is an integer element we are searching for in the array.
Target not found! Thank you!
Target found! And its index in array is: 7 Thank you!
Target found! And its index in array is: 6 Thank you!
Target found! And its index in array is: 6
#13 In the picture below, the arrow represents a robot. The robot can move in the white square boxes but not in the black colored region. Which of the following code segments can move the robot to the blue colored square?