Олимпиадный тренинг

Задача . 37455


Задача

Темы:
Refer to method insert below:
/** @param list an ArrayList of String objects
* @param element a String object
* Precondition: list contains String values sorted
* in decreasing order.
* Postcondition: element inserted in its correct position in list.
*/
public void insert(List<string> list, String element)
{
    int index = 0;
    while (element.CompareTo(list[index]) < 0)
      index++;
    list.Insert(index, element);
}
Assuming that the type of element is compatible with the objects in the list, which is a true statement about the insert method?

(A) It works as intended for all values of element. 
(B) It fails for all values of element.
(C) It fails if element is greater than the first item in list and works in all other cases.
(D) It fails if element is smaller than the last item in list and works in all other cases.
(E) It fails if element is either greater than the first item or smaller than the last item in list and works in all other cases.
 

time 1000 ms
memory 32 Mb
Правила оформления программ и список ошибок при автоматической проверке задач

Статистика успешных решений по компиляторам
Комментарий учителя