What type of algorithm is the following code?
n = len(myList)while n > 1: i = 1 while i < n: if myList[i] < myList[i - 1]: swap(myList, i, i - 1) i += 1 n -= 1

A. linear sort
B. bubble sort
C. insertion sort
D. selection sort


Answer: B

Computer Science & Information Technology

You might also like to view...

What does the ReDim statement allow for?

a) Expanding any dynamic data structure. b) Re-declaring a variable. c) Expanding an array. d) None of the above.

Computer Science & Information Technology

Starting with the result from Exercise 20.1, draw the tree that results from removing (45 12 1), again using our simple implementation with no balancing mechanism.

What will be an ideal response?

Computer Science & Information Technology

Which of the following is not true when changing fonts, font sizes, font styles, and font colors?

a. When you click the Font Color button instead of the Font Color button arrow, the color displayed in the lower part of the Font Color button is applied to selected text while displaying the color gallery. b. Font styles include bold, italic, and underline. c. You can apply any combination of these styles to presentation text to draw the reader's eye to important text. d. The lower part of the Font Color button displays the most recently applied font color.

Computer Science & Information Technology

____ arrays are two or more arrays, where each array has the same number of elements and the elements in each array are directly related by their position in the arrays.

A. Two-dimensional B. Multi-dimensional C. Parallel D. Complex

Computer Science & Information Technology