960 likes | 1.7k Views
Computational Problem Solving. Chin-Sung Lin Eleanor Roosevelt High School. Computational Problem Solving. Problems Problem S olving Approaches Computational Problems Solutions for Computational Problems Impacts of Computational Problem Solving What is an Algorithm?
E N D
Computational Problem Solving Chin-Sung Lin Eleanor Roosevelt High School
Computational Problem Solving • Problems • Problem Solving Approaches • Computational Problems • Solutions for Computational Problems • Impacts of Computational Problem Solving • What is an Algorithm? • Representation of Algorithms – Flow Chart • Representation of Algorithms – Pseudo Code • Algorithms of Skyscrapers Project
Problems are obstacles, difficulties, or challenges which invite solutions
Problems are EVERYWHERE
Problems Education Healthcare Economic Biology Internet Transportation
Problem Solving Approaches 3 Problem Solving Approaches in Science and Engineering Experimental Analytical Computational
Problem Solving Example How can we build a projectile intercepting system?
Problem Solving Approaches Example 3 Problem Solving Approaches (3 Types of Models) Experimental Analytical Computational
Problem Solving Example Analytical (Mathematical) Model
Problem Solving Example Experimental Model
Problem Solving Example Computational (Simulation) Model
Problem Solving Example 3 Problem Solving Approaches (3 Types of Models) Experimental Analytical Computational
Computational Problems • Decision Problems • Function Problems • SearchProblems • Sort Problems • Counting Problems • Optimization Problems
Decision Problems • A computational problem where the answer for every instance is either yes or no. • Example: The primality testing - "Given a positive integer n, determine if n is prime." A decision problem is typically represented as the set of all instances for which the answer is yes.
Function Problems • A computational problem where a single output of a function is expected for every input, but the output is more complex than that of a decision problem, that is, it isn't just YES or NO. • Example: The integer factorization problem, which asks for the list of factors.
Sort Problems • A computational problem where elements of a list need to be put in a certain order. • The most-used orders are numerical order and lexicographical order. • Example: Order the students in a class according to their ages from older to younger.
Search Problems • A computational problem where it searches an element from a given list of elements. • Example: Find students with first name Peter in Elroclasslist.
Counting Problems • A computational problem where it counts the number of occurrences of a type of elements in a set of elements. • Example: A counting problem associated with factoring is "Given a positive integer n, count the number of nontrivial prime factors of n.”
Optimization Problems • A computational problem where it finds the "best possible" solution among the set of all possible solutions. • Example: Use a Google Map to find the shortest path of driving.
Solutions for Computational Problems
Problem Solving Process 4-Step Problem Solving Process Specification Testing Algorithm Programming
Problem Solving Example: Counting Money • Suppose you want to count out a certain amount of money, using the fewest possible US bills and coins • US monetary system: $100, $20, $10, $5, $1, 25¢, 10¢, 5¢, 1¢ • Example: To make $56.39, what should you do?
Problem Solving Example: Counting Money • Suppose you want to count out a certain amount of money, using the fewest possible US bills and coins • US monetary system: $100, $20, $10, $5, $1, 25¢, 10¢, 5¢, 1¢ • Example: To make $56.39, what should you do? • At each step, take the largest possible bill or coin that does not overshoot
Problem Solving Example: Counting Money • Suppose you want to count out a certain amount of money, using the fewest possible US bills and coins • US monetary system: $100, $20, $10, $5, $1, 25¢, 10¢, 5¢, 1¢ • Example: To make $56.39, what should you do? • At each step, take the largest possible bill or coin that does not overshoot • two $20 bills, to make $40 • a $10 bill, to make $50 • a $5 bill, to make $55 • a $1 bill, to make $56 • a 25¢ coin, to make $56.25 • a 10¢ coin, to make $56.35 • four 1¢ coins, to make $56.39
Problem Solving Example: Counting Money • Suppose you want to count out a certain amount of money, using the fewest possible US bills and coins • US monetary system: $100, $20, $10, $5, $1, 25¢, 10¢, 5¢, 1¢ • Example: To make $56.39, what should you do? • At each step, take the largest possible bill or coin that does not overshoot • two $20 bills, to make $40 • a $10 bill, to make $50 • a $5 bill, to make $55 • a $1 bill, to make $56 • a 25¢ coin, to make $56.25 • a 10¢ coin, to make $56.35 • four 1¢ coins, to make $56.39 • For US money, this algorithm always gives the optimum solution
Problem Solving Example: Counting Money • Suppose you want to count out a certain amount of money, using the fewest possible coins • Fictional monetary system: $12, $8, $1 (coins) • Example: To make $17, what should you do?
Problem Solving Example: Counting Money • Suppose you want to count out a certain amount of money, using the fewest possible coins • Fictional monetary system: $12, $8, $1 (coins) • Example: To make $17, what should you do? • At each step, take the largest possible bill or coin that does not overshoot • a $12 coin, to make $12 • five $1 coins, to make $17
Problem Solving Example: Counting Money • Suppose you want to count out a certain amount of money, using the fewest possible coins • Fictional monetary system: $12, $8, $1 (coins) • Example: To make $17, what should you do? • At each step, take the largest possible bill or coin that does not overshoot • a $12 coin, to make $12 • five $1 coins, to make $17 • This algorithm needs six coins and is NOT the optimum solution
Problem Solving Example: Counting Money • Suppose you want to count out a certain amount of money, using the fewest possible coins • Fictional monetary system: $12, $8, $1 (coins) • Example: To make $17, what should you do? • At each step, take the largest possible bill or coin that does not overshoot • a $12 coin, to make $12 • five $1 coins, to make $17 • This algorithm needs six coins and is NOT the optimum solution • The better way is to use
Problem Solving Example: Counting Money • Suppose you want to count out a certain amount of money, using the fewest possible coins • Fictional monetary system: $12, $8, $1 (coins) • Example: To make $17, what should you do? • At each step, take the largest possible bill or coin that does not overshoot • a $12 coin, to make $12 • five $1 coins, to make $17 • This algorithm needs six coins and is NOT the optimum solution • The better way is to use • two $8 coins, to make $16 • a $1 coin, to make $17 • This way needs ONLY three coins and IS the optimum solution
Impacts of Computational Problem Solving
Problem Solving Example: A Kidney Story • Kidney disease affects 50,000 new Americans a year. Kidney Exchanges can save lives! • Kidney transplants are often their best option for saving their life. • The demand for kidneys far outstrips the supply from deceased donors. • For patients with kidney disease, the best option is to find a living donor — a healthy person willing to donate one of their two kidneys. • In a live donation, a potential donor and the intended recipient must be compatible, which can be quite rare. • In order for patients to obtain a compatible donor, they can swap donors. • A pool of incompatible patient-donor pairs where one tries to find swaps is called a kidney exchange.
Problem Solving Example: A Kidney Story • In the simplest exchange, you have two patients each with an available donor kidney, and both patients are compatible with the other’s donor kidney. • When compatibility doesn't match, looking for a third person can make the exchange work —this is called a "3-cycle exchange”. • Longer cycles can yield more matches, but are often difficult to manage. 3-Cycle Exchange 2-Cycle Exchange
Problem Solving Example: A Kidney Story • Consider the exchange below. A patient is connected to a donor if they are biologically compatible. A donor will only donate a kidney if his or her friend also receives a kidney. What is the optimal exchange for this situation? Why? • What technique will you use to solve this problem? How would your technique scale if there were ten donors and patients? 100? Thousands?
Problem Solving Example: A Kidney Story • 60 Lives, 30 Kidneys, All Linked (New York Time article: February 18, 2012) • Prof. TuomasSandholmand his research group from CMU developed an algorithm that can compute the optimal matching for a U.S.-wide kidney exchange (~10,000 patients) in about an hour. The optimal matching is the one that results in the largest number of exchanges. • http://www.nsf.gov/cise/csbytes/newsletter/vol1/vol1i6.html
Problem Solving Example: A Kidney Story • Matching algorithms can be applied to a variety of other problems that require similar barter exchanges. • The National Odd Shoe Exchange lets people with differently sized feet agree to swap shoes to avoid having to buy two pairs each (http://www.oddshoe.org), • Read It Swap It lets people swap books (http://www.readitswapit.co.uk//TheLibrary.aspxx), • Intervacallows people to swap vacation houses (http://www.intervac-homeexchange.com), and • Netcyclerallows people to swap, give away, and get items for free (www.netcycler.com).
An Algorithm is a finite set of well-defined instructions for effectively carrying out a procedure or solving a problem.
An Algorithm is a finite set of well-defined instructions for effectively carrying out a procedure or solving a problem.
Representations of Algorithms • Show the logic of how the problem is solved - not how it is implemented. • Readily reveal the flow of the algorithm. • Be expandable and collapsible. • Lend itself to implementation of the algorithm.
Representations of Algorithms • Flowcharts • Graphical representation of control flow • Pseudocode • A sequence of statements, more precise notation • Not a programming language, no formal syntax
Representation of Algorithms – Flow Chart
Start or stop Representation - Flowcharts Process Elements of flowcharts Input or output Decision Flow line Connector Off-page connector
Examples of Flowcharts An algorithm for findingthe area of a circle of radiusr.