SlideShare a Scribd company logo
1 of 47
Download to read offline
Becoming a Better
    Problem Solver:
    A CS Perspective

             Melvin Zhang
           melvinzhang.net
      http://www.slideshare.net/melvinzhang/
becoming-a-better-problem-solver-a-cs-perspective


            January 20, 2012
Becoming a Better Problem Solver:
A CS Perspective
Outline

  What is problem solving?

  Strategies and tactics
      Getting started (Strategies)
      Making progress (Tactics)

  Summary

  What I’m working on
P´lya’s Mouse
 o
P´lya’s Mouse
 o

                A good problem solver
                doesn’t give up easily, but
                don’t keep banging your
                head on the same part of
                the wall.

                The key is to vary each
                attempt.
References
References
What is problem solving?



  Problem solving is the process of tackling
  problems in a systematic and rational way.
Steps in problem solving
                    Understanding
                     the problem




     Looking back                  Devising a plan




                    Carrying out
                      the plan
Outline

  What is problem solving?

  Strategies and tactics
      Getting started (Strategies)
      Making progress (Tactics)

  Summary

  What I’m working on
Strategies, tactics and tools

  Strategies
  General approaches and psychological hints for
  starting and pursuing problems.
  Tactics
  Diverse methods that work in many different
  settings.
  Tools
  Narrowly focused techniques and ”tricks” for
  specific situations.
Outline

  What is problem solving?

  Strategies and tactics
      Getting started (Strategies)
      Making progress (Tactics)

  Summary

  What I’m working on
Strategy 1. Get your hands dirty
Example: Generating Gray codes
  Named after Frank Gray, a researcher from Bell
  Labs. Refers to a special type of binary code in
  which adjacent codes different at only one position.

                   3-bit binary code
                          000
                          001
                          010
                          011
                          100
                          101
                          110
                          111
Example: Generating Gray codes

    1-bit         2-bit          3-bit
      0            00            000
      1            01            001
                   11            011
                   10            010
                                 110
                                 111
                                 101
                                 100
Applications of Gray codes




     Figure: Rotary encoder for angle-measuring devices


     Used in position encoder (see figure).
     Labelling the axis of Karnaugh maps.
     Designing error correcting codes.
Strategy 2. Restate the problem

  The problem as it is stated may not have an obvious
  solution. Try to restate the problem in a different
  way.
  Find the Inverse
   Original Given a set of object, find an object
            satisfying some property P.
    Inverse Find all of the objects which does NOT
            satisfy P.
Example: Invitation



                      You want to invite the
                      largest group of friends,
                      so that each person know
                      at least k others at the
                      party.
Invitation

  Direct approach
   1. For each subset of friends, check if everyone
      knows at least k others.
   2. Return the largest set of friends.

  Looking back
  Works but there are potentially 2n subsets to check,
  where n is the number of friends.
Invitation


  Find the Inverse
  Instead of finding the largest group to invite, find
  the smallest group that is left out.
  Observation
  A person with less than k friends must be left out.
Strategy 3. Wishful thinking




  Make the problem simpler by removing the source
  of difficulty!
    1. Identify what makes the problem difficult.
    2. Remove or reduce the difficulty.
Example: Largest rectangle




  Find the largest white rectangle in an n × n grid.
  There is an easy solution which checks all
  rectangles. There are n × n ≈ n4 rectangles.
                          2    2
Example: Largest rectangle


  2D seems to be difficult, how about 1D?




  There are n segments in a row, but we can find
              2
  the longest white segment using a single scan of the
  row. What is that so?
Example: Next Gray code
  Given an n-bit Gray code, find the next code.

                   3-bit Gray code
                         000
                         001
                         011
                         010
                         110
                         111
                         101
                         100
Example: Next Gray code

  Gray code is tough! What if we worked in binary?

          Gray code             Binary code

             111                    101


             101                    110
Outline

  What is problem solving?

  Strategies and tactics
      Getting started (Strategies)
      Making progress (Tactics)

  Summary

  What I’m working on
Making progress
  Record your progress
  Any form of progress is good, record your workings
  and keep track of interesting ideas/observations.




                             Sometimes, you might
                             have to sleep on it.
Story of RSA




  Figure: Left to right: Adi Shamir, Ron Rivest, Len Adleman
Tactic 1. Extremal principle


  Given a choice, it is useful to consider items which
  are extreme.
       Tallest/shortest
       Leftmost/rightmost
       Largest/smallest
Example: Activity selection
  Each bar represents an activity with a particular
  start and end time. Find the largest set of activities
  with no overlap.
Example: Activity selection
  An intuitive approach is to repeatedly pick the
  leftmost activity.




     Does this produce the largest set of activities?
Example: Activity selection

  This method may be fooled! Consider the following:
Example: Activity selection

  How would you normally pick among a set of tasks?
  Do the one with the earliest deadline first!
Tactic 2. Exploit symmetry
Example: Gray code to binary code
          3-bit Gray code 3-bit binary code
                000              000
                001              001
                011              010
                010              011
                110              100
                111              101
                101              110
                100              111
  Some observations:
     The leftmost column is always the same.
     After a column of ones, the order flips
     (reflection).
Example: Gray code to binary code

    3-bit Gray code
          000
          001
                        Order     0   1   0
          011
                                  1   0   1
          010
                       Gray code 1    1   0
          110
                      Binary code 1   0   0
          111
          101
          100
Tactic 3. Space-time tradeoff



  Trading space for time: lookup tables, caching
  Trading time for space: recalculation
Example: Computing segment sums

  Given an array A of integers, compute the sum of
  any segment A[i, j] efficiently.

               6 4 -3 0 5 1 8 7

  For example,
       A[1, 3] = 6 + 4 + −3 = 7
       A[3, 7] = −3 + 0 + 5 + 1 + 8 = 11
Example: Computing segment sums

  Wishful thinking Computing for any segment A[i, j]
             is difficult, what if we consider only
             segments of the form A[1, j]?
  Space-time tradeoff Sums for A[1, j] can be
             precomputed and stored in a another
             array P

          A 6 4 -3 0 5 1 8 7
          P 6 10 7 7 12 13 24 31
Example: Computing segment sums


          A 6 4 -3 0 5 1 8 7
          P 6 10 7 7 12 13 24 31

  Observation
  The sum for A[i, j] can be computed as
  P[j] − P[i] + A[i].
Example: Computing segment sums


  Looking back
     What is special about sum?
     Does this work with max/min? If not, can the
     idea be adapted?
Outline

  What is problem solving?

  Strategies and tactics
      Getting started (Strategies)
      Making progress (Tactics)

  Summary

  What I’m working on
Strategies and tactics



 Strategies                 Tactics
  1. Get your hands dirty    1. Extremal principle
  2. Restate the problem     2. Exploit symmetry
  3. Wishful thinking        3. Space-time tradeoff
If there is a problem you can’t solve, then
there is an easier problem you can solve:
find it.




                                   George P´lya
                                           o
Outline

  What is problem solving?

  Strategies and tactics
      Getting started (Strategies)
      Making progress (Tactics)

  Summary

  What I’m working on
developer.hoiio.com
magarena.googlecode.com

More Related Content

Similar to Becoming a better problem solver: a CS perspective

Module 3_Problem Solving With Logic.pptx
Module 3_Problem Solving With Logic.pptxModule 3_Problem Solving With Logic.pptx
Module 3_Problem Solving With Logic.pptxClaudineBaladjay1
 
Chapter 10: Error Correction and Detection
Chapter 10: Error Correction and DetectionChapter 10: Error Correction and Detection
Chapter 10: Error Correction and DetectionJeoffnaRuth
 
Algorithm and flowchart with pseudo code
Algorithm and flowchart with pseudo codeAlgorithm and flowchart with pseudo code
Algorithm and flowchart with pseudo codehamza javed
 
6 3 Notes A
6 3 Notes A6 3 Notes A
6 3 Notes Ambetzel
 
There are two types of ciphers - Block and Stream. Block is used to .docx
There are two types of ciphers - Block and Stream. Block is used to .docxThere are two types of ciphers - Block and Stream. Block is used to .docx
There are two types of ciphers - Block and Stream. Block is used to .docxrelaine1
 
lecture notes about decision tree. Its a very good
lecture notes about decision tree. Its a very goodlecture notes about decision tree. Its a very good
lecture notes about decision tree. Its a very goodranjankumarbehera14
 
January 29 30
January 29 30January 29 30
January 29 30khyps13
 
2020 1학기 정기스터디 1주차
2020 1학기 정기스터디 1주차2020 1학기 정기스터디 1주차
2020 1학기 정기스터디 1주차Moonki Choi
 
Beyond Floating Point – Next Generation Computer Arithmetic
Beyond Floating Point – Next Generation Computer ArithmeticBeyond Floating Point – Next Generation Computer Arithmetic
Beyond Floating Point – Next Generation Computer Arithmeticinside-BigData.com
 
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1johnnygoodman
 
PowerPoint_Ch2_Section2.1 and 2.2.pdf
PowerPoint_Ch2_Section2.1 and 2.2.pdfPowerPoint_Ch2_Section2.1 and 2.2.pdf
PowerPoint_Ch2_Section2.1 and 2.2.pdfamimoronaldodhiambo
 
Grade 9 Uo-L4-Scientific No & Sig Dig
Grade 9 Uo-L4-Scientific No & Sig DigGrade 9 Uo-L4-Scientific No & Sig Dig
Grade 9 Uo-L4-Scientific No & Sig Diggruszecki1
 
Skills_Level 2 Functional Slkills Maths.
Skills_Level 2 Functional Slkills Maths.Skills_Level 2 Functional Slkills Maths.
Skills_Level 2 Functional Slkills Maths.DemJawo
 
Combinatorial Problems2
Combinatorial Problems2Combinatorial Problems2
Combinatorial Problems23ashmawy
 

Similar to Becoming a better problem solver: a CS perspective (20)

Introduction to Computing
Introduction to ComputingIntroduction to Computing
Introduction to Computing
 
Module 3_Problem Solving With Logic.pptx
Module 3_Problem Solving With Logic.pptxModule 3_Problem Solving With Logic.pptx
Module 3_Problem Solving With Logic.pptx
 
Chapter 10: Error Correction and Detection
Chapter 10: Error Correction and DetectionChapter 10: Error Correction and Detection
Chapter 10: Error Correction and Detection
 
Algorithm and flowchart with pseudo code
Algorithm and flowchart with pseudo codeAlgorithm and flowchart with pseudo code
Algorithm and flowchart with pseudo code
 
Anti-Patterns
Anti-PatternsAnti-Patterns
Anti-Patterns
 
Lop1
Lop1Lop1
Lop1
 
Ninja Cursors
Ninja CursorsNinja Cursors
Ninja Cursors
 
2 significant-fig
2  significant-fig2  significant-fig
2 significant-fig
 
Icom4015 lecture12-s16
Icom4015 lecture12-s16Icom4015 lecture12-s16
Icom4015 lecture12-s16
 
6 3 Notes A
6 3 Notes A6 3 Notes A
6 3 Notes A
 
There are two types of ciphers - Block and Stream. Block is used to .docx
There are two types of ciphers - Block and Stream. Block is used to .docxThere are two types of ciphers - Block and Stream. Block is used to .docx
There are two types of ciphers - Block and Stream. Block is used to .docx
 
lecture notes about decision tree. Its a very good
lecture notes about decision tree. Its a very goodlecture notes about decision tree. Its a very good
lecture notes about decision tree. Its a very good
 
January 29 30
January 29 30January 29 30
January 29 30
 
2020 1학기 정기스터디 1주차
2020 1학기 정기스터디 1주차2020 1학기 정기스터디 1주차
2020 1학기 정기스터디 1주차
 
Beyond Floating Point – Next Generation Computer Arithmetic
Beyond Floating Point – Next Generation Computer ArithmeticBeyond Floating Point – Next Generation Computer Arithmetic
Beyond Floating Point – Next Generation Computer Arithmetic
 
CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1CPAP.com Introduction to Coding: Part 1
CPAP.com Introduction to Coding: Part 1
 
PowerPoint_Ch2_Section2.1 and 2.2.pdf
PowerPoint_Ch2_Section2.1 and 2.2.pdfPowerPoint_Ch2_Section2.1 and 2.2.pdf
PowerPoint_Ch2_Section2.1 and 2.2.pdf
 
Grade 9 Uo-L4-Scientific No & Sig Dig
Grade 9 Uo-L4-Scientific No & Sig DigGrade 9 Uo-L4-Scientific No & Sig Dig
Grade 9 Uo-L4-Scientific No & Sig Dig
 
Skills_Level 2 Functional Slkills Maths.
Skills_Level 2 Functional Slkills Maths.Skills_Level 2 Functional Slkills Maths.
Skills_Level 2 Functional Slkills Maths.
 
Combinatorial Problems2
Combinatorial Problems2Combinatorial Problems2
Combinatorial Problems2
 

More from Melvin Zhang

How Alan Turing accidentally invented Software
How Alan Turing accidentally invented SoftwareHow Alan Turing accidentally invented Software
How Alan Turing accidentally invented SoftwareMelvin Zhang
 
Solving the TSP for warehouses
Solving the TSP for warehousesSolving the TSP for warehouses
Solving the TSP for warehousesMelvin Zhang
 
Optimize all the things with MiniZinc
Optimize all the things with MiniZincOptimize all the things with MiniZinc
Optimize all the things with MiniZincMelvin Zhang
 
AMKSS Career Conference 2018: Software Engineering
AMKSS Career Conference 2018: Software EngineeringAMKSS Career Conference 2018: Software Engineering
AMKSS Career Conference 2018: Software EngineeringMelvin Zhang
 
Beating us at our own Games
Beating us at our own GamesBeating us at our own Games
Beating us at our own GamesMelvin Zhang
 
Getting started with open source game playing AIs
Getting started with open source game playing AIsGetting started with open source game playing AIs
Getting started with open source game playing AIsMelvin Zhang
 
Programs that Play better than Us
Programs that Play better than UsPrograms that Play better than Us
Programs that Play better than UsMelvin Zhang
 
Building a Turing Machine emulator to explore Turing's great ideas
Building a Turing Machine emulator to explore Turing's great ideasBuilding a Turing Machine emulator to explore Turing's great ideas
Building a Turing Machine emulator to explore Turing's great ideasMelvin Zhang
 
Lessons from Developing an AI to Play Magic: The Gathering
Lessons from Developing an AI to Play Magic: The GatheringLessons from Developing an AI to Play Magic: The Gathering
Lessons from Developing an AI to Play Magic: The GatheringMelvin Zhang
 
Functional programming from first principles
Functional programming from first principlesFunctional programming from first principles
Functional programming from first principlesMelvin Zhang
 
Binary Lambda Calculus and Combinatory Logic
Binary Lambda Calculus and Combinatory LogicBinary Lambda Calculus and Combinatory Logic
Binary Lambda Calculus and Combinatory LogicMelvin Zhang
 
AMKSS Career Conference 2015: Programming
AMKSS Career Conference 2015: ProgrammingAMKSS Career Conference 2015: Programming
AMKSS Career Conference 2015: ProgrammingMelvin Zhang
 
Building a state of the art AI to play Magic: The Gathering
Building a state of the art AI to play Magic: The GatheringBuilding a state of the art AI to play Magic: The Gathering
Building a state of the art AI to play Magic: The GatheringMelvin Zhang
 
Efficient Selectivity and Backup Operators in Monte-Carlo Tree Search
Efficient Selectivity and Backup Operators in Monte-Carlo Tree SearchEfficient Selectivity and Backup Operators in Monte-Carlo Tree Search
Efficient Selectivity and Backup Operators in Monte-Carlo Tree SearchMelvin Zhang
 
Quest for the optimal algorithm
Quest for the optimal algorithmQuest for the optimal algorithm
Quest for the optimal algorithmMelvin Zhang
 
Playing Games by Throwing Dice
Playing Games by Throwing DicePlaying Games by Throwing Dice
Playing Games by Throwing DiceMelvin Zhang
 
Ortholog assignment
Ortholog assignmentOrtholog assignment
Ortholog assignmentMelvin Zhang
 
Building pipelines with Make
Building pipelines with MakeBuilding pipelines with Make
Building pipelines with MakeMelvin Zhang
 
Opportunities in STEM
Opportunities in STEMOpportunities in STEM
Opportunities in STEMMelvin Zhang
 

More from Melvin Zhang (19)

How Alan Turing accidentally invented Software
How Alan Turing accidentally invented SoftwareHow Alan Turing accidentally invented Software
How Alan Turing accidentally invented Software
 
Solving the TSP for warehouses
Solving the TSP for warehousesSolving the TSP for warehouses
Solving the TSP for warehouses
 
Optimize all the things with MiniZinc
Optimize all the things with MiniZincOptimize all the things with MiniZinc
Optimize all the things with MiniZinc
 
AMKSS Career Conference 2018: Software Engineering
AMKSS Career Conference 2018: Software EngineeringAMKSS Career Conference 2018: Software Engineering
AMKSS Career Conference 2018: Software Engineering
 
Beating us at our own Games
Beating us at our own GamesBeating us at our own Games
Beating us at our own Games
 
Getting started with open source game playing AIs
Getting started with open source game playing AIsGetting started with open source game playing AIs
Getting started with open source game playing AIs
 
Programs that Play better than Us
Programs that Play better than UsPrograms that Play better than Us
Programs that Play better than Us
 
Building a Turing Machine emulator to explore Turing's great ideas
Building a Turing Machine emulator to explore Turing's great ideasBuilding a Turing Machine emulator to explore Turing's great ideas
Building a Turing Machine emulator to explore Turing's great ideas
 
Lessons from Developing an AI to Play Magic: The Gathering
Lessons from Developing an AI to Play Magic: The GatheringLessons from Developing an AI to Play Magic: The Gathering
Lessons from Developing an AI to Play Magic: The Gathering
 
Functional programming from first principles
Functional programming from first principlesFunctional programming from first principles
Functional programming from first principles
 
Binary Lambda Calculus and Combinatory Logic
Binary Lambda Calculus and Combinatory LogicBinary Lambda Calculus and Combinatory Logic
Binary Lambda Calculus and Combinatory Logic
 
AMKSS Career Conference 2015: Programming
AMKSS Career Conference 2015: ProgrammingAMKSS Career Conference 2015: Programming
AMKSS Career Conference 2015: Programming
 
Building a state of the art AI to play Magic: The Gathering
Building a state of the art AI to play Magic: The GatheringBuilding a state of the art AI to play Magic: The Gathering
Building a state of the art AI to play Magic: The Gathering
 
Efficient Selectivity and Backup Operators in Monte-Carlo Tree Search
Efficient Selectivity and Backup Operators in Monte-Carlo Tree SearchEfficient Selectivity and Backup Operators in Monte-Carlo Tree Search
Efficient Selectivity and Backup Operators in Monte-Carlo Tree Search
 
Quest for the optimal algorithm
Quest for the optimal algorithmQuest for the optimal algorithm
Quest for the optimal algorithm
 
Playing Games by Throwing Dice
Playing Games by Throwing DicePlaying Games by Throwing Dice
Playing Games by Throwing Dice
 
Ortholog assignment
Ortholog assignmentOrtholog assignment
Ortholog assignment
 
Building pipelines with Make
Building pipelines with MakeBuilding pipelines with Make
Building pipelines with Make
 
Opportunities in STEM
Opportunities in STEMOpportunities in STEM
Opportunities in STEM
 

Recently uploaded

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 

Recently uploaded (20)

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 

Becoming a better problem solver: a CS perspective

  • 1. Becoming a Better Problem Solver: A CS Perspective Melvin Zhang melvinzhang.net http://www.slideshare.net/melvinzhang/ becoming-a-better-problem-solver-a-cs-perspective January 20, 2012
  • 2. Becoming a Better Problem Solver: A CS Perspective
  • 3. Outline What is problem solving? Strategies and tactics Getting started (Strategies) Making progress (Tactics) Summary What I’m working on
  • 5. P´lya’s Mouse o A good problem solver doesn’t give up easily, but don’t keep banging your head on the same part of the wall. The key is to vary each attempt.
  • 8. What is problem solving? Problem solving is the process of tackling problems in a systematic and rational way.
  • 9. Steps in problem solving Understanding the problem Looking back Devising a plan Carrying out the plan
  • 10. Outline What is problem solving? Strategies and tactics Getting started (Strategies) Making progress (Tactics) Summary What I’m working on
  • 11. Strategies, tactics and tools Strategies General approaches and psychological hints for starting and pursuing problems. Tactics Diverse methods that work in many different settings. Tools Narrowly focused techniques and ”tricks” for specific situations.
  • 12. Outline What is problem solving? Strategies and tactics Getting started (Strategies) Making progress (Tactics) Summary What I’m working on
  • 13. Strategy 1. Get your hands dirty
  • 14. Example: Generating Gray codes Named after Frank Gray, a researcher from Bell Labs. Refers to a special type of binary code in which adjacent codes different at only one position. 3-bit binary code 000 001 010 011 100 101 110 111
  • 15. Example: Generating Gray codes 1-bit 2-bit 3-bit 0 00 000 1 01 001 11 011 10 010 110 111 101 100
  • 16. Applications of Gray codes Figure: Rotary encoder for angle-measuring devices Used in position encoder (see figure). Labelling the axis of Karnaugh maps. Designing error correcting codes.
  • 17. Strategy 2. Restate the problem The problem as it is stated may not have an obvious solution. Try to restate the problem in a different way. Find the Inverse Original Given a set of object, find an object satisfying some property P. Inverse Find all of the objects which does NOT satisfy P.
  • 18. Example: Invitation You want to invite the largest group of friends, so that each person know at least k others at the party.
  • 19. Invitation Direct approach 1. For each subset of friends, check if everyone knows at least k others. 2. Return the largest set of friends. Looking back Works but there are potentially 2n subsets to check, where n is the number of friends.
  • 20. Invitation Find the Inverse Instead of finding the largest group to invite, find the smallest group that is left out. Observation A person with less than k friends must be left out.
  • 21. Strategy 3. Wishful thinking Make the problem simpler by removing the source of difficulty! 1. Identify what makes the problem difficult. 2. Remove or reduce the difficulty.
  • 22. Example: Largest rectangle Find the largest white rectangle in an n × n grid. There is an easy solution which checks all rectangles. There are n × n ≈ n4 rectangles. 2 2
  • 23. Example: Largest rectangle 2D seems to be difficult, how about 1D? There are n segments in a row, but we can find 2 the longest white segment using a single scan of the row. What is that so?
  • 24. Example: Next Gray code Given an n-bit Gray code, find the next code. 3-bit Gray code 000 001 011 010 110 111 101 100
  • 25. Example: Next Gray code Gray code is tough! What if we worked in binary? Gray code Binary code 111 101 101 110
  • 26. Outline What is problem solving? Strategies and tactics Getting started (Strategies) Making progress (Tactics) Summary What I’m working on
  • 27. Making progress Record your progress Any form of progress is good, record your workings and keep track of interesting ideas/observations. Sometimes, you might have to sleep on it.
  • 28. Story of RSA Figure: Left to right: Adi Shamir, Ron Rivest, Len Adleman
  • 29. Tactic 1. Extremal principle Given a choice, it is useful to consider items which are extreme. Tallest/shortest Leftmost/rightmost Largest/smallest
  • 30. Example: Activity selection Each bar represents an activity with a particular start and end time. Find the largest set of activities with no overlap.
  • 31. Example: Activity selection An intuitive approach is to repeatedly pick the leftmost activity. Does this produce the largest set of activities?
  • 32. Example: Activity selection This method may be fooled! Consider the following:
  • 33. Example: Activity selection How would you normally pick among a set of tasks? Do the one with the earliest deadline first!
  • 34. Tactic 2. Exploit symmetry
  • 35. Example: Gray code to binary code 3-bit Gray code 3-bit binary code 000 000 001 001 011 010 010 011 110 100 111 101 101 110 100 111 Some observations: The leftmost column is always the same. After a column of ones, the order flips (reflection).
  • 36. Example: Gray code to binary code 3-bit Gray code 000 001 Order 0 1 0 011 1 0 1 010 Gray code 1 1 0 110 Binary code 1 0 0 111 101 100
  • 37. Tactic 3. Space-time tradeoff Trading space for time: lookup tables, caching Trading time for space: recalculation
  • 38. Example: Computing segment sums Given an array A of integers, compute the sum of any segment A[i, j] efficiently. 6 4 -3 0 5 1 8 7 For example, A[1, 3] = 6 + 4 + −3 = 7 A[3, 7] = −3 + 0 + 5 + 1 + 8 = 11
  • 39. Example: Computing segment sums Wishful thinking Computing for any segment A[i, j] is difficult, what if we consider only segments of the form A[1, j]? Space-time tradeoff Sums for A[1, j] can be precomputed and stored in a another array P A 6 4 -3 0 5 1 8 7 P 6 10 7 7 12 13 24 31
  • 40. Example: Computing segment sums A 6 4 -3 0 5 1 8 7 P 6 10 7 7 12 13 24 31 Observation The sum for A[i, j] can be computed as P[j] − P[i] + A[i].
  • 41. Example: Computing segment sums Looking back What is special about sum? Does this work with max/min? If not, can the idea be adapted?
  • 42. Outline What is problem solving? Strategies and tactics Getting started (Strategies) Making progress (Tactics) Summary What I’m working on
  • 43. Strategies and tactics Strategies Tactics 1. Get your hands dirty 1. Extremal principle 2. Restate the problem 2. Exploit symmetry 3. Wishful thinking 3. Space-time tradeoff
  • 44. If there is a problem you can’t solve, then there is an easier problem you can solve: find it. George P´lya o
  • 45. Outline What is problem solving? Strategies and tactics Getting started (Strategies) Making progress (Tactics) Summary What I’m working on