Docsity

COMPUTER SCIENCE Topic – Problem Solving, Assignments of Computer Science

Partial preview of the text

Download COMPUTER SCIENCE Topic – Problem Solving and more Assignments Computer Science in PDF only on Docsity!

COMPUTER SCIENCE

Topic – Problem Solving

An algorithm is a precise step-by-step set of instructions for solving a problem or carrying out a task

Algorithms

They are often used to improve efficiency by removing the need for human input A computer following an algorithm can decide what decision to make far more quickly than a human Book

There are four methods of writing algorithms

Types of Algorithms

All algorithms can be represented in each of these methods The four types are..

Written Description

Types of Algorithms

Step by step instructions written in plain English

Book

Pseudocode

Types of Algorithms

Uses structured English and keywords with a heavy focus on the order of the instructions (the logic)

Book Half way between plain English and a programming language

Program Code

Types of Algorithms

Code that is produced using a programming language such as Python

Book

Algorithms can be displayed as flowcharts

Flowcharts

Terminal Shows the start and end of an algorithm Decision/Selection Shows yes/no or true/false decisions where there are two possible outcomes Process Shows data processing , such as a calculation Input / Output Indicates an input or output Subroutine Shows a function or procedure that has its own flowchart Line Represents control passing between the other symbols Book

Example Flowcharts (Easy)

Flowcharts

Start Terminal Output Print “Hello world” End Terminal Start Terminal Print “Mr” Output End Terminal Print “Lyon” (^) Output Change this to your name! Book

Example Flowchart (Difficult 1)

Flowcharts

Start Is mark1 > mark2? NO YES Input mark1, mark2, mark End End End End Output mark Is mark2 > mark3? Is mark1 > mark3? NO NO YES Output mark Output mark YES Output mark Terminal Terminal Input Output DO NOT DRAW THIS FLOWCHART IT IS ON THE SHEET Output (^) Output Decision Terminal Output Terminal Terminal Decision Decision Sheet

Complete the flowchart worksheet(10mins)

Main Task

Start End Boil kettle Add tea bag Add hot water Add milk Has the water boiled? No Yes Start End Boil kettle Add tea bag Add hot water Add milk Making a Cup of Tea Take sugar? No Yes Add Sugar

Why do we need to use flowcharts?

  • Plan a New Project
  • Design something for someone else to see
  • visualize and troubleshoot
  • Mapping computer algorithms

Plenary Task Answer the following questions

  1. Draw and explain the symbols used in flow charts
  2. Give two examples of where flow charts might be used
  3. Give a reason why flow charts are used EXTENSION: Explain how the data in a flow chart could become stuck in an infinite loop

Home work- due Tuesday 27th Create a flow chart for one of the following. Remember to include as many steps as possible