Search Header Logo
Linear Search

Linear Search

Assessment

Presentation

Computers

9th - 10th Grade

Practice Problem

Medium

Created by

Chris CHA

Used 4+ times

FREE Resource

3 Slides • 7 Questions

1

Linear Search

2

Linear Search Algorithm

sports = ["soccer", "hockey", "basketball", "archery"]

When data is unsorted, the sensible option when searching for a particular item is to start at the beginning and look at every item until you find the one you want. You could be lucky and find it quickly if it's near the front of the list or you may need to wait if it's near the back.
This is a LINEAR SEARCH.

3

media

Study this code and answer the questions on the next few slides.

Linear Search

4

Multiple Choice

Question image

What is the best description for what happens to found and index in this snippet?

1

They are initialised

2

They are evaluated

3

They are discarded

4

They are mutated

5

Multiple Choice

Question image

What is the best description of the control structures in this code snippet?

1

An iteration with another iteration nested inside.

2

A sequence of selections and a nested iteration.

3

An iteration with two selections inside

4

A selection with two iterations nested inside

6

Multiple Select

Question image

What happens to the index variable on each iteration of the REPEAT...UNTIL loop?

1

It's value does not change

2

It is used to determine which element of the list is examined

3

It is used to determine if there are no more elements left in the list to examine

4

It is increased by 1 on each iteration

7

Multiple Choice

Question image

list = ["Tim", "Kate", "Ali", "Gayle"]

If target is "Gayle", what would be the value of index when found is assigned the value True?

1

4

2

3

3

2

4

1

8

Multiple Choice

Question image

What is the best description for this selection block?

1

Compares index to list length to see if the loop has reached the end of the list. It will exit the loop using BREAK

2

Compares index to target to see if the loop has become less than the length of the list. It will BREAK from looping until the target is found.

3

Compares index to list length then BREAKs into another iteration and selection until the target is found.

4

Compares index to list length and then BREAKS the processor in half demanding that target is found.

9

Multiple Choice

Question image

What is the best description for this selection block?

1

If the list item at the current index is the same as the target it BREAKS out of the loop

2

If the list item at the current index is not the same as the target it BREAKS out of the loop and sets found to False

3

If the list item at the current index is the same as the target it BREAKS out of the loop and sets found to True

4

If the list item at the current index is the same as the target it sets found to True and then BREAKS out of the loop

10

Multiple Choice

Question image

list = ["Jim", "Barolo", "Guiseppe", "Arlan"]

If target was Barolo, what would the output be?

1

Target not found in the list

2

Target found at index index

3

Target found at index 0

4

Target found at index 1

Linear Search

Show answer

Auto Play

Slide 1 / 10

SLIDE