CS223: Software Engineering Lecture 5: Software Development Models.
CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.
-
Upload
laura-horn -
Category
Documents
-
view
226 -
download
0
Transcript of CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.
![Page 1: CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.](https://reader035.fdocuments.in/reader035/viewer/2022062304/56649e2d5503460f94b1c52f/html5/thumbnails/1.jpg)
CS223 AlgorithmsD-Term 2013
Instructor: Mohamed Eltabakh
WPI, CS
Introduction
Slide 1
![Page 2: CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.](https://reader035.fdocuments.in/reader035/viewer/2022062304/56649e2d5503460f94b1c52f/html5/thumbnails/2.jpg)
Lecture Outline
• Introduction and Definitions
• Example Problems
• Course Logistics
Slide 2
![Page 3: CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.](https://reader035.fdocuments.in/reader035/viewer/2022062304/56649e2d5503460f94b1c52f/html5/thumbnails/3.jpg)
Definition
• An algorithm is a finite sequence of step by step, discrete, unambiguous instructions for solving a particular problem
– Receives input data– Produces output data– Each instruction can be carried out in a finite
amount of time in a deterministic way
Slide 3
![Page 4: CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.](https://reader035.fdocuments.in/reader035/viewer/2022062304/56649e2d5503460f94b1c52f/html5/thumbnails/4.jpg)
Definition
• In simple terms, an algorithm is a series of instructions to solve a problem (complete a task)
• We focus on Deterministic Algorithms– Under the same input it must produce the
same output
Algorithminput output
Well defined sequence of computer instructions
Slide 4
![Page 5: CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.](https://reader035.fdocuments.in/reader035/viewer/2022062304/56649e2d5503460f94b1c52f/html5/thumbnails/5.jpg)
Two Key Properties
• Correctness– An algorithm is correct if under all valid inputs, it produces
the correct output
• Efficiency– Same problem can have many ways (algorithms) to solve it– Which one is more efficient?– Efficiency means:
• How long will it take?
• How much storage will it need?
Time CPU # of instructions
StorageSpace Memory
Slide 5
![Page 6: CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.](https://reader035.fdocuments.in/reader035/viewer/2022062304/56649e2d5503460f94b1c52f/html5/thumbnails/6.jpg)
CS223 AlgorithmsD-Term 2013
Representative Problems
Slide 6
![Page 7: CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.](https://reader035.fdocuments.in/reader035/viewer/2022062304/56649e2d5503460f94b1c52f/html5/thumbnails/7.jpg)
Problem Family I: Sorting
– Input• A list of unsorted values
– Output• The corresponding sorted list
B R U T E F O R C E
B C E E F O R R T U
The algorithm must know how to compare values (<, =, or >)
Slide 7
![Page 8: CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.](https://reader035.fdocuments.in/reader035/viewer/2022062304/56649e2d5503460f94b1c52f/html5/thumbnails/8.jpg)
Problem Family II: Searching– Input
• A list of values L, and a key (single value) K
– Output• The position in L that contain K (if exists)
B R U T E F O R C E
Search for 33?
Search for C?
Will it make a difference if the list is sorted ???
Slide 8
![Page 9: CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.](https://reader035.fdocuments.in/reader035/viewer/2022062304/56649e2d5503460f94b1c52f/html5/thumbnails/9.jpg)
Problem Family III: Trees– Input
• A tree of values
– Different problems• Traverse the tree and list the values
• Search for a value in the tree
• Deletion from or insertion into the tree
Can you notice a certain order in this tree?
Binary Tree Binary Search Tree
Left smaller thanRight greater than
Slide 9
![Page 10: CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.](https://reader035.fdocuments.in/reader035/viewer/2022062304/56649e2d5503460f94b1c52f/html5/thumbnails/10.jpg)
Problem Family IV: Graphs– Input
• A graph of values G
– Different problems• Traverse the graph• Searching for a value in the graph• Shortest path from one node to another
What is the shortest path from F to B?
What is the shortest path from F to all other nodes?
Find a minimum spanning tree?
Slide 10
![Page 11: CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.](https://reader035.fdocuments.in/reader035/viewer/2022062304/56649e2d5503460f94b1c52f/html5/thumbnails/11.jpg)
Problem Family V: String Processing
– Input• One or multiple strings
– Different problems• Search for one string in another
• Edit distance between strings
• String alignment
Search for sentence “algorithms are fun”
Find the smallest difference between this document and another document
Slide 11
![Page 12: CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.](https://reader035.fdocuments.in/reader035/viewer/2022062304/56649e2d5503460f94b1c52f/html5/thumbnails/12.jpg)
Too Many Others
Protein networks
DNA sequence alignment
Matrix multiplication
Scheduling problem
Greatest Common Divisor (GCD)
Nearest neighbor (closest gas station to me)
Slide 12
![Page 13: CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.](https://reader035.fdocuments.in/reader035/viewer/2022062304/56649e2d5503460f94b1c52f/html5/thumbnails/13.jpg)
Algorithm Design Phases
-- What are the inputs?-- What are the outputs?-- What is the functionality?
-- Correctness?
-- Efficiency?
Must give the correct answer under all valid inputs
Analyze your algorithm * How fast is it? * Does it consume much resources (CPU, memory, disk, etc…)
-- Choose a language to implement your algorithm (E.g., C, Java, Perl, etc…)
-- Correct implementation !!!
-- Test you algorithm -- Try different inputs-- Check special and corner cases
Slide 13
![Page 14: CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.](https://reader035.fdocuments.in/reader035/viewer/2022062304/56649e2d5503460f94b1c52f/html5/thumbnails/14.jpg)
Course Outline (What You Will Learn)
• Algorithmic Strategies and Methodologies – Tree and graph traversal, Greedy Algorithms, Dynamic
Programming, Divide and Conquer
• Problem Types/Families– Sorting, Searching, Graph and Tree Algorithms, Scheduling and
Optimization, String Processing
• Algorithms on Different Data Structures– Arrays, Trees, Queues, Graphs, Strings, Hash Tables, Linked Lists
• Analysis and Evaluation– Coding and running algorithms, – Analytical analysis using big-O notation
Slide 14
![Page 15: CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.](https://reader035.fdocuments.in/reader035/viewer/2022062304/56649e2d5503460f94b1c52f/html5/thumbnails/15.jpg)
CS223 AlgorithmsD-Term 2013
Course Logistics
Slide 15
![Page 16: CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.](https://reader035.fdocuments.in/reader035/viewer/2022062304/56649e2d5503460f94b1c52f/html5/thumbnails/16.jpg)
Textbook
• Required Introduction to Algorithms
T.H. Cormen, C.E. Leiserson, R.L. Rivest, and C. Stein.
Third Edition, MIT Press, 2009. ISBN 978-0-262-03384-8.
URL: Book Website
Slide 16
Available in bookstore Several copies on reserve in library
![Page 17: CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.](https://reader035.fdocuments.in/reader035/viewer/2022062304/56649e2d5503460f94b1c52f/html5/thumbnails/17.jpg)
Course Logistics
• Website: http://web.cs.wpi.edu/~cs2223/d13
• Electronic WPI system: blackboard.wpi.edu
• Lectures– MTRF (2:00pm - 2:50pm)
• Grading– All assignments are
done individually
Slide 17
![Page 18: CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.](https://reader035.fdocuments.in/reader035/viewer/2022062304/56649e2d5503460f94b1c52f/html5/thumbnails/18.jpg)
Tentative Scheduling
• Tentative scheduling for assignments, exams, and quizzes– Visit the website: http://web.cs.wpi.edu/~cs2223/d13
• Late Submission Policy– One-day late 10% off the max grade – Two-day late 20% off the max grade– Three-day late 30% off the max grade– Beyond that no late submission is accepted
Slide 18
![Page 19: CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.](https://reader035.fdocuments.in/reader035/viewer/2022062304/56649e2d5503460f94b1c52f/html5/thumbnails/19.jpg)
Course Management
• Two systems will be maintained
– Web Page: http://web.cs.wpi.edu/~cs2223/d13
– Electronic WPI system: blackboard.wpi.edu
• Homework/Project submissions
– Either at the beginning of class on the due date
– Or electronically on blackboard.wpi.edu (Recommended)
• Viewing Grades
– On blackboard.wpi.edu
Slide 19
![Page 20: CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.](https://reader035.fdocuments.in/reader035/viewer/2022062304/56649e2d5503460f94b1c52f/html5/thumbnails/20.jpg)
Office Hours
• Posted on the course web page
• Covers most days of the week
• Make use of them– they are there for YOU !
• Feel free to send me email or stop by my office
Slide 20
![Page 21: CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.](https://reader035.fdocuments.in/reader035/viewer/2022062304/56649e2d5503460f94b1c52f/html5/thumbnails/21.jpg)
Programming Language
• In assignments, use a language of your choice– Most students use either Java, C, or Python
• In lectures, I will use pseudocode closer to Java or C
Slide 21
![Page 22: CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.](https://reader035.fdocuments.in/reader035/viewer/2022062304/56649e2d5503460f94b1c52f/html5/thumbnails/22.jpg)
Slide 22