25
CS 4/56101 Design and Analysis of Algorithms Fall 2021

CS 4/56101 Design and Analysis of Algorithms Fall 2020

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

CS 4/56101 Design and Analysis of Algorithms

Fall 2021

Website and Contact

• Course Website:• http://www.cs.kent.edu/~aalbaghd/DAAFall21.html

• Important information • Slides

• Announcements

• Instructor:• Ahmed Al-Baghdadi

• Email: [email protected]

• Office hours: 5:00p.m. to 6:00p.m. Tuesday and Thursday

Learning objectives

• Advanced data structures and their analysis

• To think algorithmically like a "real" computer scientist

• Different techniques and methods for designing efficient algorithms for solving computational problems

• Students will develop• the ability to design efficient algorithms

• the ability to prove correctness and evaluate efficiency of algorithms

Course Goals

• Study important data structures and algorithmic techniques not normally covered in CS 23001

• Develop ability to design efficient algorithms

• Develop ability to prove correctness and evaluate efficiency of algorithms

• **The main goal of the course is to learn to think algorithmically like a ``real'' computer scientist

Topics will include:

• Computational Model and Runtime Analysis

• Binary Search

• Insertion, Merge, and Quicksort

• Heaps and Priority Queues

• Linear Time Sorting

• Red-Black, AVL, and B-Trees

• Hash Tables

• Graphs • Basic Algorithms • DAGs • Minimum Spanning Tree • Shortest Path (Dijkstra)

Textbook

• Algorithm Design: Foundations, Analysis, and Internet Examples, by Michael T. Goodrich and Roberto Tamassia, 1st edition, Wiley, 2001

Other Books

• Introduction to Algorithms, by Cormenet al. 3rd edition, MIT Press, 2009 Primary source for this class.

• The Algorithm Design Manual, by Steven S. Skiena 2nd edition, Springer, 2008

Note

• You do not need (to buy) a textbook. These are recommendations if you are looking for a textbook to study.

Course Requirements

• Homework 35%• Download from Blackboard or the course website• Deadline will be announced on the course website and Blackboard• Solutions will be submitted to Blackboard

• Midterm Exam 30%• (via Blackboard)

• Final Exam 30% • (via Blackboard)

• Attendance 5%

• **NOTE: Exact dates will be announced in class!!!

Class Policies

• Late Policy• Homework must be sent submitted to Blackboard by the due date shown on

the course website

• Unexcused late homework is not accepted

• Missed exams and missed homework are only excused if absence was essential and can be fully documented.

• Registration Requirements • Sept. 8th: Last day to drop before grade of "W" is assigned is

• Sept. 9 to Nov. 3,: Last day to withdraw (Grade of "W" assigned.)

Homework and Collaboration

• You will need to devote a considerable amount of time to homework

• You may discuss the homework with other students, but you must write your solutions independently

• If you obtain a solution to a homework problem through research (e.g., from books or journals), you are expected to acknowledge your sources in your write up and also to write up your solution independently

Milestone for successful completion of the course• Attend the classes regularly

• Perform the homework thoroughly and independently

• Read a head

• Read the book carefully and several times

• Ask Questions

What is an algorithm?

• Algorithm• a set of steps to accomplish a task

What is an algorithm?

• Algorithm• a set of steps to accomplish a task

• Example:• Making Pizza

What is an algorithm?

• Algorithm in Computer Science• an algorithm is a set of steps for a computer program to accomplish a task

• Examples of CS Algorithms• Search algorithm

What is an algorithm?

• Algorithm in Computer Science• an algorithm is a set of steps for a computer program to accomplish a task

• Examples of CS Algorithms• Search algorithm (Find the Maximum)

High-level description:

1.If there are no numbers in the set then there is no highest

number.

2.Assume the first number in the set is the largest number in the

set.

3.For each remaining number in the set: if this number is larger

than the current largest number, consider this number to be the

largest number in the set.

4.When there are no numbers left in the set to iterate over,

consider the current largest number to be the largest number of

the set.

What is an algorithm?

• Algorithm in Computer Science• an algorithm is a set of steps for a computer program to accomplish a task

• Examples of CS Algorithms• Search algorithm

Algorithm LargestNumber

Input: A list of numbers L.

Output: The largest number in the list L.

if L.size = 0

return null

largest ← L[0]

for each item in L, do

if item > largest,

then largest ← item

return largest

High-level description:

1.If there are no numbers in the set then there is no highest

number.

2.Assume the first number in the set is the largest number in the

set.

3.For each remaining number in the set: if this number is larger

than the current largest number, consider this number to be the

largest number in the set.

4.When there are no numbers left in the set to iterate over,

consider the current largest number to be the largest number of

the set.

What is an algorithm?

• Algorithm in Computer Science• an algorithm is a set of steps for a computer program to accomplish a task

• Examples of CS Algorithms• Path Finding (Google Maps)

What is an algorithm?

• Algorithm in Computer Science• an algorithm is a set of steps for a computer program to accomplish a task

• Examples of CS Algorithms• Path Finding (Google Maps)

What is an algorithm?

• Algorithm in Computer Science• an algorithm is a set of steps for a computer program to accomplish a task

• Examples of CS Algorithms• Path Finding (Google Maps)

What makes a good algorithm?

• The two most important criteria• will it solve the problem?

• produce the desired output?

• prove that our algorithms are correct?

• will it solve the problem efficiently?• how fast is the algorithm?

• how much resources does it need?

• is there a faster algorithm?

• Having one of both properties is (usually) easy. However, having both is the goal.

Problem Example

• You are given two integer arrays A and B. Is there an integer i which is in both arrays?

Problem Example

• You are given two integer arrays A and B. Is there an integer i which is in both arrays?

• First Algorithm

1- For Each a ∈A

2- For Each b ∈ B

3- If a = b

4- Then Return “Yes”

5- Return “No”

Problem Example

• You are given two integer arrays A and B. Is there an integer i which is in both arrays?

• Second Algorithm1 Sort A and B.

2 Set i := 0 and j := 0.

3 While i < |A| and j < |B|

4 If A[i] = B[j] Then

5 Return “Yes”

6 Else If A[i] < B[j] Then

7 Set i := i + 1.

8 Else If A[i] > B[j] Then

9 Set j := j + 1.

10 Return “No”

Problem Example

• Which algorithm is better and why?

1 Sort A and B.

2 Set i := 0 and j := 0.

3 While i < |A| and j < |B|

4 If A[i] = B[j] Then

5 Return “Yes”

6 Else If A[i] < B[j] Then

7 Set i := i + 1.

8 Else If A[i] > B[j] Then

9 Set j := j + 1.

10 Return “No”

1- For Each a ∈A

2- For Each b ∈ B

3- If a = b

4- Then Return “Yes”

5- Return “No”