Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Algorithms in C and states and graphs, Lecture notes of C programming

Algorithms in C,some examples and notes and interesting stuff

Typology: Lecture notes

2016/2017

Uploaded on 08/28/2017

byron-ramon-banzon
byron-ramon-banzon 🇵🇭

5

(1)

5 documents

1 / 32

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
EEE 11
Programming Fundamentals
Lecture 01: Problem Solving
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20

Partial preview of the text

Download Algorithms in C and states and graphs and more Lecture notes C programming in PDF only on Docsity!

EEE 11

Programming Fundamentals

Lecture 01: Problem Solving

What is a Problem?

◼ A new situation that presents some difficulty that one whishes to address ◼ “Whenever there is a gap between where you are now and where you want to be, and you don’t know how to find a way to cross that gap, you have a problem.”

  • J. Hayes, The Computer Problem Solver , 1990

Understand the Problem

◼ Read the problem completely ◼ Try out examples ◼ Ask questions

▪ What would the result look like? ▪ What are the assumptions and constraints? ◼ Use diagrams and notations ◼ Restate the problem ◼ Avoid assumptions

Devise a Plan

◼ Establish subgoals ◼ Try to recognize something familiar

▪ Recognize patterns ▪ Use analogy ▪ Apply existing strategies ◼ Introduce external elements ◼ Take cases (validate the plan)

Look Back

◼ Be critical of your result ◼ Look for flaws in your solutions ◼ No deficiencies

▪ Use good test cases

Common Problem Solving

Techniques

◼ Work backwards ◼ Use existing models ◼ Solve by elimination ◼ Divide and conquer ◼ Recursion

Use Existing Models

◼ Most problems are just variations of existing problems ◼ Examples:

▪ Get the sum of all numbers from 1 to 100 ▪ Get the sum of all even numbers from 2 to 100

Solve by Elimination

◼ Remove invalid options ◼ Example:

▪ What is the largest prime number less than 100?

Recursion

◼ Find patterns that can be repeated

Computers as Problem Solving

Tools

◼ Computers follow instructions exactly

▪ Consistently applies the steps provided to it ▪ Can repeat as many times without getting tired ▪ Can perform tasks with speed and accuracy ◼ Limitations of Computers

▪ Limited input ▪ Processes digital data only ▪ Instructions have to be clear and concise

Algorithms

Pseudocodes and Flowcharts

Algorithms

◼ A problem solving method suitable for implementation as computer program* ◼ Procedures or formulas to solve a problem ◼ Key properties:

▪ Interpretable ▪ Finite set of instructions ▪ Recognizable end-state, end-point or result

*R. Sedgewick, Algorithms in C , 3 rd^. Ed., Addison-Wesley Publishing Company, Inc., 1998

Algorithms as Pseudocode

◼ Text-based representation of algorithms ◼ Notations from popular programming languages are used ◼ D0ne for human reading, not for machines ◼ No universal standard

Algorithms as Flowcharts

◼ Graphical representation ◼ Different shapes mean different things ◼ Flow of the algorithm is shown by arrows

Input/Output

Process

Decision

Start/Stop