Introduction to Algorithms

Slides:



Advertisements
Similar presentations
CS 240 Computer Programming 1
Advertisements

CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
CS107 Introduction to Computer Science Lecture 2.
CS107: Introduction to Computer Science Lecture 2 Jan 29th.
CS 1400 Course Reader Introduction. What is Programming? Designing an appropriate algorithm Coding that algorithm in a computer language.
CS107 Introduction to Computer Science Loops. Instructions Pseudocode Assign values to variables using basic arithmetic operations x = 3 y = x/10 z =
CS107 Introduction to Computer Science
CSci 107 Introduction to Computer Science Lecture 1.
CS107 Introduction to Computer Science Lecture 2.
CS101- Lecture 11 CS101 Fall 2004 Course Introduction Professor Douglas Moody –Monday – 12:00-1:40 – – –Web Site: websupport1.citytech.cuny.edu.
CS 1400 Chapter 1 Introduction and Background
Lecture Notes 8/30/05 Program Design & Intro to Algorithms.
Chapter 3 Planning Your Solution
Review Algorithm Analysis Problem Solving Space Complexity
Adapted from slides by Marie desJardins
Introduction to Programming Lecture Number:. What is Programming Programming is to instruct the computer on what it has to do in a language that the computer.
An ordered sequence of unambiguous and well-defined instructions that performs some task and halts in finite time Let's examine the four parts of this.
Programming.
Algorithmic Problem Solving CMSC 201 Adapted from slides by Marie desJardins (Spring 2015 Prof Chang version)
INTRODUCTION TO ALGORITHMS PROGRAMMING. Objectives Give a definition of the term algorithm Describe the various parts of the pseudocode algorithm or algorithm.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
Programming Lifecycle
CSE 102 Introduction to Computer Engineering What is an Algorithm?
Introduction to Algorithms. What is Computer Science? Computer Science is the study of computers (??) This leaves aside the theoretical work in CS, which.
Flowcharts.
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
Control Structures (A) Topics to cover here: Introduction to Control Structures in the algorithmic language Sequencing.
CHAPTER 1 INTRODUCTION 1 st Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
1 Program Planning and Design Important stages before actual program is written.
Computer Programming CONTENTS Introduction to Operating Systems Introduction to programming languages Introduction to perl programming language Programming.
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
Ch 1 - Introduction to Computers and Programming Hardware Terminology Main Memory Auxiliary Memory Drives Writing Algorithms Using Pseudocode Programming.
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.
PROBLEM SOLVING. What is a Problem? A problem is a situation that needs to be resolved.
Algorithms and Flowcharts
CIS 115 AID Teaching Effectively/cis115aid.com FOR MORE CLASSES VISIT
Chapter 1 Introduction 2nd Semester H
Program design Program Design Process has 2 phases:
Chapter 3 Program Design
GC101 Introduction to computers and programs
Input and Output Upsorn Praphamontripong CS 1110
1-1 Logic and Syntax A computer program is a solution to a problem.
Chapter 2: Input, Processing, and Output
ALGORITHMS AND FLOWCHARTS
Pseudocode Upsorn Praphamontripong CS 1110 Introduction to 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.
Algorithm and Ambiguity
CMIS 102 Competitive Success-- snaptutorial.com
CMIS 102 Education for Service-- snaptutorial.com
CMIS 102 Teaching Effectively-- snaptutorial.com
ALGORITHMS AND FLOWCHARTS
Introduction to pseudocode
Algorithms & Pseudocode
Programming Right from the Start with Visual Basic .NET 1/e
CSci 107 Introduction to Computer Science
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Programming Funamental slides
Algorithm Discovery and Design
ALGORITHMS AND FLOWCHARTS
Chapter 2- Visual Basic Schneider
Introduction to Algorithms and Programming
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Problem Solving Skill Area 305.1
Programming We have seen various examples of programming languages
Algorithm and Ambiguity
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Introduction to Programming
Chapter 2: Input, Processing, and Output
Presentation transcript:

Introduction to Algorithms Yonglei Tao

What is an Algorithm? A step-by-step description about how to perform a task Unambiguous In a logical order Executable A program is the expression of an algorithm in a programming language

Examples of Algorithm Making a phone call Other examples Pick up the receiver Hear the dial-tone Dial a phone number Wait for the reply Talk Replace the receiver Other examples Programming a VCR A recipe for a cake

Building Instructions for LEGO

Developing an Algorithm How to develop an algorithm? Problem solving How to describe an algorithm? In English? In a programming language?

Pseudocode English statements + basic control structures in programming languages Good compromise Simple, readable, no strict rules, don’t worry about punctuation Let you think at an abstract level about the problem Allow you to focus on what needs to be done without having to deal with the syntax and grammar of a programming language

Pseudocode vs. Code Pseudocode VB code Get the rate from user dblRate = Convert.ToDouble(txtRate.Text)

Building Blocks for Pseudocode Basic statements Get the input (from user) Print the output (on the screen) Perform basic calculations Conditional and iterative statements Variables

Variables How to do (2 + 3) * (5 – 1) using a calculator? A variable is a memory location Can store a value Addressable by its name Examples count 1 sum 5

Basic Statements Assign values to variables using basic arithmetic operations Set the value of x to 3 or x = 3 Set the value of y to x/10 or y = x/10 Set the value of z to x +25 or z = x + 25 Get input from user Get the value of x Print results to the screen Print the value of y, z Print “CIS160 Visual BASIC”

Example Write pseudocode that asks the user for three numbers, computes their sum and average and outputs the results. Get the values of a, b, c from user sum = a + b + c avg = sum / 3 Print sum, avg Input Process Output

Example Write pseudocode that reads the value of a circle radius from the user, and prints the area of a circle with that radius Get the value of radius from user area = pi * radius * radius Print “The area of your circle is “ & area

Exercise Write pseudocode that inputs the length and width of a carpet in feet and the price in dollar per square yard. It also prints out the total cost of the carpet, including a 6% sales tax. 1 square yard = 9 square feet