{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

INTRO

# INTRO - INTRODUCTION Why write algorithms(1 To get it out...

This preview shows pages 1–4. Sign up to view the full content.

INTRODUCTION Why write algorithms : (1) To get it out of the head, human memory is unreliable! (2) To communicate with the programmer and other algorithm developers. (3) To prove its correctness, to analyze, to improve its efficiency, … ALGORITHM: What is a computer program? (1) Steps for solving some problem, and (2) the steps written (implemented) in a language to be understood by a compiler program (and eventually by a CPU). Problem Algorithm Program Calculate i=i n i 2 for i = 1 through n do accumulate i 2 in x; return x. public static int sum(int n) { int partialSum = 0; for (int i=1; i<=n; i++) partialSum += i*i; return partialSum; } The first step in solving a computational problem is developing an algorithm. It could be written in a loose fashion or in a rigorous way. Its primary purpose is to communicate the problem solving steps unambiguously . It must be provably correct and should terminate . So, specification = problem definition; algorithm = solution of the problem; program = translation of the algorithm in a computer language.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
COURSE OBJECTIVE: Algorithm development is almost a black art, very much like solving puzzles . There is no way to “teach” algorithm development. So, in this course we will (1) expose you to some important algorithms, e.g., topological-sort , (2) different styles of developing algorithms, e.g. dynamic programming , and (3) how to compare algorithms in an objective way. Our primary concern while writing algorithms is its resource utilization - TIME , SPACE , ( PROCESSORS ) - primarily time . A secondary concern is the understandability of the algorithm. Readability is one of the primary concerns of a software engineer.
ALGORITHM ANALYSIS How do we judge which algorithm “runs” faster? We really cannot! Run times of implementations are CPU dependent, language dependent, programming style dependent, … But we can measure which algorithm takes how many STEPS of computation, assuming that the basic operations like add, multiply, compare etc takes one unit of time on machines for each of such steps, and all computations are done in the main memory ( RAM model of computation). Then again, the number of steps in an algorithm depends on the INPUT SIZE ! So, we measure the number of steps as a FUNCTION of the input-size of the problem. For example, Problem: search a key in an array.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 17

INTRO - INTRODUCTION Why write algorithms(1 To get it out...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online