I need help with these questions. I need the most help and focus on 20-30 Evens
ID: 3735320 • Letter: I
Question
I need help with these questions. I need the most help and focus on 20-30 Evens
16 Write code using the sort() method to sort the following numbers in descending order:
18 Which type of search would be best to use to find the name of student at a large university with a population of 60,000 students if all student names are stored in an array? Justify your answer.
Use the following code for Review Exercises 19 and 20:
Assume there is an array named customers() which consists of 150 names and an array called purchases() which is a parallel array holding the amount that each customer has spent in this business over the past year. The code sorts the arrays by smallest purchase amount to largest.
20 Rewrite the swap routine so the parallel customers() array will match the purchases() array after the sort is complete.
Use the following code for Review Exercises 21–23:
The following code is for a binary search of an array named names() which holds 100 names.
22 Write the expression that creates the appropriate value for index on line 2.
What are the values of array elements ages[k] and ages[k + 1] after the following JavaScript code is executed?
26. Use the sort() method to write JavaScript code to sort an array of numbers in ascending order. Recall that, to use this method with numbers in an array, you must include a function to compare numerical values (not ASCII values). The array is as follows:
28 How many passes are made through the outer for loop?
30 After the first pass through the inner for loop, what is the value of index ?
Explanation / Answer
*** According to Chegg policy, I can only answer the first full question, please post others as separate question***
Answer for the first question:
// First we will store the numbers in an array:
var points = [53, 82, 93, 75, 86, 97 ];
//now we can sort it in descending order
//to sort in descending order we will just reverse the way they are compared, i.e. b-a instead of a-b
//copy the code as it is for output.
points.sort(function(a, b){return b-a});