Unit 3 Section 17 and 18 Blog
Unit 3 Section 17 and 18
Notes
-
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.
-
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.
-
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.
-
Undecidable problem: problems for which no algorithms can be built that can provide a correct yes or no answer.
function peak_finder(array) {
var peak = array[0];
for (i = 0; i < array.length; i ++) {
if (array[i] > peak) {
var peak = array[i];
}
}
return peak;
}
var numbers = [1, 2, 3, 4, 5, 6, 7, 8];
console.log(peak_finder(numbers));
data = [9, 1, 7, 6, 2, 8, 5, 3, 4, 0]
print("original list")
print(data)
data.sort()
print("-----------------")
print("sorted list")
print(data)
from itertools import permutations
data = [1, 2, 3]
for i in permutations(data):
print(i)