Announcements The Algorithmic Model Programming Languages Data Assignment Arithmetic.

Slides:



Advertisements
Similar presentations
Pecan cinnamon cookies. Walnut Cinnamon Cookies 1/2 cup unsalted butter 3/4 cup granulated sugar, divided 1/4 cup packed light brown sugar 1 large egg.
Advertisements

Chocolate Chip Cookies. Ingredients: ½ cup butter (1 stick) 1/3 c. brown sugar (packed) 1/3 c. granulated sugar (white) 1 egg 1/ 2 t. vanilla 1 cup +
Recipes.
Understanding Recipes
Computer Science and Engineering The Ohio State University To Ponder Does a problem get easier or harder to solve if I give you less information?
Michelle Koch For other treats around the holidays, visit:
CSci 107 Introduction to Computer Science Lecture 1.
How To Make Chocolate Chip Cookies By: Kevin Klosky.
Baking Chocolate Chip Cookies Ms. Davis Life Skill Class July 11th, 2004.
Computer Science 101 Overview of Algorithms. Example: Make Pancakes Prepare batter Beat 2 eggs Add 1 tablespoon of brown sugar Add 1 cup of milk Add 2.
Fractions with Mom’s Chocolate Chip Jumbles By Margie MacDonald.
MEASUREMENT MAN © Jennifer Choquette.
By Brianne and Lacey This presentation is going to explain to you how to make chocolate chip cookies. Supplies Ingredients Directions It will include:
White Chocolate Orange Cookies. 1 cup butter softened 1/2 cup white sugar 1/2 cup brown sugar 1 egg 1 tablespoon orange zest 2 1/4 cups all-purpose flour.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Algorithms: The recipe for computation What is an algorithm?
Streptococcus pneumoniae. Fig. 6.3b Avery, McCarty and MacLoed, 1944.
Simple Program Design Third Edition A Step-by-Step Approach
CIS Computer Programming Logic
1. Reference  2  Algorithm :- Outline the essence of a computational procedure, step by step instructions.  Program :- an.
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
Introduction By: Dr. Javad Razjouyan. Programming Languages.
How to Make Chocolate Chip Cookies By Sara Hokkala.
1.02 I Preparation Tasks List 11.02I Listing Preparation Tasks.
Baking Cookies English Club eats chocolate chip cookies!
Algorithms: The recipe for computation What is an algorithm?
Lecture 2 Fundamental Data Types. Variable Declaration.
Some quotes…. I really hate this damned machine I wish that they would sell it. It never does quite what I want But only what I tell it. ~Anon These machines.
Computer Science & Engineering An Introduction (and Some Advanced Concepts Too!) Prof. Paul Sivilotti Dept. of Computer Science & Engineering The Ohio.
1.02 C Work Plans 1 The secret for success!. Why use a work plan? Helps meal preparation run smoothly Implement these steps: 1.02CWork Plans2 Steps 1-
The Algorithmic Model. What is Computer Science What is Programming Algorithms –Definition –Properties of Good Algorithms –Describing Algorithms –Examples.
Instructional Video Read the Recipe Select Ingredients And Equipment Prepare The Recipe BAKING COOKIES IN THE VIRTUAL WORLD HELP About LO.
1 11/29/05CS360 Windows Programming XML. 2 11/29/05CS360 Windows Programming What is XML?  XML: Extensible Markup Language  HTML expresses appearance.
An Object-Oriented Approach to Programming Logic and Design Chapter 1 An Overview of Computers and Logic.
Cookies !. Ingredients: 3/4 cup granulated sugar 3/4 cup packed brown sugar 1 cup butter or margarine, softened 1 teaspoon vanilla 1 egg 2 cups Gold Medal.
What you’ll need 2 ½ cups of all – purpose flour 1 teaspoon baking soda 1/2 teaspoon of salt 1 cup granulated sugar 2 eggs.
Functional Text. What is “functional text?” Instruction manuals Recipes Lists of facts (ex: nutrition facts) Table of contents Index Directions That is.
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
How to make chocolate chip cookies By Rose Savage.
Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan 2.
How to Make Chocolate Chip Cookies Caity Jozwiak Period 6.
Does chocolate chip cookie dough sit in the refrigerator for 48 hours before baking it? By: Brooke Giaccone-Hammell And Julie Sentman.
+ Chocolate Chip Cookies Diamond Britton. + Recipe (2 dozen) 1 teaspoon baking soda 1 teaspoon vanilla extract 1 large egg 1 cup flour 1 teaspoon salt.
Introduction to design and analysis algorithm
Snicker Doodle Recipe By:Ashlee Kirkland. Items Needed to make the dough ½ cup each butter and shortening (or margin), at room temperature½ cup each butter.
How to Make Chocolate Chip Cookies
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
CPS Today’s topics l Algorithms and pseudocode l Notes adapted from Marti Hearst at UC Berkeley and David Smith at Georgia Tech Upcoming ä Beginning.
How to Make Chocolate Chip Cookies Fast, Easy, and Yummy Original Author Unknown Modified By: CTAE Resource Network.
1 Introduction to design and analysis algorithm. 2.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Kitchen Measuring Equipment. Measuring 2 Categories of Measuring Equipment Liquid Dry.
Algorithms and Flowcharts
Recipe Notes.
ICS 3UI - Introduction to Computer Science
Algorithms and Problem Solving
CSCI-235 Micro-Computer Applications
How can we do cookies ?. How can we do cookies ?
Data Structures and Algorithms
Maple Peanut Butter Thumbprint Cookies
Welcome back to Software Development!
Welcome back to Software Development!
Algorithms and Problem Solving
Let’s make Cookies!.
Algorithms vs. Programming
COOKIE BAKING LESSON.
Algorithms vs. Programming
Presentation transcript:

Announcements The Algorithmic Model Programming Languages Data Assignment Arithmetic

Announcements Web Page

Announcements Newsgroups –git.cc.class.cs1311.announce –git.cc.class.cs1311.rec –git.cc.class.cs1311.lab –git.cc.class.cs131x.macusers Reading newsgroups –On Campus: Outlook Express/Netscape/tin –Off Campus: tin

The Algorithmic Model

What is Computer Science What is Programming Algorithms –Defined –Properties of Good Algorithms –Describing Algorithms –Examples –Components of Algorithms

What is Computer Science Not really a science in the traditional sense Study of algorithms and how to use them NOT study of computers Software engineering is important! –Analysis and design of systems –Programming –Testing and maintenance

What is Programming Programming requires two skills: –Algorithmic thinking –Knowledge of programming language syntax Learning language syntax is the easy part

How We Learn Computer Science We use pseudo-code to focus on learning algorithmic thinking. From there, you can go anywhere! Not using a computer to compile and run your program forces you to mentally execute your program and debug it! Too many programmers try to program by “trial and error” and twiddling.

Algorithm Defined A set of logical steps to accomplish a task One way to solve a problem A “recipe of action” A way of describing behavior Algorithms contain: Data Instructions

Algorithms in Computing Input Data Algorithm Output Data

Chocolate Chip Cookies DATA (ingredients) 2 1/4 cups flour1 tsp salt 1 tsp baking soda2 eggs 3/4 cup brown sugar 1 tsp vanilla ext. 3/4 cup gran’d sugar 1 cup soft butter 12oz. semi-sweet chocolate chips INSTRUCTIONS (steps) Preheat oven to 375°. Combine flour, salt, baking soda, in bowl, set mixture aside. Combine sugars, butter, vanilla, beat until creamy. Add eggs and beat. Add dry mixture and mix well. Stir in chocolate chips Drop mixture by teaspoons onto ungreased cookie sheet Bake 8 to 10 minutes Algorithm “Recipe”

Abstraction 1.a general idea or term 2.an impractical idea; visionary and unrealistic 3.general characteristics apart from concrete realities, specific objects or actual instances 4.withdrawal 5.absent-mindedness; inattention 6.a work of art stressing formal relationships (Random House Dictionary of the English Language)

Abstraction in Computing Refers to the logical grouping of concepts or objects Define/implement the general idea Isolate the details Helps readability and understanding of our algorithms

Abstraction Examples Algorithms Variable names Procedures and functions Data structures The computer language itself!

Abstraction in Algorithms The Abstraction: Get to the College of Computing at Georgia Tech One Implementation: begin get on I-85 heading towards Midtown Atlanta exit I-85 at the 10th street exit proceed along exit ramp to 10th street turn west on 10th street turn left on Atlantic Drive stop in front of CoC building end Other implementations of the same abstraction can be just as correct, better, or worse

Why do we stress abstraction?

What’s Wrong With This Algorithm? (From back of shampoo bottle) Directions: Wet Hair Apply a small amount of shampoo Lather Rinse Repeat

Properties of Good Algorithms Good algorithms are Precise Unambiguous Complete Correct Simple Contain levels of abstraction

Describing Algorithms Natural language (English) Pictures Pseudo-code or a specific programming language

1.Make a list of courses you want to register for, in order of priority 2.Start with empty schedule. Number of hours = 0. 3.Choose highest priority class on list. 4.If the chosen class is not full and its class time does not conflict with classes already scheduled, then register for the class (2 steps): 4.a. Add the class to the schedule 4.b. Add the class hours to the number of hours scheduled 5.Cross that class off of your list. 6.Repeat steps 3 through 5 until the number of hours scheduled is >= 15, or until all classes have been crossed out. 7.Stop.

Flowcharts End Begin Make list of classes you want to take Num Hours = 0 Choose highest priority class on list Add the class to your schedule. Add class hours to Num Hours. Cross the class off your list. yes no Is this class full? Is there a time conflict? Num Hours >= 15? More classes on list? yes no

Components of Algorithms Any computing algorithm will have AT MOST five kinds of components: Data structures to hold data Instructions change data values Conditional expressions to make decisions Control structures to act on decisions Modules to make the algorithm manageable by abstraction, i.e., grouping related components

Questions?

View of Programming Languages

Overview of Programming Languages Allows programmers to describe desired behaviors (algorithms) The audiences are –Humans –Computers (only understand binary) Consists of: –Built-in –User-defined

Program Language Language Built-inUser-defined DataOperators Assignment Arithmetic Input/Output Relational Boolean DataOperators Atomic Number Character Boolean Pointer Complex String

Relations between Problems, Algorithms, and Programs Problem Algorithm Program....

Questions?

Data

Data Structures Data Structures are containers for data. The simplest of them are called “atomic” because they hold only a single value and cannot be subdivided into lower- level components Other “complex” data structures may hold multiple pieces of data, and are constructed from atomic types.

Built-in Data Types Four built-in atomic types: - Character(char) - Number(num) - Boolean(boolean) - Pointer(ptr) One built-in complex type: - String(string)

Memory Lane

Abstracting the Memory Memory consists of 1’s and 0’s We want to abstract out the details –Create a space in memory for a specific type of information –Access this location in memory using a meaningful name

Three Steps in Using Memory Declare Initialize (no default value) Manipulate

Declaring Variables Variables are data structures whose value may be changed by the algorithm. Each variable must be declared to have an identifier (i.e., a name) and be of some data type. For example: to declare a variable named “counter” that can hold a numeric value: counter isoftype Num

Initialization Each variable must first be assigned a value of the appropriate type after being declared. For example: to assign the value 0 to the variable counter: counter <- 0 Variables do not contain information until they are initialized (I.e. no default value).

Numbers Declared as: my_num isoftype Num my_num can now store one (integer or real) number of any magnitude. Examples: my_num <- 1 // this is OK my_num <- -65 // so is this my_num < // and so is this my_num <- ‘a’ // an ERROR

Characters Declared as: your_grade isoftype Char your_grade can now store any one alphanumeric character. Single-quotes used to distinguish Char values. Examples: your_grade <- ‘A’ // this is OK your_grade <- ‘A-’ // an ERROR your_grade <- ‘9’ // this is OK your_grade <- 9 // an ERROR

Booleans Declared as: this_test isoftype Boolean this_test can now hold one boolean (TRUE or FALSE) value. Examples: this_test <- TRUE // this is OK this_test <- FALSE // so is this this_test <- “FALSE” // an ERROR this_test <- “TRUE” // an ERROR

String Strings can holds a collection of characters. Declared as: this_string isoftype String this_string can now hold a “string” of any number of alphanumeric characters. Examples: this_string <- “hello world” // OK this_string <- hello world // ERROR this_string <- “45” // OK this_string <- 45 // ERROR

Distinguishing Data Types “Woman, without her, man is nothing” “Woman, without her man, is nothing” my_char <- ‘a’ // single quotes my_string <- “a” // double quotes

Pointers Declared as: this_num_ptr isoftype ptr toa Num this_num_ptr can now “know” where a Num variable “lives” in memory. this_num_ptr 42

Questions?

Assignment

The Assignment Operator The assignment operator stores a particular value in a variable. Assignment: <- Format: variable <- value/variable

Type Matching The type of variable on the left side must match the type of value/variable on the right side: my_num <- 42 my_num <- your_num

Assignment Examples Examples: my_age <- 43 your_age <- my_age // duplicates? your_grade <- ‘A’ this_test <- TRUE hi_there <- “Hello World” TRUE and FALSE are each single boolean values.

More Examples a <- b + c Get the value of b from memory Get the value of c from memory Add the two values together Store the result in memory location a a <- a + 1 Get the value of a from memory Add the number 1 to it. Store the result in memory location a

Pointer Assignment Given: this_ptr isoftype ptr toa Num that_ptr isoftype ptr toa Num Then: this_ptr <- new(Num) that_ptr <- new(Num) Gives each pointer variable a new number variable to which it refers: ? ? this_ptr that_ptr

Given above, then: this_ptr^ <- 4 that_ptr^ <- 8 Assigns values to the variable to which the pointer refers. Pointer Assignment 4 this_ptr 8 that_ptr

Pointer Assignment Given: other_ptr <- this_ptr this_ptr <- that_ptr Assigns/reassigns pointers variables to reference other variables 4 this_ptr 8 that_ptr other_ptr 4 this_ptr 8 that_ptr

Questions?

Arithmetic

Arithmetic Operators Arithmetic operators allow us to express mathematical operations: Addition+ Subtraction- Multiplication* Division/ Integer DivisionDIV ModuloMOD

Order of Operations Follow standard arithmetic order of operations: Multiplication & Division Addition & Subtraction Left to Right

Parentheses Use parentheses to control order of execution. Suppose we want: Will x <- a + b / c - d work?

So we want x <- (a + b) / (c - d)

DIV and MOD DIV: keep whole number quotient, and throw away the remainder MOD: keep the remainder, and throw away the whole number quotient Examples: 8 DIV 3 = 2 // 3 goes into 8 two times 8 DIV 9 = 0 // 9 doesn’t go into 8 7 MOD 3 = 1 // remainder of 1 7 MOD 9 = 7 // remainder of 7

MOD & DIV DIV 1 = -6.3 DIV 2 = 0 MOD 3 = 1 MOD 3 = 2 MOD 3 = 3 MOD 3 = 4 MOD 3 = 5 MOD 3 = 6 MOD 3 =

Questions?

Input and Output

I/O Operators allow us to communicate with the “outside world,” the world beyond the algorithm itself. We’re not concerned with formatting.

Print Displays output items to the user Syntax: print(item_1, item_2,..., item_n) Examples: print(“Please enter your info.”) print(num_one, my_char, is_Student)

Read Obtains input items from the user Syntax: read(item_1, item_2,..., item_n) Examples: read(menu_choice) read(is_Student, name, age) No automatic prompting!

Input and Output Examples algorithm IO_Example num_one, num_two, average isoftype Num // obtain two numbers print(“Please enter two numbers”) read (num_one, num_two) // output a literal text message and the // value of the sum print (“Sum = ”, num_one + num_two) // output a string literal and average average <- (num_one + num_two) / 2 print (“Average = “, average) endalgorithm

Questions?