1 / 29

# Algorithms, Programs, and Computers - PowerPoint PPT Presentation

Algorithms, Programs, and Computers. CS 110 Fall 2005. Problem Solving. You want to make money and you have some simpletons who are willing to help Devise a plan that will make money (write a business plan for starting a restaurant) Tell the simpletons to execute the business plan.

Related searches for Algorithms, Programs, and Computers

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

## PowerPoint Slideshow about 'Algorithms, Programs, and Computers' - lok

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### Algorithms, Programs, and Computers

CS 110

Fall 2005

• You want to make money and you have some simpletons who are willing to help

• Devise aplan that will make money (write a business plan for starting a restaurant)

• Tell the simpletons to execute the business plan

• The simpletons can make mistakes

• Refine the communication of instructions to them

• Use time cards, tables, flow charts, pictures

• Develop a bullet proof “process”

• You want to make money and you have a computer to help you

• Devise an algorithm (plan)

• Make the algorithm very detailed so a simpleton can do it (program)

• Execute the program (computer)

• A program is a sequence of instructions that tell the computer what to do

• What language do computers speak?

• What language do people speak?

• Assembly Language

• ADD R1, R2

• MOV [R5], R1

• IF (R4 < R2) JMP A:

• Very sequential

• Like a flow chart

• Not the language of human users

• Computer logic is even more primitive

• AND

• OR

• NOT

• All programs (nearly every electronic device you use) operates with only these three logical operations

• Computer software exists to create an abstraction between AND/OR/NOT and human language/logic

• Programming Languages

• C++, Java, C#, Perl

void main (int argc, char **argv) {

printf (“Hello, world\n”);

}

class program

{

public static void main(String args[]) {

System.out.println("Hello World!");

}

}

• Each has strengths and weaknesses

• Error protection

• Syntax in English vs. syntax in German

• Expressiveness

• Eskimo words for snow

• How can computers interpret so many different languages?

• Translate them all into a common language (machine language)

• Compilers!

• Computers execute machine language

• Programs are a sequence of instructions in some language

• Compilers transform programs from one language to another, usually a simpler one

• The way one solves a problem

• Divide and conquer

• Top-down or bottom-up

• Simplify

• Deduction

• Trial and error

• Poker: deal five cards to everyone at the table

How?

(step by step)

• An approach to solving a problem

• A sequence of steps

• Break a complex problem into simpler pieces

The first step in making computers work for you!

• There’s a danger here

• Time is scarce

• Simple algorithms may entail inordinate time and resources

• Computers are simpletons

• We must think about an algorithm’s complexity before using it

• Consider dealing five cards

• One second per deal

• How long to finish dealing five cards to:

2 players

• Consider dealing five cards

• One second per deal

• How long to finish dealing five cards to:

3 players

• Consider dealing five cards

• One second per deal

• How long to finish dealing five cards to:

4 players

• Consider dealing five cards

• One second per deal

• How long to finish dealing five cards to:

100 players

• It takes 5 * num_players time

A Linear Time Algorithm

time

Number of players

• Many problems are polynomial (n2)

• Execution time grows as the square of the problem size (sorting names)

time

Problem size

• Many problems are exponential (2n)

• Execution time grows as to the nth with increase in problem size (Traveling Salesperson Problem)

time

Problem size

• Some problems are intractable

• There are 1079 atoms in Universe

• It would be impossible to solve an algorithm this complex

• Some problems are not computable

• Literally no end to computation to be donw

• Algorithms have different complexities

• Complexity is important to understand

• What is knowable?

• How difficult is it to acquire?