Algorithms & Pseudocode

Slides:



Advertisements
Similar presentations
ALGORITHMS AND FLOWCHARTS
Advertisements

PROBLEM SOLVING TECHNIQUES
CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
1.4 Programming Tools Flowcharts Pseudocode Hierarchy Chart
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
 Control structures  Algorithm & flowchart  If statements  While statements.
Chapter 2: Algorithm Discovery and Design
Review Algorithm Analysis Problem Solving Space Complexity
PRE-PROGRAMMING PHASE
ALGORITHMS AND FLOWCHARTS
Adapted from slides by Marie desJardins
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
PSEUDOCODE C Programming Technique – Firdaus-Harun.com.
Coding Design Tools Rachel Gauci. What are Coding Design Tools? IPO charts (Input Process Output) Input- Make a list of what data is required (this generally.
ALGORITHMS AND FLOWCHARTS CSCI 105 – Computer Fluency.
Dale Roberts 1 Program Control - Algorithms Department of Computer and Information Science, School of Science, IUPUI CSCI N305.
Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control Structures 3.5The If Selection Structure 3.6The.
Basic Control Structures
1 Program Planning and Design Important stages before actual program is written.
`. Lecture Overview Structure Programming Basic Control of Structure Programming Selection Logical Operations Iteration Flowchart.
Algorithms and Pseudocode
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.
Program design Program Design Process has 2 phases:
ALGORITHMS AND FLOWCHARTS
GC101 Introduction to computers and programs
Unit 3: ALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTS
CS111 Computer Programming
PROGRAM CONTROL STRUCTURE
Pseudocode Upsorn Praphamontripong CS 1110 Introduction to Programming
Pseudo Code.
Lecturer CS & IT Department UOS MBDIN
Computer Programming Fundamentals
Algorithm and Ambiguity
ALGORITHMS AND FLOWCHARTS
Unit# 9: Computer Program Development
Problem Solving Techniques
Introduction to pseudocode
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
1) C program development 2) Selection structure
Global Challenge Night Sensor Lesson 2.
Algorithm Discovery and Design
ALGORITHMS AND FLOWCHARTS
Global Challenge Night Sensor Lesson 2.
Introduction to Algorithms and Programming
` Structured Programming & Flowchart
Global Challenge Night Sensor Lesson 2.
Global Challenge Night Sensor Lesson 2.
Global Challenge Night Sensor Lesson 2.
Algorithm and Ambiguity
Global Challenge Walking for Water Lesson 2.
Global Challenge Night Sensor Lesson 2.
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Global Challenge Night Sensor Lesson 2.
Global Challenge Night Sensor Lesson 2.
Flowcharts and Pseudo Code
Introduction to Programming
Global Challenge Night Sensor Lesson 2.
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Global Challenge Night Sensor Lesson 2.
Global Challenge Night Sensor Lesson 2.
Global Challenge Walking for Water Lesson 2.
WJEC GCSE Computer Science
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Presentation transcript:

Algorithms & Pseudocode

Algorithms An algorithm is a detailed set of steps to solve a problem It states the actions to be executed and the order in which they are to be completed Algorithms can be described using pseudocode or a flowchart Algorithms are fundamental to computer programming

Developing an algorithm High Level Algorithm Written in pseudocode or drawn as a flowchart, it describes how the problem will be solved without the fine detail Detailed Pseudocode Expands the logic of the high level algorithm to closely match a real program Real Code Line by line conversion of the pseudocode to real code.

Important Constructs There are 3 important constructs used in algorithms and coding that you need to be familiar with: Sequence The order that instructions are executed. Order is important eg: Clean teeth Get out of bed Selection Making a decision based on certain conditions eg: If its raining then I’ll stay indoors Else I’ll go to the park Iteration Another name for repeating a set of actions While I feel hungry Eat more food

Pseudocode Pseudocode is an artificial language that helps programmers develop algorithms. It is intended to be easy to read and free from the strict formal syntax of a programming language The rules of pseudocode are reasonably straightforward – there should be a line of pseudocode for every line of real code in your program

Example 1 - Student grades Task: A program is required to output ”passed” if a student achieves 60 or more marks otherwise failed High Level Algorithm Pseudocode If student's mark is greater than or equal to 60 Display"passed" else Display "failed" If mark >= 60 Print "passed" else Print "failed" In this example the problem to be solved, high level algorithm and pseudocode are similar because of the very fact that it is a simple program. However, that should not prevent you from completing the process!

Example 2 – Class Average Task: A program is required to input the individual marks and calculate the average score for a class of 10 students High Level Algorithm Pseudocode Initialise variables Loop add 1 to count input mark calculate average Until count > 10 Display average average  0, class-total  0, mark  “” For count  1 to 10 mark  userinput (”enter student’s marks”) class-total  class-total + mark average  class-total/count Next count Useroutput (“class average is “, average) Now the value of the high level algorithm becomes clearer. It shows the “big picture” of how the problem is to be solved Finer detail is added in the pseudocode ie: Variables to be used type of loop (for or while) Calculation of average