KHAN ACADEMY ALGORITHMS LIST 2024 WITH COMPLETE SOLUTION
KHAN ACADEMY ALGORITHMS LIST 2024 WITH COMPLETE SOLUTION A statistician developed this procedure to calculate the "variance" of a list of numbers. The variance is a statistical quantity that corresponds to the average of the sum of the squared differences of each number from the mean. As input, the procedure takes a list of numbers and its mean: PROCEDURE calculateVariance(numbers, mean) { count ← 0 sumSquaredDiffs ← 0 FOR EACH num IN numbers { diff ← (num - mean) squaredDiff ← diff * diff sumSquaredDiffs ← sumSquaredDiffs + squaredDiff count ← count + 1 variance ← sumSquaredDiffs / count } RETURN variance } The statistician verifies the procedure outputs the variance correctly, but they still want to improve the efficiency of the procedure by reducing the number of operations required. Which change will reduce the most number of operations while still outputting a correct answer? Moving the calculation of variance to be after the loop (but before the return) The following algorithm computes the maximum score for a list of final exam scores. Initialize a variable max to the first score in the list. For each score in the list, compare the score to max. If score is greater than max, store score in max Return max. Which building blocks are involved in this algorithm? ️Note that there may be multiple answers to this question. Selection Iteration Sequencing ScootALot is a scooter rental service. At the end of each day, they hire contractors to pick up scooters and distribute them optimally around the city. The distribution algorithm considers all the possible locations for the scooters, compares that to the density of customers, and comes up with the optimal location for each scooter. As the company becomes more popular, they realize their algorithm is taking an unreasonable amount of time to come up with optimal scooter locations. What is the best way to improve the run time of the algorithm? Use a heuristic-based algorithm that suggests good locations for the scooters. An algorithm will be used to calculate the difference between the smallest and largest values in a list. For the list of [10, 3, 5, 6], it should calculate a
Escuela, estudio y materia
- Institución
- KHAN ACADEMY ALGORITHMS LIST 2024 WITH COMPLETE SO
- Grado
- KHAN ACADEMY ALGORITHMS LIST 2024 WITH COMPLETE SO
Información del documento
- Subido en
- 3 de mayo de 2024
- Número de páginas
- 19
- Escrito en
- 2023/2024
- Tipo
- Examen
- Contiene
- Preguntas y respuestas
Temas
-
khan academy algorithms list 2024 with complete so