Algorithms and Pseudocode CS Principles Lesson Developed for CS4 Alabama Project Jim Morse.

Slides:



Advertisements
Similar presentations
ITEC113 Algorithms and Programming Techniques
Advertisements

Chapter 9 Describing Process Specifications and Structured Decisions
Program Design and Development
CSCI/CMPE 4341 Topic: Programming in Python Chapter 3: Control Structures (Part 1) – Exercises 1 Xiang Lian The University of Texas – Pan American Edinburg,
Pseudocode.
Chapter 1 Program Design
Pseudocode.
Chapter 3 Planning Your Solution
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
DCT 1123 Problem Solving & Algorithms
Chapter 9 Describing Process Specifications and Structured Decisions
S2008Final_part1.ppt CS11 Introduction to Programming Final Exam Part 1 S A computer is a mechanical or electrical device which stores, retrieves,
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Chapter 2 Pseudocode. Objectives To introduce common words, keywords and meaningful names when writing pseudocode To define the three basic control structures.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
Pseudocode Simple Program Design Third Edition A Step-by-Step Approach 2.
Visual Basic Programming
Algorithm Design.
Programming, an introduction to Pascal
The Hashemite University Computer Engineering Department
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Controlling Program Flow with Decision Structures.
Algorithms and Pseudocode
IST 210: PHP Logic IST 210: Organization of Data IST2101.
7 - Programming 7J, K, L, M, N, O – Handling Data.
Egyptian Language School Computer Department
Topics Designing a Program Input, Processing, and Output
Data Types Variables are used in programs to store items of data e.g a name, a high score, an exam mark. The data stored in a variable is entered from.
1-1 Logic and Syntax A computer program is a solution to a problem.
Chapter 2: Input, Processing, and Output
GC211Data Structure Lecture2 Sara Alhajjam.
CS1001 Programming Fundamentals 3(3-0) Lecture 2
IF statements.
The Selection Structure
Unit 2 Smarter Programming.
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
UMBC CMSC 104 – Section 01, Fall 2016
CMSC201 Computer Science I for Majors Lecture 03 – Operators
Algorithm and Ambiguity
CS 240 – Lecture 11 Pseudocode.
ALGORITHMS AND FLOWCHARTS
Selection CIS 40 – Introduction to Programming in Python
Program Design Introduction to Computer Programming By:
Introduction to pseudocode
Introduction to C++ Programming
Control Structure Senior Lecturer
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
ALGORITHMS AND FLOWCHARTS
Coding Concepts (Basics)
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
` Structured Programming & Flowchart
Algorithm and Ambiguity
Computer Science Core Concepts
Algorithms computer as the tool process – algorithm
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
Chapter 11 Describing Process Specifications and Structured Decisions
Language Constructs Construct means to build or put together. Language constructs refers to those parts which make up a high level programming language.
Chapter 3: Selection Structures: Making Decisions
Boolean Expressions to Make Comparisons
Flowcharts and Pseudo Code
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Chapter 3: Selection Structures: Making Decisions
Chapter 2: Input, Processing, and Output
Basic Concepts of Algorithm
The Selection Structure
COMPUTING.
Presentation transcript:

Algorithms and Pseudocode CS Principles Lesson Developed for CS4 Alabama Project Jim Morse

Algorithms Review

Logic The science that investigates the principle of correct or reliable inference. Infer – Concluding from evidence – To indicate from facts a solution or guess – To speculate from premises – To suggest using presumed information

Algorithm An effective method expressed as a list of well- defined instructions for completing a task. Examples: Instructions to assemble an object Cooking Receipts Business processes Military Protocols

Basic Steps in Any Algorithm Create a List of the items you need to complete the task. Gather the items Do something with these items Display Finished product

Basic Functions in a Computer Gather the items (INPUT) Do something with these items (PROCESS) Display Finished product (OUTPUT)

Pseudocode

Computer Programming The design, scheduling, or planning of a computer program. An algorithm designed for a computer to complete a given task.

Pseudocode An algorithm of a task, written in a form that can easily be converted into a computer program at a later date. For us, written in English Must be accurate, specific and feasible

Why Pseudocode? To detect any logic error prior to writing a computer program. Simple to covert into any programming language.

Steps of Pseudocode Define the problem Define the information that needs to be gathered to solve the problem Write the pseudocode for inputting the information Write the pseudocode for processing the information Write the pseudocode for reporting the results or solution.

Clarify the Problem What is really being asked of you? Disregard useless information. – Many times programming questions are presented with information that is intended to confuse you and is not needed to solve the problem. Is there a formula or equation I will need to solve the problem? What is it?

Input What data/information is needed for the computer to solve the problem. How are you going to store the data while you are waiting to use it?

Processing What needs to be done to the inputted data to solve the problem?

Output Displaying, print, writing, sending information to a screen, console, printer, file or over a network.

Input

Storage of Input For a computer to use data, it must be inputted from a source and stored in the memory (RAM) of the computer. We store this data… – Constants – Variables – Arrays/lists These memory locations have a unique name or identifier.

Basic Data Types Character – one keystroke ( ‘a’, ‘ ’, ’!’, etc…) String – multiple keystrokes (“Apple”,“!sdksdf&8”, “The pig in the poke”, etc…) Integer – whole numbers (12,56,-6,239, etc…) Decimals – Numbers with decimal places (1.1, 6.3, , 1.0, etc…) Boolean – Logic (TRUE or FALSE)

Constants Constants hold one value and should never be changed. Assignment of constants follow this format: ConstantName = value Example: Str_Name = “Jim” Dec_Pay =

Variables Similar to constants but the values variables can change as the program runs. Assignment of variable follow this format: VariableName = value Example: Dec_Pay = Bo_PowerOn = TRUE

Arrays/Lists A group of data that has some connection. Assignment of arrays/lists follow this format: ArrayName = [value1, value2, value3] Example: Str_Fruits = [“apple”, “banana”, “peach”] Int_Numbers = [1, 2, 3, 77] Arrays usually hold only on type of data, Lists can hold multiple types of data.

Arrays/Lists Variables and constants can be added to arrays/lists. MyFavorite = “Apple” YourFavorite = “Peach” OurFruits = ( Myfavorite, YourFavorite)

Processing

The manipulation of data in a structured event. Two ways to look at processing… 1.Computational 2.Structural

Computational Processing Mathematical – Add- Multiply – Subtract- Divide – Exponential- Modulus Logical – Equal- Not Equal – Greater Than- Less Than – Greater Than or Equal To- Less Than or Equal To – Contains- Does Not Contain – AND- OR

Structural 3 basic forms that can be used in pseudocodes 1.Sequence 2.Decisions 3.Loops

Structures Sequence - one step at a time until completion Begin Create variable Str_Name GET Str_Name value from user DISPLAY Str_Name value END

Structures - Decisions IF – complete process only if a logical comparison is true. IF…ELSE – completes one process if a logical comparison is true and completes another if the process is false IF…ELSEIF…ELSE – more than two results of a comparison.

IF… Decision ….. IF (Condition is TRUE) do something End

IF…ELSE Decision ….. IF (Condition is TRUE) do something ELSE do something else END

IF…ELSEIF….ELSE Decision ….. IF (condition is TRUE) do something ELSEIF (this other condition is true) do something else ELSE do a third option END

Loops We use a WHILE loop for most situations While (condition is TRUE) do this Loop End

Creating Pseudocode

Basic Rules of Pseudocode One step of algorithm per line. Indent to show steps within a structure Always use a key word to describe similar steps

Example of Consistent Wording GET = receive information from the user WRITE = save information to a file DISPLAY = make information viewable to the user

Debugging/Troubleshooting Debugging – The process of locating and fixing errors in your pseudocode, whether these errors are logical, mathematical or procedural. Hints: Trace Runs– Step through the pseudocode step by step writing down all possible inputs, processing all equations and comparisons by hand. Peer Review – Have a peer step through your pseudocode for validation of your processes.

End Teachers, please use these slides as guidelines. Add images, videos, design templates as you see fit taking in consideration your audience.