| Folder Name | Branch | Score | Coefficient |
|---|---|---|---|
| /autocomplete | autocomplete | 100 | 0.3 |
Implement a custom createAutoComplete function that efficiently returns all strings from a given array that start with a provided prefix. You are expected to implement the fastest possible search algorithm, specifically using binary search. Your solution will be evaluated for both correctness and performance.
const data = [
'java',
'javascript',
'python',
];
const autocomplete = createAutoComplete(data);
autocomplete('ja'); // returns [ 'java', 'javascript' ]
autocomplete('javas'); // returns [ 'javascript' ]
autocomplete('p'); // returns [ 'python' ]
index.js file in the autocomplete folder must export the createAutoComplete function as follows:function createAutoComplete(data) {}
module.exports = { createAutoComplete };
Your Pull Request must include:
While working on this task, keep a developer’s diary. Write down the decisions you made, the approaches you considered, where you got stuck, and how you worked through it.
The diary is not graded. Its purpose is to help you understand your own work more deeply and to give your mentor a basis for a real conversation about the task.
The “Diary” folder can be placed in the root of the project.
Maximum Score: 100 points
| Criteria | Points |
|---|---|
The branch is named autocomplete |
1 |
| Commit messages follow RS School Git Convention | 1 |
The autocomplete folder exists |
1 |
The index.js file exists in the correct folder |
1 |
The index.js file exports the createAutoComplete function |
1 |
| The function is implemented using binary search | 4 |
| The function passes all provided tests | 4 |
| The solution is well-structured, readable, and follow best practices | 2 |
| Pull Request description includes all required elements: | |
| Task URL is included in the PR | 1 |
| Screenshot of local test results is attached in the PR | 1 |
| Algorithm analysis (Big O) is provided in the PR description | 1 |
| Submission and Deadline Dates are included in the PR | 1 |
| Your self-check of the task’s completion using checkboxes is included in the PR | 1 |
| Penalty: Commit after the deadline and before mentor review | -4 |
| Penalty: The solution includes any comments | -10 |
| Penalty: The solution includes console.log | -2 |
After submitting the task, your mentor will ask 4–5 questions from the areas below. Answers account for ~80 points of the total score, so make sure you can explain the concepts in your own words — not just recite a definition.
createAutoComplete solution in the worst case? Account for both the search phase and collecting the results."apple" < "banana" is true?createAutoComplete rely on one?