Suppose list is a LinkedList that contains 1 million int values. Analyze the following code:
```
A:
for (int i = 0; i < list.size(); i++)
sum += list.get(i);
B:
for (int i: list)
sum += i;
```
a. Code fragment A runs faster than code fragment B.
b. Code fragment B runs faster than code fragment A.
c. Code fragment A runs as fast as code fragment B.
b Becuase code fragment B uses an iterator to traverse the elements in a linked list.
You might also like to view...
File ________ occurs when files are broken into small pieces that are stored in nonadjacent or noncontiguous clusters on a disk
Fill in the blank(s) with correct word
Which of the following statements describes block scope?
a. It begins at the opening { of the class declaration and terminates at the closing }. b. It limits label scope to only the method in which it is declared. c. It begins at the identifier's declaration and ends at the terminating right brace (}). d. It is valid for one statement only.