In the algorithm for sorting a linked list, given below:

```
1 i = 0
2 ptr = start
3 while ptr is not equal to NULL
4 A[ i++] = ptr
5 ptr = ptr->next
6 // sort the array with a sorting algorithm (swap addresses instead of elements);
7 // use A[ i ]->info to look at an element
8 for all i from 0 to n – 2
9 A[ i ]->next = A[ i + 1 ]
10 start = A[ 0 ]
11 A[ n – 1 ]->next = NULL
```
consider the time complexity of the sorting algorithm used on lines 6-7. Why don’t lines 1-5 and lines 8-11 contribute any more to this time complexity?

A. The time complexity of lines 1-5 is O( 1 ) and the time complexity of lines 8-11 is O( 1 ).
B. The time complexity of lines 1-5 is O( lg n ), and the time complexity of lines 8-11 is
O( lg n ); these time complexities must be less than that of the sorting algorithm.
C. Lines 1-5 and lines 8-11 are just “peripheral” lines, that have nothing to do with time
complexity.
D. The time complexity of the sorting algorithm must be at least O( n ), if nothing is known about the elements ahead of time; the time complexity of lines 1-5 is
O( n ), and the time complexity of lines 8-11 is O( n ).


D

Computer Science & Information Technology

You might also like to view...

You can import queries as queries or tables in Access

Indicate whether the statement is true or false

Computer Science & Information Technology

Match the following PowerPoint features with the pane or panel where each can be found:

I. added or removed slides when presentations compared II. change the author name of a file III. shows Errors, Warnings, and Tips for a file IV. add files from another presentation V. add Final status to a file A. Document Properties panel B. Accessibility Checker pane C. Revisions pane D. Reuse Slides pane E. Document Information Panel

Computer Science & Information Technology

Goal Seek is part of a suite of data tools used for ________

Fill in the blank(s) with correct word

Computer Science & Information Technology

Point-and-shoot cameras are much heavier and larger than SLR cameras.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology