Algorithms programs and computers
Download
1 / 29

Algorithms, Programs, and Computers - PowerPoint PPT Presentation


  • 91 Views
  • Updated 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


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


C++

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

printf (“Hello, world\n”);

}


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