You must implement a command-line tool topk that reads a large text file line by line and computes the top-k…
You must implement a command-line tool topk that reads a large text file line by line and computes the top-k…: a task in TermGrade Environments: 1,004 executable Linux tasks (Harbor dataset). Input contract: - The tool is invoked as: topk <k <input file - <k is an integer = 1. - <input file is a…
The task
**Input contract:** - The tool is invoked as: `topk <k> <input_file>` - `<k>` is an integer >= 1. - `<input_file>` is a UTF-8 text file, potentially very large (cannot fit in memory). - Each line in the file is a record. Empty lines (zero-length after stripping CR/LF) must be treated as records with value `""` (empty…
Part of ai-and/termgrade-environments.