# E-learning -- Algorithms and Binary Search -- Test B

## Pre-test: Algorithms

### What is an algorithm?

• An algorithm is a set of step-by-step instructions for solving a problem or completing a task.
• An algorithm is a term used in the field of math, which is usually used in equation solving.
• An algorithm is a fact people need to memorize.

### When can we use algorithms to solve problems?

• We use algorithms to solve problems in some fields such as math, physics, chemistry... etc.
• Using algorithms to solve problems has been widely applied in our lives. We can use algorithms to solve everyday problems.
• We use algorithms to solve high-technology problems.

### The difference between a linear search and a binary search is:

• A binary search
looks for a value by checking the element in the middle of an array
• A linear search
looks for a value in a linear sequence

### What are algorithms and why are they important?

#### Are the efficiencies of algorithms measurable?

• Yes, the efficiencies of algorithms are measurable. However, the majority of the algorithms have the same efficiency.
• Yes, the efficiencies of algorithms are measurable. Some of the algorithms are more efficient than others.
• No, the efficiencies of algorithms are NOT measurable.
• No, only a few algorithms can be measured.

### Algorithms --- Problem Solving and Computational Thinking

#### Before you learn about the binary search,  please complete the following question as a pre-test --- put the sentences in correct order to indicate how we use binary research to locate a value/item in a sorted collection/list.

• Find the maximum value and the minimum value of a sorted collection/list.
• Get the average of the maximum value and the minimum value.
• If the average number is lower than the item/value you need to locate, set the minimum number to be one larger than the average number. If the average number is higher than the item/value you need to locate, set the maximum number to be one smaller than the average number.
• Repeat the present two steps until you locate the item/value.

## Binary Search

### Binary search and linear search

#### Binary research works by repeatedly dividing in half the portion of the list that could contain the item until you've narrowed down the possible locations to just one. Linear research sequentially moves through a list looking for the item.In the guessing game you played, which algorithm is more efficient to locate the number?

• Binary search
• Linear search

### Question 1

#### When we use sorting algorithm to solve problems in the real world, can we set the minimum number to be an integer other than 1?

• No, the minimum number has to be 1.
• Yes, the minimum number can be an integer other than 1.

• 1
• 2
• 3
• 4
• 5
• 6
• 7
• 8
• 9
• 10

## Quiz

### What is an algorithm?

• An algorithm is a set of step-by-step instructions for solving a problem or completing a task.
• An algorithm is a term used in the field of math, which is usually used in equation solving.
• An algorithm is a fact people need to memorize.

### When can we use algorithms to solve problems?

• We use algorithms to solve problems in some fields such as math, physics, chemistry... etc.
• Using algorithms to solve problems has been widely applied in our lives. We can use algorithms to solve everyday problems.
• We use algorithms to solve high-technology problems.

### What is linear search?

• A linear search repeatedly divide in half the portion of the list that could contain the item.
• A linear search sequentially moves through your collection (or data structure) looking for a matching value.

### The maximum number of comparisons the linear search performs in searching a value in an array of size N is N.

• The maximum number of comparisons the linear search performs in searching a value in an array of size N is N.
• The maximum number of comparisons the linear search performs in searching a value in an array of size N is NOT N.

### The binary search does not work unless the array is sorted.

• The binary search does not work unless the array is sorted.
• The binary search works when the array is unsorted.

### The difference between a linear search and a binary search is:

• A binary search
looks for a value by checking the element in the middle of an array
• A linear search
looks for a value in a linear sequence

• 1
• 2
• 3
• 4
• 5
• 6
• 7
• 8
• 9
• 10