csci 371 design & analysis of algorithms

12
CSCI 371 Design & Analysis of Algorithms Morken 210 MWF 11:00-12:00 AM Dr. Kenneth Blaha

Upload: others

Post on 07-Feb-2022

1 views

Category:

Documents


0 download

TRANSCRIPT

CSCI 371 Design & Analysis of Algorithms

Morken 210

MWF 11:00-12:00 AM

Dr. Kenneth Blaha

Wednesday 9/8Announcements:

• Make sure you can access the CSCI 371 Sakai site

• Make sure you have an active CSCI account

• Complete the Student Information form

Next time

• Read Chapter 1 (overview – be able to answer the following questions )

– What is a well-specified problem and what is a problem instance?

– What is an algorithm?

– If there is more than one solution (algorithm) to a problem, how do we pick the “best” solution?

– Does every computational problem have an efficient solution?

• Read Section 2.1 and 2.2

– Don’ t worry about proofs of correctness or loop invariants

Today:

• Introductions & Reflections

• First day stuff (Sakai, class website, Syllabus, Student Hours, …)

• CSCI 270 Basics

• CSCI 371 Overview / Program 1 ??

Introductions & Reflections

• Introduce yourself

• How do you feel about being back in the classroom?

– a word that captures how you feel

– a color that captures how you feel

– a sound that captures how you feel

– other

• Last year online classes (Good / Bad / Ugly)

First Day Stuff• Student Information Form

– CSCI Department Accounts

• Sakai

– Homework (once a week? - Due 5 PM MTWRF?)

• Class web page

– Syllabus

– Schedule

– Programming Assignments

• Sakai or Submission System

• paper copies??

• Select Students at Random

CSCE 270 Basics• Abstract Data Type (ADT)

– Data

– Operations

• Using and Implementing Java’s Primary Data Structures

• Primary ADT Covered in CSCE 270– List Set

– Stack Queue

– Tree BST

– Map

• Studied Different Implementations (Data Structures)– ArrayList and LinkedList

– Efficiency of Operations: add(e), add(index, e), get(index)

• Was sorting covered in your CSCI 270 class?

Design & Analysis of AlgorithmsCSCI 371 - Overview

• Combine Data Structures with Algorithm Design Techniques to solve a variety of important computational problems

• Algorithm Design Techniques (problem solving strategies)– Brute Force– Incremental / Iterative – Recursion / Backtrack Search– Transform and Conquer– Divide and Conquer– Dynamic Programming– Greedy Technique

• Elementary and Advanced Graph Algorithms

Important Problem Types

• Searching

• Sorting

• String Processing

• Graph Problems

– DFS and BFS

– Topological Sort

– Strongly Con. Comp.

– Shortest Path

– Maximum Flow

• Combinatorial Problems– Graph Isomorphism

– Bin Packing

– Scheduling

• Geometric Problems– Closest pair of points

– Convex Hull

• Numeric Problems– Solving equations

– Evaluating functions

– Solving Systems of equations

Design & Analysis of AlgorithmsCSCI 371 Overview - Continued

How will we describe algorithms?• High level language

• Pseudocode

• Java/C++/… code

GCD(m, n) - Pseudocode

Problem: Find gcd(m,n), the greatest common divisor of two positive integers

Input:Two positive integers (m, n)Output: The gcd of m and n

Brute Force - Pseudocodegcd(m, n)1. t = min(m, n)2. for i = t downto 13. if ( (m mod t == 0) and (n mod t == 0) ) 4. return t

Euclid’s gcd(m, n) Algorithm

High Level DescriptionStep 1 If n = 0, return m and stop; otherwise go to Step 2Step 2 Divide m by n and assign the value of the remainder to rStep 3 Assign the value of n to m and the value of r to n. Go to

Step 1.

Pseudocode Descriptiongcd(m, n)while n ≠ 0

r = m mod nm = n n = r

return m

Next TimeComplete the Student Information form

• Read Chapter 1 (overview – be able to answer the following questions )

– What is a well-specified problem and what is a problem instance?

– What is an algorithm?

– If there is more than one solution to a problem, how do we pick the “best” solution?

– Does every well-specified problem have an efficient solution?

• Read Section 2.1 and 2.2

– Don’ t worry about proofs of correctness or loop invariants

– Understand pseudocode conventions

• If you have time review Program 1

The Bad:Mathematical emphasisLots of proofsParts are very technical

The Good:Great reference bookGood pseudocode Short Independent ChaptersWe will not focus on proofs

Program 1

• Purpose

– Warm up exercise

– Review some 270 basics

– Practice using Maps