Presentation is loading. Please wait.

Presentation is loading. Please wait.

Course Description Algorithms are: Recipes for solving problems.

Similar presentations


Presentation on theme: "Course Description Algorithms are: Recipes for solving problems."— Presentation transcript:

1 Algorithms CSCI 235, Spring 2019 Lecture 1 Introduction to Algorithms Read: Chapters 1 and 2 of text

2 Course Description Algorithms are: Recipes for solving problems.
In this course we will learn algorithms for solving typical problems: Sorting Searching Graphs etc. We will focus on design techniques and analysis. 2

3 Design and Analysis Design Techniques: Divide and Conquer
Dynamic Programming Greedy Algorithms etc. Analysis Techniques: How effectively does an algorithm use resources? How much time? How much space?

4 What? No Programming?!? This is a theory course.
We will do little, if any, programming on computers. (But we will write programs in pseudo code). We will learn mathematical techniques to analyze algorithms. (Some may be new to you, but we will go over them in class).

5 Administrivia Much of what you need to know about the course is on the course website: This site contains: Basic information about the course The course schedule Lecture notes The assignment schedule

6 A Simple Example Write a program to find the square of x.
Version 1: Version 3: SQ1(x) SQ3(x) Version 2: SQ2(x)

7 Comparing Algorithms What should we consider when comparing algorithms? Possibilities: Memory Use Number of logic gates needed Computational Time How can we measure time? Number of arithmetic operations Number of assignments Number of times a line is executed

8 Back to the Square Example: V1
We will estimate the running time of our square algorithms by counting the number of times each line is executed. Running time: version 1:

9 Square Example: V2 & V3 Running time: version 2: version 3:

10 Some Consideratons Some lines take longer than others to execute
Some operations take longer than others Counting lines is a rough estimate of relative speed. There are always hidden costs, e.g. increments, tests and assignments in for loops. Sometimes it makes sense to focus on a representative line or lines (e.g. the body of a for loop).

11 Factors Affecting Running Time
Model of Computation: Sequential or Parallel? We will assume: Single Processor Numerical operations take place in constant time. 2. Order of growth. How fast the time increases as the input size increases. Only the dominant term is important. Ignore leading coefficients.

12 More Factors Affecting Running Time
3. Input size. Size of numerical input is the input itself (e.g. x) Size of an array is the length of the array Size of a tree may be the number of nodes or the height There may be more than one size (e.g. search for string of length m in string of length n.) 4. Input itself Running time may differ for different inputs of the same size. Look at Worst case (Maximum time for input of that size--upper bound) Look at Best case (Minimum running time--shows lower bound). Look at Average case (might be difficult to calculate. Often not much better than worst case.)


Download ppt "Course Description Algorithms are: Recipes for solving problems."

Similar presentations


Ads by Google