Exam 12: Sorting Data

arrow
  • Select Tags
search iconSearch Question
  • Select Tags

In JavaScript, lexigraphical sorting treats numbers as characters.

(True/False)
4.8/5
(29)

On the first pass of a bubbles sort, when two adjacent elements are compared, if the one on the left has a greater value than the one on the right, they are swapped.

(True/False)
4.9/5
(41)

When you swap the values of two variables or array elements, you need a third variable, a temporary one, to hold one of the values until the swap is completed.

(True/False)
4.8/5
(40)

A bubble sort requires passes through an array, but it makes one fewer pass than the number of array elements.

(True/False)
4.7/5
(36)

To sort in ascending order, use the less than operator (<) to swap elements if the first element is less than the second.

(True/False)
4.8/5
(42)

The following algorithm represents the logic of a(n) ____. // Outer loop designates a position // from first to last element For currEl = 0 To ARRAYSIZE - 1 MinValue = someNums[currEl] MinPosition = currEl // Inner loop steps through array, // finding smallest value For index = currEl + 1 To ARRAYSIZE - 1 If someNums[index] < minValue Then MinValue = someNums[index] MinPosition = index End If End For // Swap minimum value with element at // designated position if different If minPosition != currEl Then Temp = someNums[currEl] SomeNums[currEl] = someNums[minPosition] SomeNums[minPosition] = temp End If End For

(Multiple Choice)
4.8/5
(38)

An optional argument called a function reference can be used with the sort() method; it bases the sorting order of any two array elements on the value the function returns.

(True/False)
4.9/5
(39)

When you are sorting in descending order, use the greater than operator (>) in the comparison to swap adjacent elements if the first element is greater than the second.

(True/False)
4.8/5
(42)

A sorting algorithm can involve switching the places of two elements being compared, a process called ____.

(Multiple Choice)
4.9/5
(41)

The following algorithm represents the logic of a(n) ____. // Loop pulls each element from 1 to the end of the array For pulledIndex = 1 to ARRAYSIZE - 1 PulledValue = someNums[pulledIndex] InsertIndex = pulledIndex // If element to the left is greater, // shift it to the right // and look at the next element to the left While insertIndex > 0 And someNums[insertIndex - 1] > pulledValue SomeNums[insertIndex] = someNums[insertIndex - 1] InsertIndex = insertIndex - 1 End While // Insert the pulled value when the shifting ends SomeNums[insertIndex] = pulledValue End For

(Multiple Choice)
4.9/5
(38)
Showing 21 - 30 of 30
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)