Save
...
computational thinking
mod3
linear
Save
Share
Learn
Content
Leaderboard
Share
Learn
Created by
emily d
Visit profile
Cards (32)
best-case
scenario: smallest
possible
number of steps eg
1st
in list
worse-case scenario
:
largest
possible number of
steps
eg last in list
Linear Search
sequentially checks each
element
in the list until it finds a
match
or exhausts the list
What is a linear search?
A method to iterate through a
collection
View source
What is the runtime complexity of a linear search?
Big O
of n
View source
How does the size of the data set affect a linear search?
The number of steps increases
proportionately
View source
What is a disadvantage of a linear search?
They are slow for
large data sets
View source
What is an advantage of a linear search?
They are fast for small to medium
data sets
View source
What type of data structures are linear searches useful for?
Data structures without
random access
View source
What is the basic structure of a linear search function?
Loop through the
array
Check each element against the value
Return the
index
if found
Return -1
if not found
View source
What is the initial value of the index in a linear search?
Zero
View source
What happens if the value is found in a linear search?
The
index
of the value is returned
View source
What is returned if the value is not found in a linear search?
Negative one
View source
What will the output be if searching for the number ten?
Element not found
View source
What are the key characteristics of a linear search?
Iterates
through elements one at a time
Slow for
large data sets
Fast for
small to medium data sets
Does not require sorted data
View source
Why is it beneficial that linear searches do not need sorted data?
It simplifies the
search process
View source
How does a linear search compare to binary and interpolation searches?
Linear searches do not require
sorted
data
View source
What type of search is described in the study material?
Linear search
View source
What are the steps of the linear search algorithm?
Start at the beginning of the
list
.
Check each item one at a time.
If the current item is the
target
, stop.
If the end of the list is reached without finding the target, conclude it is not present.
View source
What should you do at the beginning of the linear search?
Start at the
beginning
of the
list
View source
How does the linear search check items?
It
checks
each
item
one
at
a
time
View source
What happens if the current item is the target during a linear search?
You stop the search
View source
What should you do if you reach the end of the list without finding the target?
Conclude it is not
present
View source
What are the key characteristics of a linear search?
Simple and straightforward
Checks each item
sequentially
Inefficient for large
datasets
Best for
small
or
unsorted
lists
View source
What is the stopping condition for the linear search?
Finding the
target item
or reaching the end
View source
What does it mean if the current item is the target during the search?
It
matches
the item you are
looking
for
View source
What is the final step if the target is found?
Stop the
search
View source
What is the significance of the term "target" in the context of the linear search?
It refers to the item being
searched
for
View source
How does the linear search algorithm handle large datasets?
It becomes
inefficient
View source
What is the main limitation of a linear search?
It is inefficient for large
datasets
View source
Why might a linear search be preferred for small lists?
It
is
simple
and
straightforward
View source
What is the overall process of a linear search?
Sequentially
check each item until found
View source