algorithms programs and computers n.
Download
Skip this Video
Download Presentation
Algorithms, Programs, and Computers

Loading in 2 Seconds...

play fullscreen
1 / 29

Algorithms, Programs, and Computers - PowerPoint PPT Presentation


  • 91 Views
  • Uploaded on

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.

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

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


Download Now 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
problem solving
Problem Solving
  • 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
problem solving1
Problem Solving
  • The simpletons can make mistakes
    • Refine the communication of instructions to them
      • Use time cards, tables, flow charts, pictures
      • Develop a bullet proof “process”
problem solving2
Problem Solving
  • 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)
hardware software
Hardware / Software
  • A program is a sequence of instructions that tell the computer what to do
    • What language do computers speak?
    • What language do people speak?
computer language
Computer Language
  • 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
it gets worse
It Gets Worse
  • Computer logic is even more primitive
    • AND
    • OR
    • NOT
  • All programs (nearly every electronic device you use) operates with only these three logical operations
it gets much better
It Gets Much Better
  • Computer software exists to create an abstraction between AND/OR/NOT and human language/logic
  • Programming Languages
    • C++, Java, C#, Perl
slide9
C++

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

printf (“Hello, world\n”);

}

slide10
Java

class program

{

public static void main(String args[]) {

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

}

}

why so many languages
Why So Many Languages?
  • Each has strengths and weaknesses
    • Error protection
      • Syntax in English vs. syntax in German
    • Expressiveness
      • Eskimo words for snow
multipurpose computers
Multipurpose Computers
  • How can computers interpret so many different languages?
    • Translate them all into a common language (machine language)
  • Compilers!
recap problem solving
Recap: Problem Solving
  • 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
algorithms
Algorithms
  • The way one solves a problem
    • Divide and conquer
    • Top-down or bottom-up
    • Simplify
    • Deduction
    • Trial and error
dealing out cards
Dealing Out Cards
  • Poker: deal five cards to everyone at the table

How?

(step by step)

recap algorithms
Recap: Algorithms
  • 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!

complexity
Complexity
  • 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
complexity of cards
Complexity of Cards
  • Consider dealing five cards
    • One second per deal
    • How long to finish dealing five cards to:

2 players

complexity of cards1
Complexity of Cards
  • Consider dealing five cards
    • One second per deal
    • How long to finish dealing five cards to:

3 players

complexity of cards2
Complexity of Cards
  • Consider dealing five cards
    • One second per deal
    • How long to finish dealing five cards to:

4 players

complexity of cards3
Complexity of Cards
  • Consider dealing five cards
    • One second per deal
    • How long to finish dealing five cards to:

100 players

complexity of cards4
Complexity of Cards
  • It takes 5 * num_players time

A Linear Time Algorithm

time

Number of players

complexity of other problems
Complexity of Other Problems
  • Many problems are polynomial (n2)
    • Execution time grows as the square of the problem size (sorting names)

time

Problem size

complexity of other problems1
Complexity of Other Problems
  • Many problems are exponential (2n)
    • Execution time grows as to the nth with increase in problem size (Traveling Salesperson Problem)

time

Problem size

complexity of other problems2
Complexity of Other Problems
  • Some problems are intractable
    • There are 1079 atoms in Universe
    • It would be impossible to solve an algorithm this complex
complexity of other problems3
Complexity of Other Problems
  • Some problems are not computable
    • Literally no end to computation to be donw
recap algorithms1
Recap: Algorithms
  • Algorithms have different complexities
  • Complexity is important to understand
    • What is knowable?
    • How difficult is it to acquire?
ad