Enrol to start learning
Reading is open to everyone. Enrolling is free, and it is what unlocks the audio lessons, practice tests and progress tracking.
10.1. Searching in an array
This section
Practice test
10 questions on this section. Wrong answers show you what to read again.
Sign up to take itWhole chapter
Revision test
Mixed questions from across the chapter. Your answers get marked.
Sign up to take itQuick
Flashcard drill
3 cards from this lesson. Good the night before a test.
Try these first
- 1.
What does linear search focus on when trying to find an element in an array?
Hint
Think about how you would manually search for a number on a list.
- 2.
What is the primary requirement for binary search to function correctly?
Hint
Consider how binary search determines where to look next.
- 3.
What is the primary advantage of binary search over linear search?
- It's faster since it uses less time on average.
- It's easier to implement.
- It's better for unsorted arrays.
Hint
Remember the time complexities we've discussed.
- 4.
True or False: Linear search can be applied to both sorted and unsorted arrays.
- True
- False
Hint
Think about the general approach of linear search.
- 5.
You are given an unsorted array of integers: [14, 3, 7, 8, 1, 2]. Design a function to apply linear search to find the index of number 7. What is the expected output and explain your steps?
Hint
Iterate over the array one element at a time.
- 6.
Given a sorted array [1, 3, 5, 7, 9, 11] and needing to find the number 8 using binary search, outline the steps of the algorithm.
Hint
Keep applying the midpoint logic and eliminate half of the search space each time.
Exercises
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
4 more questions available
Enrol freeQuiz
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
Get your answers marked and your progress tracked
Enrol freeChallenge Problems
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting