Сложность времени для алгоритма

Я прав в своем объяснении при расчете временной сложности следующего алгоритма?

A HashSet, moduleMarksheetFiles, is being used to add the files that contain the moduleName specified.

<code>for (File file: marksheetFiles){
     while(csvReader.readRecord()){
         String moduleName = csvReader.get(ModuleName);

         if (moduleName.equals(module)){
               moduleMarksheetFiles.add(file);
         }
     }
 }
</code>

Let m be the number of files

Let k be the average number of records per file. As each file is added only once because HashSet does not allow for duplicates. HashSet.add() is O(1) on average and O(n) for worst case. Searching for a record with the specified moduleName involves comparing every record in the file to the moduleName, will take O(n) steps.

Следовательно, средняя сложность по времени будет: O ((m * k) ^ 2).

Это правильно?

Кроме того, как бы вы рассчитали наихудший случай?

Благодарю.

PS. Это не домашняя работа, просто анализ алгоритма моей системы для оценки производительности.

Ответы на вопрос(1)

Ваш ответ на вопрос