Save
Computer science OCR A Level
2.3.4 Searching Algorithms
Save
Share
Learn
Content
Leaderboard
Share
Learn
Created by
Aanya Sinha
Visit profile
Cards (20)
What are searching algorithms used for?
To find a specified
element
in data
View source
Why are different searching algorithms used?
They suit particular
data structures
and scenarios
View source
What is a requirement for using binary search?
Data must be
sorted
View source
How does binary search determine which side of data to search?
By finding the
middle element
and
comparing
View source
What happens to the data in each iteration of binary search?
Half of the
input data
is
discarded
View source
What is the time complexity of binary search?
O(log n)
View source
What is the pseudocode for binary search?
A =
Array
of data
x =
Desired
element
low
= 0
high
= A.length - 1
while low <= high:
mid
= (low + high) / 2
if A[mid] == x: return mid
else if A[mid] > x: high = mid - 1
else: low = mid + 1
return
“Not found in data”
View source
What is the middle position calculated in the first step of searching "Dylan"?
4
View source
What do we do when the middle element is higher than the desired element?
Discard the
upper
half of the data
View source
What is the final position returned when "Dylan" is found?
3
View source
What happens when low exceeds high in the binary search process?
The
algorithm
returns “Not found in data”
View source
How does binary search compare to linear search in efficiency?
Binary search is more efficient
It halves the search space each
iteration
Linear search checks each element sequentially
View source
What is the time complexity of linear search?
O(n)
View source
What is a key characteristic of linear search?
It does not require
sorted
data
View source
What is the pseudocode for linear search?
A =
Array
of data
x =
Desired
element
i = 0
while
i < A.length:
if A[i] == x:
return
i
else: i = i + 1
return “Not found in data”
View source
How does linear search compare to binary search in terms of efficiency?
Linear search is less efficient
It checks each
element
one by one
Binary search halves the
search space
View source
What is the main disadvantage of linear search?
It can be incredibly
inefficient
View source
How does the algorithm behave when searching for "R" in the alphabet?
It shows less efficiency than
binary search
View source
What is the main characteristic of linear search regarding data structure?
It can work with
unsorted
data
View source
How does the efficiency of linear search change with data size?
It
becomes
slower
as
data
size
increases
View source