Module 2: Fundamental Concepts - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Module 2: Fundamental Concepts

Description:

A problem is a mapping or function between a set of inputs and a set of outputs ... One answer. To solve problems. What does it mean to solve a problem? ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 17
Provided by: Eri770
Learn more at: http://www.cse.msu.edu
Category:

less

Transcript and Presenter's Notes

Title: Module 2: Fundamental Concepts


1
Module 2 Fundamental Concepts
  • Problems
  • Programs
  • Programming languages

2
Problems
  • We view solving problems as the main application
    for computer programs

3
Definition
  • A problem is a mapping or function between a set
    of inputs and a set of outputs
  • Example Problem Sorting

(4,2,3,1)
(1,2,3,4)
(3,1,2,4)
(1,5,7)
(7,5,1)
(1,2,3)
(1,2,3)
4
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

5
Example Problem Specifications
  • 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

6
Programs
  • Programs solve problems

7
Purpose
  • Why do we write programs?
  • One answer
  • To solve problems
  • What does it mean to solve a problem?
  • Informal answer For every legal input, a correct
    output is produced.
  • Formal answer To be given later

8
Programming Language
  • Definition
  • A programming language defines what constitutes a
    legal program
  • Example a pseudocode program may not be a legal
    C program which may not be a legal C program
  • A programming language is typically referred to
    as a computational model in a course like this.

9
C
  • Our programming language will be C with minor
    modifications
  • Main procedure will use input parameters in a
    fashion similar to other procedures
  • no argc/argv
  • Output will be returned
  • type specified by main function type

10
Maximum Element Problem
  • Input
  • integer n gt 1
  • List of n integers
  • Output
  • The largest of the n integers

11
C Program which solves the Maximum Element
Problem
  • int main(int A, int n)
  • int i, max
  • if (n lt 1)
  • return (Illegal Input)
  • max A0
  • for (i 1 i lt n i)
  • if (Ai gt max)
  • max Ai
  • return (max)

12
Fundamental Theme
  • Exploring capabilities and limitations of C
    programs

13
Restating the Fundamental Theme
  • We will study the capabilities and limits of C
    programs
  • Specifically, we will try and identify
  • What problems can be solved by C programs
  • What problems cannot be solved by C programs

14
Question
  • Is C general enough?
  • Or is it possible that there exists some problem
    P such that
  • P can be solved by some program P in some other
    reasonable programming language
  • but P cannot be solved by any C program?

15
Churchs Thesis (modified)
  • We have no proof of an answer, but it is commonly
    accepted that the answer is no.
  • Churchs Thesis (three identical statements)
  • 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

16
Summary
  • Problems
  • When we talk about what programs can or cannot
    DO, we mean what PROBLEMS can or cannot be
    solved
Write a Comment
User Comments (0)
About PowerShow.com