Lecture01

Document Sample
Lecture01 Powered By Docstoc
					   Lecture 1: Course Overview
• Course: CSE 360
• Instructor: Dr. Eric Torng
• TA: Huamin Chen




                                1
                     Topics
• Course Overview
  – Algorithms
     • Models of Computation
  – Problems
     • Functions or Program Specification
  – What we will be doing in this course



                                            2
      What do people do with
           computers?
• One answer
  – Run programs on them.




                               3
          What is a program?
• Algorithm
  – define difference later
• List of instructions
  – finite
  – definite; no ambiguity




                               4
             Examples
• Dough recipe
• Maximum program




                        5
                 Dough recipe
• Ingredients
  – 3 cups flour
  – 1 cup water
• Instructions
  – bring water to boil
  – thoroughly mix flour and boiling water
  – refrigerate overnight

                                             6
          Maximum program
• Variables
  – integer array A[100]
  – integer max, i;
• Instructions
  – max = A[0];
  – for (i=1;i<100;i++)
     • IF A[i] > max THEN max = A[i];
  – return max;
                                        7
      Models of Computation
• A model of computation is a programming
  language
  – Defines concept of legal programs
     • Dough recipe is not a legal computer program
• Main constraints
  – available resources
  – possible operations
  – (also other parameters)
                                                      8
Difference between program and
           algorithm
• Algorithm
  – high level idea
• Program
  – implementation of algorithm in a specific
    programming language/computational model
     • Different programs can implement the same high
       level algorithm


                                                        9
  Initial Model of Computation
• C++ programming language
• Modified Church’s Thesis
  – C++ is a general model of computation
     • Any algorithm can be expressed as a C++ program
     • If some algorithm cannot be expressed by a C++
       program, it cannot be expressed in any reasonable
       programming language



                                                           10
   What does an algorithm do?
• A specific program/algorithm is written to
  solve a specific problem.




                                               11
          What is a problem?
• A problem is a mapping or function
  between a set of inputs and a set of outputs

• Example
  – Sorting problem
  – Input x: 4 2 3 1
  – Output f(x): 1 2 3 4

                                                 12
             Sorting problem

(4,2,3,1)                         (1,2,3,4)
        (3,1,2,4)

   (7,5,1)              (1,5,7)


      (1,2,3)
                                  (1,2,3)



    Inputs                        Outputs

                                              13
     How to specify a problem
• Input
  – Describe what an input instance looks like
• Output
  – Describe what task should be performed on the
    input
  – In particular, describe what output should be
    produced

                                                 14
         Example Problems
– Sorting Problem
  • Input
     – Integers n1, n2, ..., nk
  • Output
     – n1, n2, ..., nk in nondecreasing order
– Find element problem
  • Input
     – Integers n1, n2, …, nk
     – Search key S
  • Output
     – yes if S is in n1, n2, …, nk, no otherwise
                                                    15
               Observation
• A problem is a SPECIFICATION for a
  program
  – In our case, a problem is very cleanly defined
    and thus there should be little ambiguity in
    what is being requested
  – This is not always true in real life



                                                     16
  What a computer programmer
            does:
• 1) Client gives a problem description to the
  programmer
  – often unclear
  – ask questions!
• 2) You design an algorithm/program to
  solve the problem.


                                                 17
       What do people do with
             problems?
• In programming courses
  – Develop programs to solve these problems
• In this course
  – 1) We will show there exist problems which
    cannot be solved by any C++ program
     • Church’s Thesis
        – What is it and why is it important in this context?
     • Techniques used
        – Diagonalization technique
        – Reduction technique                                   18
What will we do in this course?
– 2) We then will study restricted computational
  models
   • Study what can be done
   • Study what cannot be done




                                                   19
             Quick Review
• Group work
  – What is a “model of computation”?
  – What is a problem?
  – How do we specify a problem?
  – What do programming courses teach you to do
    with problems?
  – What is one thing we are going to teach you
    about problems in this course?
                                                  20
             Key Concepts
• Algorithms and programs
  – models of computation/programming languages
• Problems
  – function
  – program specification
• Unsolvable problems


                                              21

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:1
posted:2/23/2012
language:
pages:21