Introduction to Problem Solving Using Computers Siti Nurbaya

Introduction to Problem Solving Using Computers Siti Nurbaya Ismail Senior Lecturer Faculty of Computer & Mathematical Sciences Universiti Teknologi MARA Kedah (e): sitinurbaya@kedah. uitm. edu. my (u): https: //sitinur 151. wordpress. com 1

Introduction to Problem Solving Using Computers • • • What is a problem and examples of problem Types of problems ( simple and typical real world ) What is a solution and sample of solutions Types of solution ( algorithmic and heuristic ) Steps to solve a problem using computer algorithm Samples of problem solving 2

Introduction to Problem Solving Using Computers Part 1: Problem At the end of this chapter you will be able to; • • Define a problem Describe a solution Explain examples of problem solving using computer Describe the connection between real life process and problem solving using computer 3

What is a problem? Unsettled matter demanding solutions or decision and requiring usually considerable thought or skill for its proper solution or decision Problem *state of difficulty that needs to be resolved or a question raised for consideration or solution *difficulty; a matter about it is difficult to decide what to do or a question to be answered or solve Simple Problem Difficult Problem *may be solved using simple solution *need a complex solution *how make a cup of tea, how to cook a rice and how to log in to instagram account *traffic control, transport schedule and perform transactions using auto teller machines 4

Problem Solving Strategies used to solved problem Heuristics Solution • • Involves intelligent trial and error or reasoning based on knowledge and experience Example: no known algorithm that tell how to play a perfect game of chess, so computer chess playing programs must use a heuristic method of solution, using methods that area likely but not certain to give a good results in any particular case Algorithmic Solution • A clearly specified procedure that is guaranteed to give the correct answer. • computing = algorithmic solutions are express as algorithm can give correct result • algorithm a step by step procedures that accepts data, manipulate them following the prescribed steps, to achieve the desired values or tasks 5

What is solution? • An action or process of solving a problem, also; • The fact or state of a problem being solved, also; • An answer to or means of answering a problem. 6

Relation: Problem & Solution • From the definition, problem and solution are interrelated and therefore; a problem should not be investigated separately from its solution. • Therefore, to solve a problem, three important steps should be performed: I. Understand the problem thoroughly II. Understand the conditions and requirements of the problem III. Search for alternative solutions and select a general solution 7

Problem & Solution Problem Solution How to make a cup of tea? • • Put a tea beg into a cup Pour hot water into the cup Add sugar into the cup Stir 8

Problem & Solution Problem Solution How to log in into an Gmail email account • Open a web browser • Enter URL; www. gmail. com • Enter Google Account username in the Enter Your Email text entry box • Click Next • Enter password in the Password text entry box • Click Sign In button 9

Examples of Problem Solving Typical simple problem solving • Cook a dish – cake – sandwich – fried rice • To get to a destination – From home to Ui. TM Kedah 10

Examples of Problem Solving Typical simple problem solving • Cook a dish: chocalate cake Input Process Output Ingredients Step to make cake Baked cake! 1. Mix Butter + sugar 2. Better + flour + milk + brown sugar + vanilla + baking powder + chocolate powder + egg 3. Baked 11

Examples of Problem Solving Typical simple problem solving • Cook a dish: tuna sandwich Input Process Output Ingredients Step to make sandwich Yummy sandwich! Salad Tuna Tomatoes Bread Mayo 1. Take 2 slice of bread 2. Put salad, tomato, tuna & mayo in between the 2 slice of bread. 12

Examples of Problem Solving Typical real world problems • Transaction – ATM Machine – Web Application • Decision Making – Forecasting • Control Problem – Traffic controller • Searching problems – Search Engines • Sorting problems – Transport Schedule 13

Examples of Problem Solving Using Computer Typical real world problems • Transaction : ATM Machine: Money Withdrawer Input Process Output 14

Examples of Problem Solving Using Computer Typical real world problems • Transaction : Web Application: Online Purchase Input Process Output 15

Examples of Problem Solving Using Computer Typical real world problems • Decision Making : Forecasting : Earthquakes Input Process Output 16

Examples of Problem Solving Using Computer Typical real world problems • Control Problem: Traffic Controller : Traffic Light Input Process Output 17

Examples of Problem Solving Using Computer Typical real world problems • Searching problems: Search Engine : Search for algorithm in youtube website Input Process Output 18

Examples of Problem Solving Using Computer Typical real world problems • Sorting problems: Transport schedule: Construct Bus Schedule Input Process Output 19

Introduction to Problem Solving Next Class…. . Part 2: Problem Solving Development Cycle 20

Problem Solving Development Cycle To perform problem solving using computer Problem solving phases This phase consists of problem definition and algorithm design Implementation phases This phase consists of converting algorithm to program, compiling processes, program testing and program maintenance phases Note: Discussion in the text book only focuses on problem solving phases 21

Problem Solving Phases: Problem Definition • Problem definition = understanding the problem • Purpose = to analyze the problem clearly, precisely and completely. – analyse means try to break up the problem into smaller meaningful workable pieces of information • The solution for the problem depends entirely on the outcome from this phase. 22

Problem Solving Phases: Problem Definition • The analysis should highlight the following important parts 1 • Understand the problem requirement. • Determine what is the required information 2 • List all the facts given in the problem. • Determine how the facts can be used in the solution 3 • Determine the assumption that has to be used. • Avoid from using irrelevant or over assumptions 4 • Determine the data to be used 5 • Determine what data to get from the user 6 • Determine what formulas to be used 7 • How the expected screen looks like • The analysis should clearly, precisely and completely identify the data, the processes that are needed, and the required information 23

Problem Solving Phases: Problem Definition When this phase is not handled carefully, the information gathred may: • Contain errors. • Not accurate (maybe the information is incomplete, it does not solve the entire problem). • Too precise then the information required. 24

Problem Solving Phases: Problem Definition • The important information obtained from the problem definition are: – Data/input needed – Information/output required – Formula/process involved – Expected screen look like Calculate the area of a rectangle. 25

A detail explanation on problem design • Data – raw material that is processed to get the information. Examples: 4. 0, 1800, and 67. 9. • Information – meaningful interpretation of data. – Examples: CGPA is 4. 0, area of a house is 1800 meter square, weight is 67. 9 kilogram Data Information 4. 0 CGPA is 4. 0 1800 The area of a house is 1800 meter square 67. 9 The weight is 67. 9 kilogram 26

A detail explanation on problem design • Real life example: Information Data 27

A detail explanation on problem design • Computer screen – communication channel between the program and user. 28

A detail explanation on problem design • Example 1(a) Task: Calculate the area of a rectangle. Information Area of a rectangle Formula Calculate area: area = length x width Data Length and width Expected screen: Enter a length: Enter a width: The area of a rectangle : data information 29

A detail explanation on problem design • More examples on text book 30

Problem Solving Phases: Algorithm Design • All the information captured from the problem definition phase will be place in a proper order and sequence so as to produce a correct algorithm. 31

What is an algorithm? • No agreed-to definition of "algorithm" exists. • A simple definition: A set of instructions for solving a problem. • The algorithm is either implemented by a program or simulated by a program. • Algorithms often have steps that iterate (repeat ) or require decisions such as logic or comparison. 32

What is an algorithm? • Algorithms are essential to the way computers process information, because a computer program is essentially an algorithm that tells the computer what specific steps to perform (in what specific order) in order to carry out a specified task, such as calculating employees' paychecks or printing students' report cards. • Instructions are usually assumed to be listed explicitly, and are described as starting 'from the top' and going 'down to the bottom', an idea that is described more formally by flow of control. Note: details on algorithm design will be covered in Chapter 3 33

END OF TOPIC 2. Next topic: Basic Concepts of ALGORITHM
- Slides: 34