Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Course: Easy-to-follow Java programming

The quiz questions


Answer the questions below to review what you have learned in Video 4. You will
find the right answers after the questions in the solution section.

1. Which algorithms did we learn about? Select the ones that were in video 4.

sum

having fun

count

linear search

reverse

selection

maximum

binary search

minimum

sorting

median

2. Put the name of the algorithms in front of the description.

Selects the smallest element of a series of elements.

Counts the elements that meet a certain requirement.

Selects the biggest element of a series of elements.

You would like to remove all the jokers from a hand of cards.

Duckademy IT courses – www.duckademy.com


We combine the elements with each other, and with the help of
functions (e.g. addition, multiplication, etc.) we create another
element out of them.

Computes the position of a certain element within a series of


elements (if it is in the series at all).

3. Put the missing instruction into the following general code of counting.

int count = 0;
int number;
iterate over the numbers (for, while or do-while)
number = ...;
if (number is OK)
;
end of iteration

4. What should we change in the following general code of maximum to


become minimum?

int number = ...;


int max = number;
int maxPosition = 1; // first number is the maximum
iterate over the numbers (for, while or do-while)
number = ...;
if (number > max) {
max = number;
maxPosition = i;
}
end of iteration

5. Put the missing instruction into the following general code of linear
search.

int key = ...;


int position = -1;
iterate over the numbers until not found AND not finished
number = ...;
if ( == ) {
position = ;
}
end of iteration

6. How do you create an integer constant with the value of 6?

SIZE = ;

Duckademy IT courses – www.duckademy.com


----------------------------------------------------------------------------------------------------------------

The answers

1. Which algorithms did we learn about? Select the ones that were in video 4.

X sum

having fun

X count

X linear search

reverse

X selection

X maximum

binary search

X minimum

sorting

median

2. Put the name of the algorithms in front of the description.

minimum Defines the smallest element of a series of elements.

count Counts the elements that meet a certain requirement.

maximum Defines the biggest element of a series of elements.

select You would like to remove all the jokers from a hand of cards.

sum We combine the elements with each other, and with the help of
functions (e.g. addition, multiplication, etc.) we create another
element out of them.

linear search Computes the position of a certain element within a series of


elements (if it is in the series at all).

Duckademy IT courses – www.duckademy.com


3. Put the missing instruction into the following general code of counting.

int count = 0;
int number;
iterate over the numbers (for, while or do-while)
number = ...;
if (number is OK)
count++;
end of iteration

4. What should we change in the following general code of maximum to


become minimum?

int number = ...;


int min = number;
int minPosition = 1; // first number is the maximum
iterate over the numbers (for, while or do-while)
number = ...;
if (number < min) {
min = number;
minPosition = i;
}
end of iteration

5. Put the missing instruction into the following general code of linear
search.

int key = ...;


int position = -1;
iterate over the numbers until not found AND not finished
number = ...;
if (number == key) {
position = i;
}
end of iteration

6. How do you create an integer constant with the value of 6?

public static final int SIZE = 6;

Duckademy IT courses – www.duckademy.com

You might also like