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.
3.2. Brute Force Algorithm
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 common subword?
Hint
Think about what part of the words is the same.
- 2.
How does a brute force algorithm work?
Hint
Consider a systematic approach to find matches.
- 3.
What is the aim of the brute force algorithm in this context?
- To find the longest common subword
- To sort the strings
- To compare character frequencies
Hint
Remember the problem we are trying to solve.
- 4.
Brute force algorithms have a complexity of O(m * n^2).
- True
- False
Hint
Reflect on how many iterations are required.
- 5.
Implement a brute force solution in Python to find the longest common subword.
Hint
Consider breaking your code into smaller functions for matching segments.
- 6.
Devise a dynamic programming approach to optimize the search for the longest common subword.
Hint
Think about how you can store and reuse lengths of already found subwords.
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