140 likes | 194 Views
Problem Solving :. Introduction to principles of computation. HOMEWORK DUE NEXT THURSDAY. Programming Tasks 7, 8, 9 ,10 Fully annotated code copied into a Word Processed document. LibreOffice 4: The free office suite the community has been dreaming of for twelve years
E N D
Problem Solving: Introduction to principles of computation
HOMEWORK DUE NEXT THURSDAY • Programming Tasks 7, 8, 9 ,10 • Fully annotated code copied into a Word Processed document. LibreOffice4: The free office suite the community has been dreaming of for twelve years • Your name in the Header of the document. • Document printed and submitted for marking at the start of the lesson, NOT DURING THE LESSON.
SPOT THE ERRORS Dim moneyLeft As Decimal = 50000 Dim foodSpending As Single Dim tripSpending As String Dim presentSpending As Single Console.Write("How much did you spend on food? ") foodSpending = (Console.WriteLine) Console.WriteLine("How much did you spend on Trips? ") tripSpending (Console.ReadLine) Console.WriteLine("How much did you spend on Presents? ") presentSpending = (Console.ReadLine) moneyLeft = moneyLeft - (foodSpending + tripSpending + presentSpending) Console.WriteLine(You have & moneyLeft & " Euros left to spend") Console.ReadKey()
WHAT IS COMPUTER SCIENCE? Computer science is a discipline that involves the understanding and design of computers and computational processes. In its most general form it is concerned with the understanding of information transfer and transformation. Particular interest is placed on making processes efficient and endowing them with some form of intelligence. The discipline ranges from theoretical studies of algorithms to practical problems of implementation in terms of computational hardware and software.
Computational thinking is made up of four parts DECOMPOSITION PATTERN RECOGNITION PATTERN GENERALISATION AND ABSTRACTION ALGORITHM DESIGN
PATTERN RECOGNITION n = (i * 3) - 2
PATTERN GENERALISATION & ABSTRACTION Pattern Generalization and Abstraction: The ability to filter out information that is not necessary to solve a certain type of problem and generalize the information that is necessary. Pattern generalization and abstraction allows us to represent an idea or a process in general terms (e.g., variables) so that we can use it to solve other problems that are similar in nature. Examples: A daily planner uses abstraction to represent a week in terms of days and hours, helping us to organize our time. A world map is an abstraction of the earth in terms of longitude and latitude, helping us describe the location and geography of a place.
ALGORITHM DESIGN • The ability to develop a step-by-step strategy for solving a problem. Algorithm design is often based on the decomposition of a problem and the identification of patterns that help to solve the problem. In computer science as well as in mathematics, algorithms are often written abstractly, utilizing variables in place of specific numbers. • Examples: • When a chef writes a recipe for a dish, he/she is creating an algorithm that others can follow to replicate the dish. • When a coach creates a play in football, he is designing a set of algorithms for his players to follow during the game. • declare robot • robot.on • robot.get(body) • robot.get(roof) • do • robot.weld(roof, body) • Until • (robot.weld== success) • robot.off
QUESTIONS • What are the four main parts of computational thinking? • Can you spot a pattern in this set of numbers? Fibonacci Numbers • Can you come up with an algorithm to make a cup of tea?
THE HALTING PROBLEM • Do you think that every process in nature can be simulated by a computer? Very early on in modern computing, a British academic named Alan Turing devised the halting problem. This problem is to do with whether we can determine if a program will ever come to a halt or run for ever. Example: console.writeline(“Hello World")
Dim x as integer = 9 • while x > 8 • console.writeline("hello") • end while • This would never finish, it would never come to a halt as x will always be larger than 8 and never get any smaller. This means the while loop will continue for ever, constantly printing out "hello". In the two cases shown it is easy to tell if a program will halt or not, but it isn't so easy. Imagine we get a more complex piece of code: • Dim x as integer = 9 • Dim total as integer = 0 • while total < 100 • total = total + x • x = x / 2 • end while
Problem Solving: Stages of problem solving • Solving problems is never easy, so you need to break them down into manageable chunks: