subject

Consider the following correct implementation of the insertion sort algorithm. public static void insertionSort(int[] elements)

{

for (int j = 1; j < elements. length; j++)

{

int temp = elements[j];

int possibleIndex = j;

while (possibleIndex > 0 && temp < elements[possibleIndex - 1])

{

elements[possibleIndex] = elements[possibleIndex - 1];

possibleIndex--; // Line 10

}

elements[possibleIndex] = temp;

}

}

The following declaration and method call appear in a method in the same class as insertionSort.

int[] arr = {4, 12, 4, 7, 19, 6};

insertionSort(arr);

How many times is the statement possibleIndex--; in line 10 of the method executed as a result of the call to insertionSort ?

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 22:00, marshunsanders
What must you do before formatting a paragraph?
Answers: 1
image
Computers and Technology, 22.06.2019 01:30, yudayang2012pa9u8p
Consider the following statements: #include #include class temporary { private: string description; double first; double second; public: temporary(string = "", double = 0.0, double = 0.0); void set(string, double, double); double manipulate(); void get(string& , double& , double& ); void setdescription(string); void setfirst(double); void setsecond(double); }; write the definition of the member function set() so that the instance variables are set according to the parameters. write the definition of the constructor so that it initializes the instance variables using the function set() write the definition of the member function manipulate() that returns a decimal number (double) as follows: if the value of description is "rectangle", it returns first * second if the value of description is "circle" it returns the area of a circle with radius first if the value of description is "cylinder" it returns the volume of a cylinder with radius first and height second. hint: the volume of a cylinder is simply the area of the circle at the base times the height. if the value of description is "sphere" it returns the volume of the sphere with radius first. otherwise it returns -1.0;
Answers: 1
image
Computers and Technology, 22.06.2019 15:00, gmc2771
Hyperactive media sales has 10 windows 7 laptop computers used by sales-people in the organization. each laptop computer has several customized applications that are used during the sales process as well as customer relationship management software. all of the applications on the laptops are difficult to configure and have large data files. if all of the laptops have current hardware, what is the easiest way to install windows 10 on them?
Answers: 1
image
Computers and Technology, 22.06.2019 17:40, pnhandley01
Consider the simple 3-station assembly line illustrated below, where the 2 machines at station 1 are parallel, i. e., the product only needs to go through one of the 2 machines before proceeding to station 2.what is the throughput time of this process?
Answers: 2
You know the right answer?
Consider the following correct implementation of the insertion sort algorithm. public static void i...

Questions in other subjects: