Presentation is loading. Please wait.

Presentation is loading. Please wait.

Getting Started with a Problem

Similar presentations


Presentation on theme: "Getting Started with a Problem"— Presentation transcript:

1 Getting Started with a Problem
“Eighty percent of success is showing up.” Woody Allen “Success is 1% inspiration and 99% perspiration.” – Thomas Edison. To successfully solve any problem, the most important step is to get actively involved. The Principle of Intimate Engagement: You must commit to the problem “Roll up your sleeves” “Get your hands dirty.”

2 Easy vs. Hard Problems Exercises: (e.g. compute 10! without a calculator) Easy problems: See the answer Medium problems: See the answer once you engage Hard problems: You need strategies for coming up with a potential solution, sometimes for even getting started. Open-ended problems are often like this. Often, multiple possible solutions, you need a strategy to choose “the best” one. (e.g. Estimate 2710! Why is this one hard? You can use a calculator… )

3 Effective vs. Ineffective Problem Solvers
Effective: Believe that problems can be solved through the use of heuristics and careful persistent analysis Ineffective: Believe ``You either know it or you don't.'' Effective: Active in the problem-solving process: draw figures, make sketches, ask questions of themselves and others. Ineffective: Don't seem to understand the level of personal effort needed to solve the problem. Effective: Take great care to understand all the facts and relationships accurately. Ineffective: Make judgments without checking for accuracy

4 Mental Toughness Need the attributes of confidence and concentration
Confidence comes with practice Attack a new problem with an optimistic attitude Unfortunately, it takes time You can’t turn it on and off at will Need to develop a life-long habit

5 Engagers vs. Dismissers
Engagers typically have a history of success with problem solving. Dismissers have a history of failure. You might be an engager for one type of problem, and a dismisser for another. You can “intervene with yourself” to change your attitude of dismissal

6 Example Problem Connect each box with its same-letter mate without letting the lines cross or leaving the large box. (Actual problem used in software company job interview) A B C

7 Strategy (my favorite): solve a simpler problem first.
C C A 8 8

8 Heuristic: Wishful Thinking
A B C B C A C B A C B A A B C

9 Engagement Example Need to start somewhere,
Cryptoarithmetic problem (base 10) A D + D I D I D Need to start somewhere, find a chink in the problem’s armor

10 The 9 coin problem 9 coins that look alike. One is fake, can be heavier or lighter (not known). Using a simple balance scale and 3 weighings, single out the fake one. Hint: solve a simpler problem first. Which one?

11 The solution for 3 coins:
the weighings are: 1 against 2 1 against 3 Both of these can have three outcomes: fall to the left (l), fall to the right (r), or balance (b). The following table gives the answer for each of these outcomes: outcome fake coin # why: l l too heavy l b too light l r (not possible) b l too light b b no fake coin b r too heavy r l (not possible) r b too heavy r r too light

12 The solution for 9 coins:
Step 1. Divide 9 coins into 3 piles of 3 coins each. Use the 3-coin strategy to weigh: pile 1 against pile 2 pile 1 against pile 3 From Step 1, you will determine: a) which pile contains the fake and b) if the fake is heavier or lighter. Step 2: Weigh 2 coins from the pile that contains fake. Total # of weighings: 2+1 = 3. More: The 12 coins puzzle the 9 coin interactive

13 Introduction

14 Algorithm: History The word ”Algorithm” comes from al-Ḵwārizmī  “the man of Ḵwārizm” (now Khiva), ancient Persia. (9th century AD).

15 Algorithm: Definition
An algorithm is a sequence of finite number of computational steps that transforms the input into the output.

16 “Design an algorithm” problem
We somehow partitioned our class into groups of 3 and 4 students. Now design a an algorithm for any CS2104 class.

17 “Design an algorithm” problem
We somehow partitioned our class into groups of 3 and 4 students. Now design a an algorithm for any CS2104 class. What’s involved: (0) Understand the problem. (1) Analysis: when does the problem have a solution? (one or many? ) (2) When an (exact) solution exists, try finding it (them). Else, try to find an approximation. (3) If necessary, optimize for speed.

18 “Design an algorithm” problem
We somehow partitioned our class into groups of 3 and 4 students. Now design a an algorithm for any CS2104 class. Approach: First, precisely define the problem. What is missing?

19 “Design an algorithm” problem
We somehow partitioned our class into groups of 3 and 4 students. Now design a an algorithm for any CS2104 class. Approach: First step: precisely define the problem. What is missing? Class size N. Typically N> 20 students. 40+ more realistic. But no more than 1000.

20 “Design an algorithm” problem
We somehow partitioned our class into groups of 3 and 4 students. Now design a an algorithm for any CS2104 class. Approach: Second step. Simplify. Solve a series of simpler problems to get clues. N=3,4,5,6,7,….15. Formulate hypothesis.

21 “Design an algorithm” problem
We somehow partitioned our class into groups of 3 and 4 students. Now design a an algorithm for any CS2104 class. Approach: Third step: Existence. The analysis might lead to something. Cases: N= 3k. Obvious: k groups of 3. (works if k>0, N>=3) N=3k+1 = 3(k-1) +4: 1 group of 4, (k-1) of 3. Works if k-1 > 0, k>1, or N>= 7. N=3k+2 = 3(k-2) + 8: 2 groups of 4, (k-2) of 3. works if k-2 > 0, N>=11.

22 Now, the full algorithm: step by step.

23 Homework 2: Partition Class into Groups with a Leader

24 Let’s go further!

25 Design and Analysis of Algorithm: Example
Given n integers in random order, sort them ascendingly. Input Output Algorithm

26 Design and Analysis of Algorithm: Example
Given n integers in random order, sort them ascendingly. Input Output Algorithm 1: brute force

27 Design and Analysis of Algorithm: Example
Given n integers in random order, sort them ascendingly. Input Output Algorithm 2: merge sort

28 Key Question Suppose computers were infinitely fast and computer memory was free. Would you have any reason to study algorithm?

29 Let’s get closer to the real world:
In “Gulliver’s Travels”, by Swift, Gulliver travels to distant parts of the Earth where he meets liliputians who are mere 6 inch tall, and giants who are 72 feet tall. These people are made of the same kind of flesh, muscle and bone; and look pretty much like like Gulliver who is 6 feet tall.

30 Let’s get closer to the real world:
In “Gulliver’s Travels”, by Swift, Gulliver travels to distant parts of the Earth where he meets liliputians who are mere 6 inch tall, and giants who are 72 feet tall. These people are made of the same kind of flesh, muscle and bone; and look pretty much like like Gulliver who is 6 feet tall. Problem 1: It takes one full liliputian glass of their good and strong wine for the liliputian to start feeling joyous. How many such glasses does Gulliver need for the same effect? Problem 2: How many liliputian suites needs to be cut and re-stitched to make a suit to fit Gulliver? Problem 3: According to Gulliver’s story, the giants could stand ( walk, run and jump..) just like Gulliver. Why is this not really possible?

31 Key steps: Problem 1. The larger the volume of the person, the more wine. Number of glasses ~ volume. Need to find ratio of volumes Gulliver/Lilliputian. Key simplification for problems 1-2. Assume human to be a cube of side a. Then V = a3. When a increased by 12, V=a3 goes up by 123. For #2, we need surface area, SA = 6a2. Gulliver’s area ~ 122 x SA(liliputian). For problem #3 needs a more sophisticated simplification. Now, the mass of the body that the bone/leg/muscle has to support is proportional to size a. While the strength of the bone/muscle is proportional to its cross-sections, that is a2. As a grows, the ratio of Mass to strength becomes smaller. So, the giants will crush their bones if they tried to stand up. By the same argument, an ant can lift 40 times its own weight, while a human can only lift about as much as his own weight only. a Body Leg

32 Fig 1. Scaling of length, area, and volume dimensions with body mass.
Dick TJM, Clemente CJ (2017) Where Have All the Giants Gone? How Animals Deal with the Problem of Size. PLOS Biology 15(1): e doi: /journal.pbio

33 Chuck Norris vs. Bruce Lee


Download ppt "Getting Started with a Problem"

Similar presentations


Ads by Google