Download presentation
Presentation is loading. Please wait.
1
CSC 380: Design and Analysis of Algorithms
Dr. Curry Guinn
2
Quick Info Dr. Curry Guinn CIS 2015 guinnc@uncw.edu
Office Hours: MTF: 10:00am-11:00am and by appointment
3
Today Canvas Quiz this Thursday (night) and following Tuesday (night)
Homework due Sunday, Jan 27 Where is the Course webpage/Syllabus What’s this course about?
4
Let’s Visit the Course Webpage
You’ll want to bookmark this page on your computer as you will visit it every day You can easily find it by going to my home page and clicking on the CSC 380 link on my main page Note that the “Schedule” link near the top of the page is quite important
5
Why is the Design and Analysis of Algorithms So Important?
Across disciplines within computer science the same problem types arise again and again This course investigates the best practices of past scientists trying to solve those puzzles Knowing the main algorithmic techniques and fundamental data structures allows you to design solutions to unique problems What are computers good for? What do they do well? What do they do so well, in fact, we would rather computers perform certain tasks than human beings? Computers can store, retrieve and manipulate certain types of data at far greater speeds and accuracy than human beings. Primarily what “algorithmics” is about is how we organize, store, access, manipulate and find information on computers. No matter what your subdiscipline is within computer science, whether it is digital art, databases, financial systems, scientific computer, or artificial intelligence, we tend to use the same sorts of operations over and over again. This course looks at the best practices that have been developed over the past 60 years of organizing and accessing information on digital computers. This course provides you with the fundamental building blocks that you will use again and again over your career..
6
How Do I Earn an ‘A’? This question, how do I earn an ‘a’, seems to be of some importance to some students. Here’s the simple answer: If you master the material, you will definitely earn an ‘a’. That’s what ‘a’ means: you have mastered the material. I don’t grade on a curve. If everyone masters the material, everyone earns an ‘a’. I would be delighted to give all ‘a’s. And lest you think that it must be really hard to earn an ‘a’ in this course, let me say that in the past, I often have had more than half the class earn ‘a’s. So how do you do it? Read the book. Our main text book by Levitin is not always an easy read. But it is critical that you do read the sections I assign. If you read closely and carefully, you will understand about half of what you read. Which brings us to the next strategy for earning an ‘a’: Come to every lecture. You are not going to understand everything you read in the book. Hopefully, in combination with my lectures, you will understand the course content. Also, my lectures will definitely contain material that is not in the book. But, here’s a caveat: you also may not understand my lectures if you haven’t read the books. So, do both. I’ll provide some incentive by offering some Canvas and in-class quizzes that will provide some extra motivation for doing the reading – and coming to class.
7
How Do I Earn an ‘A’? This question, how do I earn an ‘a’, seems to be of some importance to some students. Here’s the simple answer: If you master the material, you will definitely earn an ‘a’. That’s what ‘a’ means: you have mastered the material. I don’t grade on a curve. If everyone masters the material, everyone earns an ‘a’. I would be delighted to give all ‘a’s. And lest you think that it must be really hard to earn an ‘a’ in this course, let me say that in the past, I often have had more than half the class earn ‘a’s. So how do you do it? Read the book. Our main text book by Levitin is not always an easy read. But it is critical that you do read the sections I assign. If you read closely and carefully, you will understand about half of what you read. Which brings us to the next strategy for earning an ‘a’: Come to every lecture. You are not going to understand everything you read in the book. Hopefully, in combination with my lectures, you will understand the course content. Also, my lectures will definitely contain material that is not in the book. But, here’s a caveat: you also may not understand my lectures if you haven’t read the books. So, do both. I’ll provide some incentive by offering some Canvas and in-class quizzes that will provide some extra motivation for doing the reading – and coming to class.
8
How Do I Master This Material?
Read the book. Come to every lecture. Do the homework. Turn in assignments on time. Work independently (unless explicitly stated group project) Every assignment must be submitted (otherwise ‘F’). Make use of office hours Send me early and often. This question, how do I earn an ‘a’, seems to be of some importance to some students. Here’s the simple answer: If you master the material, you will definitely earn an ‘a’. That’s what ‘a’ means: you have mastered the material. I don’t grade on a curve. If everyone masters the material, everyone earns an ‘a’. I would be delighted to give all ‘a’s. And lest you think that it must be really hard to earn an ‘a’ in this course, let me say that in the past, I often have had more than half the class earn ‘a’s. So how do you do it? Read the book. Our main text book by Levitin is not always an easy read. But it is critical that you do read the sections I assign. If you read closely and carefully, you will understand about half of what you read. Which brings us to the next strategy for earning an ‘a’: Come to every lecture. You are not going to understand everything you read in the book. Hopefully, in combination with my lectures, you will understand the course content. Also, my lectures will definitely contain material that is not in the book. But, here’s a caveat: you also may not understand my lectures if you haven’t read the books. So, do both. I’ll provide some incentive by offering some Canvas and in-class quizzes that will provide some extra motivation for doing the reading – and coming to class.
9
Course and Grading Criteria
Quizzes 10% 1st Midterm Exam 15% 2nd Midterm Exam Final 35% Homework 25% -10 pts. per day late up to 5 days. Then ‘F’ for the course This page summarizes the relative worth of assignments. I am hoping those fractions add up to 1. I don’t drop any quizzes in this course. The midterms and final are all paper-based tests – that is to say, you won’t be writing code on a computer for those tests. However, some questions will require you to write code on paper.
10
The Required Text Introduction to the Design and Analysis of Algorithms, 3rd Edition, Anany Levitin, ©2012, Boston, MA. (Pearson Website)
11
What is an algorithm? An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any legitimate input in a finite amount of time. problem algorithm “computer” input output Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 1 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
12
Euclid’s Algorithm Problem: Find gcd(m,n), the greatest common divisor of two nonnegative, not both zero integers m and n Examples: gcd(60,24) = 12, gcd(60,0) = 60, gcd(0,0) = ? Euclid’s algorithm is based on repeated application of equality gcd(m,n) = gcd(n, m mod n) until the second number becomes 0, which makes the problem trivial. Example: gcd(60,24) = gcd(24,12) = gcd(12,0) = 12 Euclid’s algorithm is good for introducing the notion of an algorithm because it makes a clear separation from a program that implements the algorithm. It is also one that is familiar to most students. Al Khowarizmi (many spellings possible...) – “algorism” (originally) and then later “algorithm” come from his name. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 1 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
13
Three descriptions of Euclid’s algorithm
Step 1 If n = 0, return m and stop; otherwise go to Step 2 Step 2 Divide m by n and assign the value of the remainder to r Step 3 Assign the value of n to m and the value of r to n. Go to Step 1. while n ≠ 0 do r ← m mod n m← n n ← r return m Recursive version gcd(m, n): if n = 0 return m else return gcd(n, m % n) Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 1 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
14
Other methods for computing gcd(m,n)
Consecutive integer checking algorithm Step 1 Assign the value of min{m,n} to t Step 2 Divide m by t. If the remainder is 0, go to Step 3; otherwise, go to Step 4 Step 3 Divide n by t. If the remainder is 0, return t and stop; otherwise, go to Step 4 Step 4 Decrease t by 1 and go to Step 2 Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 1 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
15
Other methods for gcd(m,n) [cont.]
Middle-school procedure Step 1 Find the prime factorization of m Step 2 Find the prime factorization of n Step 3 Find all the common prime factors Step 4 Compute the product of all the common prime factors and return it as gcd(m,n) Is this an algorithm? Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 1 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
16
Sieve of Eratosthenes Input: Integer n ≥ 2
Output: List of primes less than or equal to n for p ← 2 to n do A[p] ← p for p ← 2 to n do if A[p] 0 //p hasn’t been previously eliminated from the list j ← p* p while j ≤ n do A[j] ← 0 //mark element as eliminated j ← j + p Example: Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 1 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
17
Why study algorithms? Theoretical importance Practical importance
the core of computer science Practical importance A practitioner’s toolkit of known algorithms Framework for designing and analyzing algorithms for new problems Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 1 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
18
Two main issues related to algorithms
How to design algorithms How to analyze algorithm efficiency Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 1 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
19
Algorithm design techniques/strategies
Brute force Divide and conquer Decrease and conquer Transform and conquer Space and time tradeoffs Greedy approach Dynamic programming Iterative improvement Backtracking Branch and bound Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 1 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
20
Analysis of algorithms
How good is the algorithm? time efficiency space efficiency Does there exist a better algorithm? lower bounds optimality Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 1 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
21
Important problem types
sorting searching string processing graph problems combinatorial problems geometric problems numerical problems Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 1 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
22
Fundamental data structures
graph tree set and dictionary list array linked list string stack queue priority queue Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 1 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
23
For Next Class, Wednesday
Canvas Quiz 1 due by Thursday night, 11:59pm, Jan 17 No late Canvas quizzes No make up quizzes Canvas Quiz 2 due by Tuesday night, 11:59pm, Jan 22 Homework 1 is due Sunday, 11:59pm, Jan 27, 11:59pm
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.