COS 121

Cards (35)

  • Problem
    An unpleasant situation or condition which a better or perfect state is desired
  • Present state

    The current situation
  • Goal state
    The desired state to be reached
  • Types of problems
    • Routine problems
    • Non-routine problems
  • Routine problems
    Problems with simple, predictable solutions
  • Non-routine problems

    Problems with subjective, abstract and complex solutions
  • Problem solving
    The application of ideas, skills, or factual information as inputs in specific sequence of steps to attain to the solution to a problem or to reach a desired goal state
  • Solution
    The sequence of steps to solve a problem
  • One problem can have multiple solutions
  • Not all problems have straightforward solutions, some require trial and error
  • Algorithmic solution
    Solutions to problems in which the desired state is achieved by a defined and finite sequence of steps
  • Heuristic solution

    Solutions to problems in which the goal state is reached by series of steps which emerge from knowledge, experience and trial and error
  • This course focuses on algorithmic solutions that can be solved by computers
  • Solution techniques
    • Abstraction
    • Analogy
    • Brainstorming
    • Trial-and-error
    • Hypothesis testing
    • Reduction
    • Divide and Conquer
    • Lateral thinking
    • Means-ends analysis
    • Method of focal objects
    • Morphological analysis
    • Research
    • Root cause analysis
    • Proof
  • Computers are built to deal with algorithmic solutions, which are often difficult or very time consuming for humans
  • Humans can arrive at heuristic solutions better than computers
  • The field of computer science that deals with heuristic problems is called Artificial Intelligence (AI)
  • Steps of problem solving
    • Identify the problem
    • Understand the problem
    • Identify alternative solutions
    • Select the best solution
    • List instructions for the solution
    • Evaluate the solution
  • Algorithm
    Shows the sequence of instructions comprising the solution to a problem
  • Flowchart
    A graphical representation of an algorithm
  • Pseudo code
    An informal human language-like description of the algorithm (steps) to arrive at a solution
  • Designing an Algorithm
    1. Identify the Inputs (I)
    2. Identify the Process (P)
    3. Identify the Output (O)
  • Characteristics of an Algorithm
    • Emphasize on the 'what' and not the 'how'
    • Each step must be exact
    • Must begin and terminate
    • Must be effective
    • Must be general
  • Problem 1
    • Calculate the gross pay of an employee given the hours worked and the rate of pay
  • Algorithm Design for Problem 1
    1. Input Hours, PayRate
    2. Calculate the GrossPay by multiplying Hours by PayRate
    3. Output the GrossPay
  • The Algorithm for Problem 1
  • Flowchart
    A graphical representation of an algorithm that shows the logic and sequence of steps
  • Flowchart Symbols

    • Flow lines
    • Start/End
    • Processing block
    • Input/Output
    • Decision
    • Modules
    • Loop
    • On-page connector
    • Off-page connector
  • Uses of Flowcharts
    • Facilitate communication
    • Play a vital role in programming
    • Helpful for understanding complicated problems
    • Ease of writing programs
  • Rules for drawing Flowcharts
  • Pseudo code
    1. A plain language description of the steps in an algorithm
    2. Similar to algorithm but more condensed
    3. Closer to programming language
  • Differences between Algorithm and Pseudo code
  • Pseudo code for Problem 1
    1. Input Hours, PayRate
    2. Calculate the GrossPay: GrossPay = Hours * PayRate
    3. Display the GrossPay
  • Problem 2: Determine the VOLUME of a sphere

    1. Input Sphere Radius (r)
    2. Compute the Volume (V) using formula: V = (4/3) *pi*r3
    3. Display the Volume (V)
  • Problem 3: Convert temperature in Degrees Celsius (oC) to Degrees Fahrenheit (oF)
    1. Input Temperature value (oC)
    2. Convert to temperature value (oF) using formula: F = (9/5)*C+32
    3. Display temperature value (oF)