1 / 33

Problem Solving thru Programming @ HCJC

Problem Solving thru Programming @ HCJC. Creative Problem Solving in Computing Leong Hon Wai Department of Computer Science School of Computing National University of Singapore 8 March 2003 http://www.comp.nus.edu.sg/~leonghw/ leonghw@comp.nus.edu.sg. Outline.

dobry
Download Presentation

Problem Solving thru Programming @ HCJC

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Problem Solving thru Programming @ HCJC Creative Problem Solving in Computing Leong Hon Wai Department of Computer Science School of Computing National University of Singapore 8 March 2003 http://www.comp.nus.edu.sg/~leonghw/ leonghw@comp.nus.edu.sg

  2. Outline • Polya’s Problem Solving Framework • Four Stages in Problem Solving • Solving Problems by Asking More Questions! • Examples • Is Problem Solving still important • Now we have very fast computers, grids • Any real differences between O(n2) and O(n lg n) • Some examples: Google and the Human Genome Project

  3. Quote A great discovery solves a great problem, but there is a grain of discovery in the solution of any problem. Your problem may be modest; but if it challenges your curiosity and bring into play your inventive faculties, and if you solve it by your own means, you may experience the tension and enjoy the triumph of discovery. G. Polya, 1945

  4. Four Stages of Problem Solving (G. Polya) G. Polya, “How to Solve It”, Princeton Univ Press, 1945 • Stage 1: Understanding the Problem • Stage 2: Devising a Plan • Stage 3: Carrying out the Plan • Stage 4: Looking Back The most widely cited reference for problem solving in all disciplines

  5. More on “Four Stages”

  6. What is (11…1) (100…05) + 1 100 1’s 99 0’s Problem 1: An “Impossible Problem” • Quick: Get the calculator… • Not so useful… • Polya Question: Look at the data? (stare at it !!) • (111…1)(100…05) + 1 ???? • Let’s call it “something-big” • PQ: What is the unknown? • Is it an integer? …a real number?

  7. What is (11…1) (100…05) + 1 100 1’s 99 0’s An “Impossible Problem” (2) • PQ: Can you re-state the problem? or unknown? • To find the square-root of “something-big plus 1” • PQ: What is that “something-big”? • Don’t know, but it is • “(square of ‘some-other-thing’)minus 1” • PQ: Shall we introduce notations: • “ y2 – 1 ” = (y + 1)(y – 1) • It is also (11…1)*(100…05)

  8. Something-big plus 1 • PQ: Can we try some special cases? (1)(15)+1 = 1 (3 * 5)+1 = (4-1)(4+1)+1 = 4**2-1+1 (11)*(105)+1 = 11*(99+6)+1 = 11*3*(33+2)+1 = 33*(33+2)+1 = (34-1)(34+1)+1 = 34**2-1+1 (111)*(1005)+1 = 111*(999+6)+1 = 333*(333+2)+1 = (334-1)(334+1)+1 = 334**2 (1111)*(10005)+1 = 1111*(9999+6)+1 = 3333*(3333+2)+1 = (3334-1)(3334+1)+1 = 3334**2 Get the pattern? … can u prove it?

  9. Looking Back • Looking Back: Where is the Key Idea? • (y2 - 1) = (y-1)(y+1) !!! • Can I do it differently? • Define something -- maybe 111…1 • (111….1) (1000…05) + 1 So, let X = 111…1 • Something-big + 1 = X (999…9 + 6) + 1 = X (9X + 6) + 1 = 9X2 + 6X + 1 = (3X+1)^2 • So, y = 3X+1. Viola!!!

  10. h ...students with 4A’s in 2003 A-levels, I mean…. Question: What is the value of m, when h = 420 ? Problem 2: Inverting the Triangle-of-Coins • Move as few coins as possible to “invert” the triangle of coins • Define h = “height of triangle”, m = “# of coins to move”

  11. Inverting the Triangle of Coins (1) • Try some small instances… • h = 1 • TRIVIAL: • h = 1 m = 0

  12. Inverting the Triangle of Coins (2) • Now, try something bigger… • h = 2 • TRIVIAL: • h = 1 m = 0 • h = 2 m = 1

  13. Viola! Inverting the Triangle of Coins (3) • Now, try something bigger… • h = 3 • RESULTS: • h = 1 m = 0 • h = 2 m = 1 • h = 3 m = 2

  14. Is there a pattern? What about h = 5? h = 420? Inverting the Triangle of Coins (4) • Now, try something bigger… • h = 4 Done! m=3 • RESULTS: • h = 1 m = 0 • h = 2 m = 1 • h = 3 m = 2 • h = 4 m = 3

  15. INSIGHT !!! Maximize OVERLAP Minimize “Moves” Need a Different Perspective!! (2) • Let’s see…. • How about… • seeing them TOGETHER! • Let’s move IT…..

  16. Need a Different Perspective!! • Let’s see…. • How about… • seeing them TOGETHER! • Let’s move…..

  17. New Insight !! Maximize Overlap • Now, try for h = 5

  18. (1,1,2) (0,1,3) New Insight !! Maximize Overlap • There are 3 sides in a triangle. • At each side, we have a “non-overlapping” triangle! • Denote their heights (a,b,c) (0,0,4)

  19. Maximizing Overlap is Easy… • Try for previous cases h = 3 • “Non-overlapping triangles with hts (a,b,c) • For h=2, we have (0,0,1) m=1 • For h=3, we have (0,1,1) m=2 • For h=4, we have (1,1,1) m=3 • For h=5, we have (1,1,2) m=5 • For h=6, we have (1,2,2) m=7 • For h=7, we have (2,2,2) m=9 • For h=8, we have (2,2,3) m=12

  20. Looking Back…. • Can work out for h = 9, 10, 11, 12, …, 420 • ANSWER is NOT so important, the METHOD IS • Where is the Key Step ? • Why was it not apparent to us at the beginning ? • How did we get to this step ?

  21. References…. for More readings... • G. Polya, “How to Solve It”, • Princeton Univ Press (1945), • re-published by Penguin Books (1990) • W. A. Wickelgren, “How to Solve Problems”, • W. H. Freeman, 1974. • R. R. Kadesch, “Problem Solving Across the Disciplines”, • Prentice Hall, 1997. • Edward De Bono, • Various Different Titles (from Lateral Thinking, to Teaching Thinking, to Hats, to Simplicity). • [EvAn] Everywhere and Anywhere -- Use your imagination!.

  22. Problem Solving in Computing – Do we need it? • Is there a need for Problem Solving? • We have invented many algorithms over the past 50 yrs • There are many textbooks on algorithms already • Don’t we already have all the algorithms we need? • Why not let faster computer do the job? • Computer are getting faster all the time (Moore’s Law) • Current Speed: 2 GigaFLOP (2 billion operations / sec) • 3GigaFLOP? 10 GigaFLOP? • What about parallel processing? GRID Computing? • What is the largest GRID we have? • 11 Teraflop (NSF funded @ 4 centers) ?

  23. Let’s look at a popular example: Google • Google: • One of the best (if not the best) search engines • Google searches 3 x 109 pages (3,083,324,652) • How big is 3 x 109 anyway? • The size of the human genome (in terms of base-pairs) • If we print out 3 x 109 characters on A4 paper, it will be • (3x109 / (66x80)) * 5 / (500x100) metres = 56.8 metres • about a 20-storey HDB block high! • Assumptions: • 1 A4 page = 66 rows x 80 columns 210 = 1000 • 500 A4 page = 5cm (in height) 1 yr = 3 x 106 sec

  24. O(n2) vs O(n lg n) algorithm • If Google wants to sort the pages (say by Title) • Here n = 3 x 109 (webpages) • If we use an O(n2) algorithm • On a very fast computer (say, 3 GigaFLOP) • (3 x 109 ) (3 x 109 ) / (3 x 109) (3 x 107) = 100 years • 30 years if it is 10 GigaFLOP • On world’s largest GRID Cluster: 11 x 1012 (teraFLOP) • 3 months (assuming no time lost among cluster) • If we use an O(n lg n) algorithm • (3 x 109) x 30 / (3 x 109) = 30 seconds • Don’t need GRID

  25. Other examples of O(n2) and O(n lg n) • FM (higher quality sound) • Uses a technique called Fast Fourier Transform (FFT) • Old method of doing transform – O(n2) • with FFT – O(n lg n)

  26. Human Genome Project

  27. Human Genome Project • Human Genome Project (1986-2003) • 3 x 109 base-pairs • 24 chromosomes • 30K – 40K genes (ave 3000 bp each) • Goals: • Identify the genes, DNA sequence • Develop tools to help data analysis • Interpret results in biologically meaningful manner

  28. HGP – A Reverse Engg. Problem • Given • 3 GB of mass storage (24 partitions) • Unknown OS, file format • Known encoding scheme • Files are fragmented • Disk has active and deleted blocks • Hardware design & system BIOS also on disk • Task: • Recover and document about 35,000 programs that represent the OS, • Figure out the low level control code & • schematic description of how computer is put together;

  29. Computer Scientists contributes… • Human Genome Project • Original Target: end in 2005 or beyond • Enter many prominent computer scientists • Powerful algorithmic techniques, • Divide and conquer paradigms • Scalable methods for speed-ups (eg: DNA Arrays) • Outcome • June 2000 – Working Draft Sequences • Feb 2001 – published • 2003 – expect high quality version completed !!

  30. Efficient Algorithms with Arrays… • Problem: • You have planned out a very long route that passed through a number of intermediate cities labelled 1,2,…,n. You are given the distances d(j) where d(j) is the distance between city j and j+1. • You receive a lot of queries of the form What is the distance between city a and city b? • Device a scheme so that so that you can answer all of these queries in O(1) time. (constant time).

  31. Don’t just understand the solution, but try also to understand the motives and procedures of arriving at the solution. The Most Important Message of the Day… ASK QUESTIONS • Do I understand the problem ? • Do I understand their solution ? • Why does the solution work ? • Why did he choose to do this or that ? • How can I invent such a solution ? • Can I do it differently ? • Can I do it more elegantly ?

  32. Message for the Day (2) • Running time MATTERS • There are still lots of computational problems • left to be solve, and • waiting to be solved well.

  33. THANK YOU VERY MUCH And I hope to work with some of you in the future

More Related