Notes

  • Decidable problems are algorithm based
  • Undecidble ins't algorithm based
  • different time of runs times in order for efficency
  • Linear time isnt the most beneficial
  • exponential helps it grow past the superpolynomial size

Vocab

  • undecidable problem problems for which no algorithms can be built that can provide a correct yes or no answer or a solution
  • Decidable problem problems for which algorthms could be written to solve/produce a correct output for all inputs.
  • Superpolynomial a specfic run time for an algorithm that help it grow througout time complexity.

Hack 1

  • An undecidable problem is something an Algorithm cant really make this is shown in the questin about god as he has a certain amount of power but can he lift a rock that weighs more than the undefiable. A decidble problem is something that can be created for an algorithm for example how to randomize the role of a dice and compare it with another persons role.

Hack 2

C. (3x8)^2 due to the fact it has to multiply the times two and then two more times which makes it three steps

Hack 3

function peak_finder2(array){
    if (array.length)=== 0{
       return  `Array cannot be empty`
     }else if (array.length === 1){
       return array[0]
     }else{
       let mid_index = Math.floor(array.length*0.5)
      if (array[mid_index +1]>array[mid_index]){
         return peak_finding(array.slice(mid_index + 1 ))
       }else if (array[mid_index -1]>array[mid_index]){ 
        new=array.reverse().slice(mid_index+1).reverse()
        return peak_finding(new)  
        }else{
         return array[mid_index]
        }
      }
}
// Note I edited my answer based on the key as I was unsure of my previous answer I think I struggled due to my lack of profieceny in javascript, however I was able to make the array more simple and write a conditional

Hack 4

 
    data = [9, 1, 7, 6, 2, 8, 5, 3, 4, 0]
    data.sort()
    print(data)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Explanation

I was able to find the function and just use the sort function in order to arive to the answer

Hack 5

  
  
perm = permutations([1, 2, 3]) 

for i in list(perm): 
    print (i)
(1, 2, 3)
(1, 3, 2)
(2, 1, 3)
(2, 3, 1)
(3, 1, 2)
(3, 2, 1)

Explanation

  • I just coded a new simpler permutation I learned this from the lesson and througout my extra reasearch that I did to arrive to this simple answer

Reflection

  • I learend a lot in this lesson something I found a bit hard was superpolynomial and the polynomial growth. My favorite part of the lesson was learning about the undecidble and decidble algorithms. Also permutations and step function were fun to learn about

Extra

def heap_permutation(data, n):
    if n == 1:
        print(data)
        return
    
    for i in range(n):
        heap_permutation(data, n - 1)
        if n % 2 == 0:
            data[i], data[n-1] = data[n-1], data[i]
        else:
            data[0], data[n-1] = data[n-1], data[0]
    
if __name__ == '__main__':
    data = ["car, watch, toy"]
    heap_permutation(data, len(data))
['car, watch, toy']
from itertools import permutations
perm = permutations(["car", "watch","toy"]) 

for i in list(perm): 
    print (i)
('car', 'watch', 'toy')
('car', 'toy', 'watch')
('watch', 'car', 'toy')
('watch', 'toy', 'car')
('toy', 'car', 'watch')
('toy', 'watch', 'car')