What should the missing code be in the following insertion sort algorithm?
?
i = 1
while i < len(myList):
itemToInsert = myList[i]
j = i - 1
while j >= 0: if itemToInsert < myList[j]:
myList[j + 1] = myList[j]
j -= 1
else:
break
i += 1
?
i += 1
?
A. myList[i + 1] = itemToInsert
B. myList[j] = itemToInsert
C. myList[j + 1] = itemToInsert
D. myList[i] = itemToInsert
Answer: C
Computer Science & Information Technology
You might also like to view...
What is the advantage of an implementation of a stack that uses the ADT list over an implementation that uses a linked list?
What will be an ideal response?
Computer Science & Information Technology
Which of the following does not complete the sentence correctly? An interface_____________.
a. forces classes that implement it to declare all the abstract interface methods. b. can be used in place of an abstract class when there is no default implementation to inherit. c. is declared in a file by itself and is saved in a file with the same name as the interface followed by the .java extension. d. can be instantiated.
Computer Science & Information Technology