By the end of this session you should be able to...

Slides:



Advertisements
Similar presentations
DT Coursework By D. Henwood.
Advertisements

PROBLEM SOLVING TECHNIQUES
Introduction to Computing Science and Programming I
PSEUDOCODE & FLOW CHART
CS1010 Programming Methodology
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering 3 October 2007.
Pseudocode and Algorithms
Loops – While, Do, For Repetition Statements Introduction to Arrays
Main task -write me a program
Chapter 2: Algorithm Discovery and Design
Review Algorithm Analysis Problem Solving Space Complexity
ALGORITHMS AND FLOWCHARTS
From Scratch to Python Learn to program like the big boys / girls!
By the end of this session you should be able to...
CC0002NI – Computer Programming Computer Programming Er. Saroj Sharan Regmi Week 7.
High-Level Programming Languages: C++
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
Invitation to Computer Science, Java Version, Second Edition.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.
While Loops Indefinite Iteration. Last lesson we looked at definite loops using the ‘For’ statement. The while loop keeps going while some condition is.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
Conditions. Objectives  Understanding what altering the flow of control does on programs and being able to apply thee to design code  Look at why indentation.
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.
30/10/ Iteration Loops Do While (condition is true) … Loop.
Coding Design Tools Rachel Gauci. Task: Counting On Create a program that will print out a sequence of numbers from "1" to a "number entered”. Decision’s.
Python uses boolean variables to evaluate conditions. The boolean values True and False are returned when an expression is compared or evaluated.
CS161 Topic #16 1 Today in CS161 Lecture #16 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for)
Intermediate 2 Computing Unit 2 - Software Development.
More Python!. Lists, Variables with more than one value Variables can point to more than one value at a time. The simplest way to do this is with a List.
Algorithm Discovery and Design Objectives: Interpret pseudocode Write pseudocode, using the three types of operations: * sequential (steps in order written)
GCSE Computing: Programming GCSE Programming Remembering Python.
Flowchart. a diagram of the sequence of movements or actions of people or things involved in a complex system or activity. a graphical representation.
Algorithms and Pseudocode
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science.
Fundamentals of Algorithms MCS - 2 Lecture # 3. Representation of Algorithms.
Progression in KS3/4 Algorithms MONDAY 30 TH NOVEMBER SUE SENTANCE.
By the end of this session you should be able to... Understand what is meant by ‘thinking logically’ including: Identify the points in a solution where.
Algorithms and Flowcharts
Programming revision Revision tip: Focus on the things you find difficult first.
Learning outcomes 5 Developing Code – Using Flowcharts
CS1010 Programming Methodology
Lesson Objectives Aims To be able to write an algorithm in Pseudo Code
INTRODUCTION TO PROBLEM SOLVING
Introducing Instructions
GC211Data Structure Lecture2 Sara Alhajjam.
Introduction To Flowcharting
Introduction to Programmng in Python
Yenka Portfolio Level for this topic: Student Name : My Levels
Iterations Programming Condition Controlled Loops (WHILE Loop)
Print slides for students reference
IPC144 Introduction to Programming Using C Week 2 – Lesson 1
Learning to Program in Python
Learning to Program in Python
Learning to Program in Python
Learning to Program in Python
Program Design Introduction to Computer Programming By:
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
MSIS 655 Advanced Business Applications Programming
Loops CIS 40 – Introduction to Programming in Python
Coding Concepts (Basics)
Data and Flowcharts Session
Data and Flowcharts Session
Flowcharts and Pseudo Code
Data and Flowcharts Session
WJEC GCSE Computer Science
Presentation transcript:

By the end of this session you should be able to... Understand what is meant by ‘the use of algorithms to describe a problem’ including: Analysis and design of algorithms for a given situation. Compare the suitability of different algorithms for a given task and data set.

Good Practice Write the date at the top of a new page at the start of every lesson When you see the pen symbol, copy down what is on the board (you can put it into your own words). Your book will be checked regularly, it must be presentable. When you see the book symbol with a page number, you should turn to that page in your text book. Page: 00

Programming Languages Starter How many programming languages are there?.. Programming Languages

Transferable skills So if there are so many programming languages, how do we ensure all programmers follow the correct method to meet a projects needs? We use algorithms to represent the program before we make the program. An algorithm is transferable as it represents the flow of data/ concepts. All programming languages have common features such as IF statements. By writing an algorithm we are ensuring any programmer can develop the final solution. Why do you think this is important?

Watch this… https://www.khanacademy.org/computing/computer-science/algorithms/intro-to-algorithms/v/what-are-algorithms

So what is an algorithm? Algorithms are a set of instructions that can be followed to perform a certain task. Two common methods of writing algorithms are flowcharts and pseudo code. You need to be familiar with both, by which you should read, write and interpret these methods of displaying solutions. It is through algorithms we are able to develop programming code that computers can use. Page: 049

Writing algorithms Algorithms can be notoriously hard to do all but for the most simple task. Non-trivial problems can have a range of out comes. It is the job of the person writing the algorithm to find the most effective outcome. The power of algorithms comes from the short cuts that have been designed into them. Algorithms must work with any instance of the same problem. The whole point of presenting algorithms to a computer is that they can be applied to different sets of similar data.

What does this algorithm do? Task What does this algorithm do? Start Is temp <19 Yes Turn heating on No Is temp >21 Yes Turn heating off No

What does this algorithm do? Task What does this algorithm do? Start Program If temp <19 turn heating on Else If temp >21 turn heating off

Task Create a simple program in Python that replicates the algorithm on the previous slide. You should ask the user to specify the temperature and have an output that reads something similar to “heating is on”, etc.

Understanding pseudo code Flowcharts are relatively straight forward to follow, but pseudo code can be tricky to get your head round at first. Follow this Link: https://www.khanacademy.org/computing/computer-programming/programming/good-practices/p/pseudo-code# Now have a go at replicated the task completed in the video but this time do it in Python.

Sequence, Selection and Iteration An algorithm follows a sequence of instructions. However simple sequences do not allow for complex instructions to take place. We can use selection and Iteration to build a complex algorithm.

Selection IF Check the condition IF – THEN Action to take based on condition IF – THEN – ELSE If condition is not valid perform another action CASE Select response from an array ENDIF Ends the construct

Iteration FOR Continues a loop for a set number of times WHILE Continues a loop while a condition holds true REPEAT Continues a loop until the condition is met

How to correctly write Pseudocode Get temperature IF temperature <19 THEN Switch heating ON ELSE IF temperature >20 THEN Switch heating OFF ENDIF ENDIF Indent Selection in capitals IF statements ended correctly

Further help Useful links: http://www.wikihow.com/Write-Pseudocode https://www.youtube.com/watch?v=4G0EYfrrDT8 http://www.slideshare.net/DamianGordon1/pseudocode-10373156 http://users.csc.calpoly.edu/~jdalbey/SWE/pdl_std.html Task: Review the links above to familiarise yourself with pseudo code.

Algorithm selection The selection of whether to use a flowchart or pseudo code to represent a computer program often depends on the audience and complexity of the computer solution. For example, if you know you are going to program the solution straight away then as we have seen pseudo code straight into your programming language might be the best choice. However, representing the heating system might never be programmed but used to explain to customers how the heating system works. So a flowchart is more appropriate.

Task For each of the following tasks identify a possible algorithm method and write a solution to the problem using your chosen method. Drawing a snowman inside a snow globe Representing how traffic light on a bridge work Representing a system that checks the username and password of a user Representing a system that generates 10 questions about Game of Thrones and then assigns a character to the player depending on their answers.

Task Choosing at least two of your algorithms, represent the solutions within a programming language of your own choice. Remember to comment your code to ensure you understand what you have done when you come to revise.

Identifying what an algorithm does It is not enough to just be able to write an algorithm; you need to be able to identify what one does. Within an exam you might be presented with pseudo code, a flowchart or a section of code from Java or Python. Your task will be to explain what it does! Remember computational methods are: abstraction, problem decomposition and the development of algorithms.

Example Code: def find_max (L): max = 0 for x in L: if x > max: max = x return max Algorithm: Set max to 0. For each number x in the list L, compare it to max. If x is larger, set max to x. 3.max is now set to the largest number in the list.

Task Describe what the following code does: int x, count, even; x = 0; cin>>count; while(x < count) { cout<<even; even = even+2; x = x+1; }

Answer Read count Set x to 0; While(x < count) Set even to even + 2 x = x + 1 write even

Task Describe what the following pseudo code does: Read num1, num2, num3 If (num1 < num2) If(num2 < num3) Write num1 , num2, num3 Else If(num3 < num1) Write num3, num1, num2 Write num1, num3, num2 else If(num1 < num3) Write num2 , num1, num3 If(num3 < num2) Write num3, num2, num1 Write num2, num3, num1

Task Program a solution to the pseudo code below: 1. Declare an integer variable called n 2. Declare an integer variable sum 3. Declare an integer variable f1 4. Declare an integer variable f2 5. set sum to 0 6. set f1 and f2 to 1 7. set n to 50 8. repeat n times a. sum = f1 + f2 b. f2 = f1 c. f1 = sum d. print sum 9. end loop int main( ) { int n, k, f1, f2, f; if ( n < 2 ) return n; else { f1 = f2 = 1; for(k=2;k<n;k++) f = f1 + f2; f2 = f1; f1 = f; } return f;

Task Program a solution to the pseudo code below: 1. Declare an integer variable called n 2. Declare an integer variable sum 3. Declare an integer variable f1 4. Declare an integer variable f2 5. set sum to 0 6. set f1 and f2 to 1 7. set n to 50 8. repeat n times a. sum = f1 + f2 b. f2 = f1 c. f1 = sum d. print sum 9. end loop int main( ) { int n, k, f1, f2, f; if ( n < 2 ) return n; else { f1 = f2 = 1; for(k=2;k<n;k++) f = f1 + f2; f2 = f1; f1 = f; } return f;

Project tasks Your final project will be a computer based solution to the day care problem. Using both flowcharts and pseudo code write algorithms showing possible solutions to the problem. As demonstrated over the previous lessons you might want to write pseudo code into notepad so that it can be copied into the program you choose to write your final solution in. It is a good idea to spend some time thinking about how you are going to represent the different parts of the problem.