One can sort an array a[] as follows. Start by observing that at stage 0, the array segment consisting of the single element a[0] is sorted. Now suppose that at the stage k, the segment a[0..k] is sorted. Take the element a[k+1], and call it X. By moving some of the elements in a[0..k] one place to the right, create a place to put X in so that now a[0..k+1] is sorted. The algorithm that uses this strategy is called


A) bubble sort
B) insertion sort
C) selection sort
D) Quicksort


B) insertion sort

Computer Science & Information Technology

You might also like to view...

What is the value of result after the following statement executes?

result = (3 * 5) % 4 + 24 / (15 - (7 - 4)); a. -6.4 b. 5 c. 1.6 d. 2.25 e. None of these

Computer Science & Information Technology

Using the class Pet from Listing 6.1, write a program to read data for five pets and display the following data: name of smallest pet, name of largest pet, name of oldest pet, name of youngest pet, average weight of the five pets, and average age of the five pets.

This project is a little more challenging if it is written to find and display all the names if more than one pet weighs the most or least, or is the oldest or youngest, which is how the solution in this manual was written.

Computer Science & Information Technology

By following the standard modeling activities, the developers will have a complete end-to-end understanding of the design of the use case.

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

Computer Science & Information Technology

What function is used to determine whether the last character in a file has been read?

A. end_of_file B. eof C. empty D. is_eof

Computer Science & Information Technology