Unit 3.9

Hacks 3.9.2

Why is it important to know that algorithms that look different can do the same thing and that algorithms that look the same might have different results?
  • It is important to know this because it allows people to collaborate and work on the same problem.(0.15)
  • for the converted conditional to boolean conversion(0.10)

Hack 3.9.2

Regionals Qualification

Flow Chart and Code #1

  1. Start
  2. Regionals = 26 places
  3. Competitions = 0-5
  4. If competitions>= 2
    • Choose random place (out of 40)
    • If place is < 26
    • Print(Qualified)
  5. If competitions<2:
    • Print(Ineligible)

EXTRA WHILE LOOP CODE

CODE

Hack 3.9.3

Flow Chart

Unit 3.11

Binary Trees

  1. calculate the middle index and create a binary tree for each of these lists
    • 12, 14, 43, 57, 79, 80, 99
    • 92, 43, 74, 66, 30, 12, 1
    • 7, 13, 96, 111, 33, 84, 60

  1. Using one of the sets of numbers from the question above, what would be the second number looked at in a binary search if the number is more than the middle number?
  • Using the list “12, 14, 43, 57, 79, 80, 99,” the second number in the binary search if the number is more than the middle number would be 80.
  1. Which of the following lists can NOT a binary search be used in order to find a targeted value?

    a. [“amy”, “beverly”, “christian”, “devin”]

    ##### b. [-1, 2, 6, 9, 19]

    c. [3, 2, 8, 12, 99]

    d. [“xylophone”, “snowman”, “snake”, “doorbell”, “author”]

  • I think c. is the answer because the numbers have to be in order within the list.