50 likes | 70 Views
Explore algorithms and efficiency in generating prime numbers. Discuss midterm exam solutions and optimizations to enhance algorithms' performance.
E N D
Lecture 14 • Go over midterm results • Algorithms • Efficiency • More on prime numbers
Solutions to Midterm Exam • Question 1 • Question 2 • Question 3 • Question 4
Algorithms • An algorithm is a specified set of steps for solving a prescribed problem. • It does not have to be written in any particular formal language, but it has to be intelligible to a reader and completely unambiguous. • It usually has input and always has output. • It must terminate in finite time, for all possible input.
Implementation of an Algorithm • An implementation of an algorithm means a computer program written in a well defined programming language to carry out the steps of the algorithm.
Problem: compute the first n prime numbers. • In question 1 you implemented a simple algorithm • Let’s discuss possible improvements to make it more efficient • In particular, do we need the loop in isPrime to run up to n?