100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Khan Academy Algorithms List Exam Questions and Answer $13.49   Add to cart

Exam (elaborations)

Khan Academy Algorithms List Exam Questions and Answer

 0 view  0 purchase
  • Course
  • Prep Tests
  • Institution
  • Prep Tests

Khan Academy Algorithms List Exam Questions and Answers 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,...

[Show more]

Preview 4 out of 40  pages

  • November 11, 2024
  • 40
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • Prep Tests
  • Prep Tests
avatar-seller
OliviaWest
Copyright © OLIVIAWEST2024/2025 ACADEMIC YEAR. ALL RIGHTS RESERVED




Khan Academy Algorithms List Exam

Questions and Answers


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



Copyright ©Stuvia International BV 2010-2024 Page 1/40

, Copyright © OLIVIAWEST2024/2025 ACADEMIC YEAR. ALL RIGHTS RESERVED


}


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? -

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. - ANSWER✔✔-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.

Copyright ©Stuvia International BV 2010-2024 Page 2/40

, Copyright © OLIVIAWEST2024/2025 ACADEMIC YEAR. ALL RIGHTS RESERVED


What is the best way to improve the run time of the algorithm? - ANSWER✔✔-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 difference of 7.


There are two proposals for the algorithm:


Algorithm 1: Set minVal to the first value in the list and maxVal to the last value in the list. Iterate

through each number in the list. If the number is greater than maxVal, store it in maxVal. If the number is

less than minVal, store it in minVal. After loop, set maxDiff to the difference between maxVal and minVal.


Algorithm 2: Set minVal to 1000 and maxVal to 0. Iterate through each number in the list. If the number

is greater than maxVal, store it in maxVal. If the number is less than minVal, store it in minVal. After loop,

set maxDiff to the difference between maxVal and minVal.


Which of these statements are true about these algorithms?


I. Algorithm 1 does not work on lists where the smallest valu - ANSWER✔✔-II only


The flow chart below visualizes an algorithm to generate the Fibonacci numbers, a famous mathematical

sequence.


If the variable max is set to 5, what would be displayed as a result of executing this algorithm? -

ANSWER✔✔-1 2 3 5 8


Yuto implements an algorithm for finding the "greatest common divisor" of two numbers. For the

numbers 54 and 24, it finds a greatest common divisor of 6.


He counts the number of steps required by the algorithm for numbers of increasing digit length and

comes up with this table:

Copyright ©Stuvia International BV 2010-2024 Page 3/40

, Copyright © OLIVIAWEST2024/2025 ACADEMIC YEAR. ALL RIGHTS RESERVED


Number of digits Steps


24


36


48


5 10


6 12


Based on the table, which of the following statements describe the run time for this algorithm?


Note that there are 2 answers to this question. - ANSWER✔✔-The algorithm runs in polynomial time.




The algorithm runs in reasonable time.


An online app for playing Chess utilizes a variety of algorithms. Their software engineers would like the

algorithms to run in under a second so that users have a great experience.


Which algorithm's runtime is most likely to be improved by the use of a heuristic? - ANSWER✔✔-

Choosing a good move when the computer is playing against the human


A restaurant delivery app uses the following algorithm to choose the restaurants it features to each user.


Which pseudocode is equivalent to the algorithm in the flowchart? - ANSWER✔✔-IF (openNow = true

AND milesAway < 5 AND reviews > 3.5) {


showFeatured ← true


} ELSE {



Copyright ©Stuvia International BV 2010-2024 Page 4/40

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller OliviaWest. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $13.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

81989 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$13.49
  • (0)
  Add to cart