1 / 13

Problem Solving using Computers

Problem Solving using Computers. Architecture of a Computer Illustration of a Problem How a Computer Solves a Problem Algorithms Problem Statement Input/Output Description Algorithm Development Testing. COMP 1100 – Computer Programming 1. Lecture 1 :.

Télécharger la présentation

Problem Solving using Computers

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 using Computers Architecture of a Computer Illustration of a Problem How a Computer Solves a Problem Algorithms Problem Statement Input/OutputDescription Algorithm Development Testing COMP1100 – Computer Programming 1 Lecture 1: Science starts only with problems - Karl Popper Summer 2011 Prepared by: Roger Gajraj

  2. Architecture of Computer Control Processing Unit (CPU) System Bus

  3. Architecture of Computer • Input unit • Takes inputs from the external world via a variety of input devices keyboard, mouse, temperature sensors, odometers, wireless devices etc. • Output Unit • Sends information (after retrieving, processing) to output devices –monitors/displays, projectors, audio devices, switches, relays, gearbox etc. • Memory • Place where information is stored. • System Bus • Used by the other units to communicate with each other. • ALU – Arithmetic and Logic Unit • Processes data; add, subtract, decision – after comparing with data, for example • Control Unit • Controls the interaction among other units. • Knows each unit by its name, responds to requests fairly, reacts quickly on certain critical events. Gives up control periodically in the interest of the system. • Together with the ALU is called the CPU. System Bus

  4. Architecture of Computer • THE CPU • Can fetch an instruction from memory • Execute the instruction • Store the result in memory • A program – a set of instructions • An instruction has the following structure: • Operation operands, destination System Bus

  5. Architecture of Computer • Input can be taken from real world and processed to produce useful output. • A computer program can be created by a programmer to instruct the computer how to process data.

  6. Problem Solving • The student must read the problem statement a number of times to ensure that he/she understands what is asked before attempting to solve the problem. • The following steps need to be followed: • read the problem carefully • understand what the problem entails • and only then, write down the steps to solve the problem. • An everyday example will be: • I need to go to school. Write down the steps to take from waking up in the morning until I am at school.

  7. Problem Solving • 1. Wake up. • 2. Get out of bed. • 3. Wash. • 4. Put on clothes. • 5. Prepare something to eat. • 6. Eat. • 7. Take my bag. • 8. Go to school.

  8. Algorithms • your steps must always be in a logical order! • These steps are called an algorithm that can be defined as a set of sequential instructions to solve a problem. • The most important aspect of solving a problem by using a computer is to write an algorithm to solve it. An algorithm is a set of steps that must be written in such a way that is it unambiguous and precise. The computer cannot think for itself – you as the programmer must tell the computer exactly what to do. You may never assume that the computer will do something if you have not explicitly included the specific step.

  9. Algorithms • Think of an algorithm as a recipe. • We can re-use this recipe to • take specific ingredients(input) • cook them together(processing) • produce some food(output)

  10. Algorithms • An algorithm to solve a computer based problem consists of 3 phases i.e. • What you have available for the algorithm to solve the problem • How you are going to solve the problem i.e. what steps you are going to take • What is the required result

  11. Algorithms • An algorithm must receive data (input) that must be processed to render meaningful results (output or information). • In other words: • Input is processed to render meaningful output. • Data is processed to render meaningful information.

  12. Expressing algorithms • Sequence of worded steps • Pseudocode • Flowcharts

  13. Example • Calculate the sum of 2 numbers and display the result on the screen: • Input: Not available in the problem statement. The user has to supply the • numbers. • Processing: Add the 2 numbers to determine the sum. • Output: The sum as calculated in the processing phase is displayed on the screen of the computer. • Note the following: • The value of the numbers must be available before the sum can be • calculated. • It is impossible to display the sum before it has been calculated.

More Related