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.
19.6.1. Sorting and Scanning
This section
Practice test
11 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 is a greedy algorithm?
Hint
Think about local vs global decisions.
- 2.
Why is it important to sort the bookings by finish time?
Hint
Consider how we check for overlaps.
- 3.
What is the fundamental principle of greedy algorithms?
- Choose the earliest start time
- Make local optimal choices
- Select the longest interval
Hint
Think about the nature of greedy decision making.
- 4.
True or False: Greedy strategies always produce optimal solutions.
- True
- False
Hint
Recall the counterexamples discussed in class.
- 5.
Assume you have the following time slots: [1, 4], [3, 5], [2, 6], [5, 7]. Find the maximum number of non-overlapping intervals using a greedy approach and explain your reasoning.
Hint
Sort by finish time and choose accordingly.
- 6.
Given a larger set of bookings, design and describe a more efficient timeline visualization for the above problem to help quickly identify non-overlapping slots.
Hint
Think about graphical representations for clarity.
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
1 more question available
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