Unit 3 Lesson 17-18

Notes

undecidable problem: problems for which no algorithms can be built that can provide a correct yes or no answer.

problem: description of a task that may or may not be able to be solved through the use of an algorithm. An instance of a problem includes a specific input. One example of this type of problem is a sorting problem.

decision problem: problem with a binary answer (yes or no). An optimization problem is a problem with the objective of finding the BEST solution amongst many possibilities to solve a problem.

An algorithm’s efficiency is determine through formal or mathematical reasoning.

decidable problem: problems for which algorithms can be written to solve/produce a correct output for all possible inputs.

Hack 1 Decidable problems are those that can be solved through the use of an algorithm. An example is determining whether a number is even or odd. Undecidable problems cant be solved with an algorithmic procedure. An example is the halting problem which asks if the program will run forever or halt.

Hack 2 Which of the following is a 3 step algorithm?

A. 2 x 6 x 8

B. 4^5

C. (3 x 8)^2

D. None of the above

E. All of the above

Answer: C is the correct answer sicne you have to multiplky the numbers inside of the parantheses then take that value to the power of two

Hack 3 and 4

Using the data.sort function I was able to rewrite the code more efficiently ans easier to read

Hack 5

Explanation for Code: Imports the permutation method from the library itertools. Using this, we can use a built in command to create permutations. Using a for loop, we can iterate through all possible permutations, and print them. This is not only a much smaller piece of code, but it does not require recalling a variable multiple times, like in the former program. This is also more efficient for the developer, as it allows for the individual to code much less and in a simpler fashion.

Reflection

Overall, I found these questions very rewarding because they were not incredibly hard where there was no point of doing them but they were not easy where I did not learn anything. It was a good balance between easy and hard. hese hacks were a bit challenging at first but with perserverance I was able to understand the concepts which allowed me to perform the hacks well. The presentation was great and I learned a lot from it. Out of all the presentations, I was able to retain a lot more from this one then others. Overall it was good and it helped me become a better coder.