1 / 17

ICS102: Introduction To Computing

Learn the fundamentals of computer science, including understanding algorithms, problem-solving techniques, and the programming process.

elester
Download Presentation

ICS102: Introduction To Computing

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. King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science Department ICS102: Introduction To Computing Problem Solving 1

  2. Today’s Class • What’s Computer Science? • What’s an Algorithm? • Problem solving techniques • Overview of computer programming process • Problem solving techniques

  3. What is Computer Science? • It is the discipline that seeks to build a scientificfoundation for such topics as computer design, computer programming, information processing, and algorithmic solutions of problems. • A computer is a machine that stores data, interact with devices, execute programs, and provides computing capabilities to its users). • Computingis the execution of an “algorithm”. What is an Algorithm? A set of steps that define how a task is performed. In other words, it is an ordered set of unambiguous, executable steps that define a terminating activity. • Examples: • Make a list of all positive integers • Extract the first integer from the list

  4. Algorithm • An algorithm can be represented using some sort of language, such as the flowcharts pseudocode (precisely defined textual structures) • An algorithm is abstract and it can be represented in many ways. • EXAMPLE: • Algorithm for converting from Celsius to Fahrenheit can be represented as • 1. F = (9/5) C + 32 (algebraic equation) • 2. “ Multiply the temperature reading in Celsius by 9/5 and then add 32 to the product”

  5. Example: An algorithm for starting the car • To run the car, we follow the following steps: • Insert the key in ignition • Make sure transmission is in Park (or Neutral) • Depress the gas pedal • Turn key to start position • If engine starts within six seconds, release key to ignition position • If engine does not start in six seconds, release key and gas pedal, wait ten seconds, and repeat steps 3 through 6, but not more than five times • If the car does not start, call the garage

  6. Programming Process • Computer program is a sequence of instructions to be performed by a computer. • Computer programming is the process of planning a sequence of steps for a computer to follow • Programming Process has the following three phases: • Problem-solving phase • Implementation phase • Maintenance phase

  7. Programming Process • Problem-solving phase • Analysis and specification ( understand and define problem, and what is expected of solution) • General solution (algorithm: a logical sequence of steps that solves the problem) • Verification (Follow steps to make sure solution solves the problem) • Implementation phase • Concrete solution (Program in a Programming language) • Testing (make sure the program produces the desired results) • Maintenance phase • Use Program • Maintain Program (meet changing requirements)

  8. Programming Process Analysis and Specification Concrete solution (Program) General solution (algorithm) Testing Verification Maintenance Phase Documentation: writing program documentation, and user manuals

  9. Problem Solving • The purpose of writing a program is to solve a problem • The general steps in problem solving are: • Understand the problem • Dissect the problem into manageable pieces • Design a solution • Analyze the complexity of the algorithm • Consider alternatives to the solution and refine it • Implement the solution • Test the solution and fix any problems that exist

  10. Problem Solving • Many software projects fail because the developer didn't really understand the problem to be solved • We must avoid assumptions and clarify ambiguities • As problems and their solutions become larger, we must organize our development into manageable pieces • This technique is fundamental to software development • In java, we will dissect our solutions into pieces called classes and objects, taking an object-oriented approach

  11. Problem Solving Techniques • You follow algorithms every day in your life. So, we need to learn how to design algorithms not simply follow them. • So, what is Problem Solving Process? • 1. Analysis 2. Design • 3. Implementation 4. Testing • Some Strategies to solve problems • Ask questions • Look for things that are familiar • Means-Ends Analysis • Divide and Conquer

  12. Strategies: Ask Questions • When you are given a problem, you ask questions (What, Why, When, and Where?) • In the context of programming • What do I have to work with (What is my data)? • What do the data items look like? • How much data is there? • How will I know when I have processed all the data? • What should my output look like? • How many times is the process going to be repeated? • What special error conditions might come up?

  13. Strategies: Look for Familiar Things • Never reinvent the wheel • If a solution exists  USE IT • Finding the daily high and low temperatures • is really the same problem as • Finding the highest and lowest grades on a test • Both problems can be abstracted as being • Find largest and smallest values in a set of numbers

  14. Strategies: Means-Ends Analysis • Beginning state and End state are often given • You need to define a set of actions that can be used to get from one to the other • Once you have a set of actions, you need to work out the details • Translated to computer programming • Begin by writing down what the input is? (Beginning state) • What the output should be? (End state) • What actions can be performed to obtain results from input data?

  15. Strategies: Divide and Conquer Break up large problems into smaller problems that are easier to handle (Top-Down approach) Hard problem Easy subproblem Hard subproblem Easy subproblem Easy subproblem Easy subproblem

  16. An Example • Compute the area of a circle • Problem statement • We need an interactive program (user will input data) that computes the area of a circle. Given the circle radius, the circle area should be displayed on the screen • Input/Output description • Input  Circle radius • Output  Circle area • Algorithm development (set of steps, decomposition outline) • Read value of circle radius (r) • Compute circle area as pi* r2 • Print the value of circle area • How do we represent more complex algorithms • Pseudocode, flowcharts

  17. Circle area Read radius Compute area Print circle area An Example (continued) A divide and conquer block diagram of our problem • Pseudocode • Prompt the user for the circle radius (put a message on the screen) • Read radius • Assign Circle area the value pi * radius2 • Write Circle area on the screen • Stop

More Related