University of Lethbridge - CPSC
sort(string titles[], int years[], int n)
Assignment 1 - Movie1 - SM 25What does this function do?
This function organizes the movie titles into alphabetical order.
For example:
"Avatar"should come before"Inception""batman"and"Batman"are treated the same — the order does not depend on capitalization
At the same time, the years[] array must stay in sync with the titles[] array. That means if we move a title during sorting, we also move its matching year with it.
Why do we need this?
We need to sort the titles so that binary search works correctly. Binary search only works on sorted data. If we skip this step, our binary search function would not work properly.
Members only
Keep reading this lesson
You've reached the end of the free preview. Unlock the rest of this lesson plus 27 more lessons in University of Lethbridge - CPSC.
- Unlimited coding questions
- Unlimited access to all classroom material
- Weekly live call for questions and guidance
- 3,000 AI tutor tokens / month
- Personal SQL database (3 MB)
- Progress tracking
Cancel any time.