“The study of algorithms is the cornerstone of computer science.” Algorithms Fall 2011.

Slides:



Advertisements
Similar presentations
Algorithms.
Advertisements

More on Algorithms and Problem Solving
CS107: Introduction to Computer Science Lecture 2 Jan 29th.
CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
JAVA Coursework (the same for 2A and 2B). Fundamental Information The coursework is 30 marks in your O’Level = 15% of the exam Must be word processed.
“The study of algorithms is the cornerstone of computer science.” Algorithms Winter 2012.
8 Algorithms Foundations of Computer Science ã Cengage Learning.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Chapter 2: Algorithm Discovery and Design
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
Chapter 2: Algorithm Discovery and Design
Program Design and Development
Chapter 2 The Algorithmic Foundations of Computer Science
Pseudocode and Algorithms
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Algorithms Computer Science: An Overview Tenth Edition by J. Glenn.
Chapter 2: Algorithm Discovery and Design
Recursion Chapter 7. Chapter 7: Recursion2 Chapter Objectives To understand how to think recursively To learn how to trace a recursive method To learn.
Programming Fundamentals (750113) Ch1. Problem Solving
Recursion Chapter 7. Chapter 7: Recursion2 Chapter Objectives To understand how to think recursively To learn how to trace a recursive method To learn.
Chapter 2: Algorithm Discovery and Design
Chapter 2: Algorithm Discovery and Design
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Algorithms Computer Science: An Overview Tenth Edition by J. Glenn.
Adapted from slides by Marie desJardins
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Abstraction IS 101Y/CMSC 101 Computational Thinking and Design Tuesday, September 17, 2013 Carolyn Seaman University of Maryland, Baltimore County.
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
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.
Copyright © 2015 Pearson Education, Inc. Chapter 5: Algorithms.
Algorithmic Problem Solving CMSC 201 Adapted from slides by Marie desJardins (Spring 2015 Prof Chang version)
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science, C++ Version, Third Edition.
Invitation to Computer Science 6th Edition
Invitation to Computer Science, Java Version, Second Edition.
Recursion Chapter 7. Chapter Objectives  To understand how to think recursively  To learn how to trace a recursive method  To learn how to write recursive.
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
Chapter 5 Algorithms © 2007 Pearson Addison-Wesley. All rights reserved.
Chapter 5 Algorithms Introduction to computer, 2nd semester, 2010/2011 Mr.Nael Aburas Faculty of Information Technology.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Algorithms Computer Science: An Overview Tenth Edition by J. Glenn.
ALGORITHM CHAPTER 8. Chapter Outlines and Objectives  Define an algorithm and relate it to problem solving.  Define three construct and describe their.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Algorithms Computer Science: An Overview Tenth Edition by J. Glenn.
Algorithm: definition An algorithm is an ordered set of unambiguous, executable steps that defines a terminating process.
Chapter 5 Algorithms. © 2005 Pearson Addison-Wesley. All rights reserved 5-2 Chapter 5: Algorithms 5.1 The Concept of an Algorithm 5.2 Algorithm Representation.
Chapter 5: 演算法 Algorithms 陳以德助理教授 : 高醫大舊二棟 轉 2586
1 CS161 Introduction to Computer Science Topic #9.
Chapter 5 Algorithms © 2007 Pearson Addison-Wesley. All rights reserved.
Computer Science: An Overview Eleventh Edition
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
Invitation to Computer Science 5 th Edition Chapter 2 The Algorithmic Foundations of Computer Science.
INVITATION TO Computer Science 1 11 Chapter 2 The Algorithmic Foundations of Computer Science.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science.
PROGRAMMING FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 6: Stepwise refinement revisited, Midterm review.
The Need for Algorithms
Algorithms and Problem Solving
Computer Science: An Overview Eleventh Edition
GC211Data Structure Lecture2 Sara Alhajjam.
COMS W1004 Introduction to Computer Science and Programming in Java
Creativity in Algorithms
Chapter 5: Algorithms Computer Science: An Overview Tenth Edition
MSIS 655 Advanced Business Applications Programming
Programming Fundamentals (750113) Ch1. Problem Solving
Algorithm Discovery and Design
Algorithm and Ambiguity
Algorithms and Problem Solving
ICT Gaming Lesson 2.
Computer Science: An Overview Tenth Edition
Presentation transcript:

“The study of algorithms is the cornerstone of computer science.” Algorithms Fall 2011

The Concept of an Algorithm An algorithm is: –an ordered set of instructions –that are unambiguous, –that are executable, –which define a process that has an end. Let’s look at these steps in detail...

Ordered set –There must be a well-established structure in terms of the order in which steps are performed. Note: they don’t have to be performed sequentially starting with the first. Unambiguous –All information required for execution must be available and there can be no question about what to do. There can be no “reasoning” required. –Example Executable steps –It must be possible to execute each step. –Example which ends.

An algorithm is a definite way of doing something; a concept or idea of how something can be accomplished. An algorithm must be represented in some way in order to be executed, i.e. written down in English, or in a particular computer language. The representation is not unique. –Example In computer-speak, a program is a representation of an algorithm or group of algorithms.

Algorithm Representation Primitives and Pseudocode Primitives –To make a representation of an algorithm we need a language. Requirements: Complete Precise –Our language is made up of commands called primitives. Primitives are building blocks. They’re something you can do. Like add two things together, or print something to the computer screen.

When we combine our primitives with rules as to how to use and combine them, we form a programming language. –Cobol, Fortran, Basic, Pascal, C, C++, Java, Lisp, Prolog, Tcl/Tk, Eiffel,... Lots of them, you get the picture. Each primitive has two parts: –Syntax - symbolic representation –Semantics - meaning or concept

Examples: Primitive Syntaxa * b Semanticsmultiply a times b Primitive Syntaxa = b; Semanticsa is assigned the value of b Rule Compound statementc = a * b; How it worksperform a * b, then assign the result to c

Pseudocode Pseudocode - a notational system in which ideas can be expressed informally during the algorithm development process. In other words, fake code. –We do this so we don’t have to specify a particular programming language just to come up with an algorithm to do something useful. We decide the particular language later, when we want to implement it. Primitive assign name the value expression Primitive if (condition) then (do something) else (do something) Primitive if (condition) then (do something)

Primitive while (condition) do (do something) Primitive repeat (do something) until (condition) Primitives +, -, *, /,, equals, AND, XOR, OR, NOT, and all other “simple” operators. And, any simply understood English statements. Primitive procedure name (arguments) (do something)

while (condition) do (stuff) while (date < Christmas date) do (buy presents) while (not at the end of employee list) do ( get employee data; assign HOURS the value (number of hours worked this week); assign RATE the value (employee hourly pay rate); assign GROSS PAY the value (HOURS * RATE); )

repeat (stuff) until (condition) repeat (Fetch the instruction pointed to by the PC and place the instruction into the IR; assign PC the value (PC + 1); Decode the instruction in the IR; Execute the instruction in the IR; ) until (the HALT instruction is executed)

if (condition) then (do stuff) else (do stuff) if (student #1 equals (a new student)) then (tell student #1 to use the blue form) else (tell student #1 to use the white form)

Procedure A procedure is used to hold code which will be used multiple times, with different things. Pseudocode use: procedure SortList (dummy list) (sort the dummy list here) SortList is the name of the procedure. (dummy list) are things that are “passed to” the procedure; here, some list. Use this to sort 2 different lists: assign sorted CS161 list the value SortList (CS161 student roster); assign sorted CS262 list the value SortList (CS262 student roster);

Section 5.3: Algorithm Discovery How to compute compound interest? How to divide two numbers? How to compute the value of  ? Somebody had to figure these out. For each problem we must discover a solution – a solution that we can write as an algorithm. Let’s look at Problem Solving.

Problem Solving “Confidence is the feeling you have just before you fully understand the problem.” Translation:“Confidence is what you feel just before you fail, thinking you really understood the problem. But then your failure has just brought you one step closer to success – provided you don’t give up.”

In class problems: –Not being able to “see” the problem: Visual blocks picture dots problem –Not being held back by our norms: Cultural blocks –...

“Person A is charged with the task of determining the ages of person B’s three children. B tells A that the product of the children’s ages is 36. After considering this clue, A replies that another clue is required, so B tells A the sum of the children’s ages (13 ex.). Again, A replies that another clue is required, so B tells A that the oldest child plays the piano. After hearing this clue, A tells B the ages of the three children. How old are the three children?

Methods of Problem Solving Try, Try, Try and Think!(The most important!) Attempt to understand the problem. Organize it. Trial and Error Get a foot in the door Look for a related problem Stepwise refinement Work backwards... Look it up in a book or ask somebody else. ( As a last resort only (assuming this is for a class)! If you don’t try first you’ll never learn and you won’t ever be able to solve a problem.)

You must dive into the problem, especially if you don’t understand the problem in the first place. Working on it enables you to gain an understanding of the problem. There are times where you cannot “see” a path to the solution until after you start working.

Be creative –Can a computer be creative? Words of wisdom: don’t behave like computers “behave” today – just following predefined steps – be human, think and be creative!

Iterative Structures Iterative structure -- something which allows us to repetitively perform some function or functions. –While-do The test condition is checked before performing body activity. –Repeat-until The test condition is checked after performing body activity.

Searching & Sorting Algorithms Sequential Search Insertion Sort

Recursive Structures Recursive structure -- A program that calls itself. An alternative to the loop structure for repetitive tasks. A procedure which invokes itself, once or many times. Binary Search Algorithm –Example of a phone book

Efficiency and Correctness Algorithm Efficiency –Algorithms can be classified by how they behave as some quantity is increased. For example: In a sorting algorithm, how much longer does it take to sort a list that’s twice as long as a previous list? Twice as long (linear), four times as long (quadratic), something else? –Does the algorithm become more or less efficient as an important quantity is increased? –Examples. –We classify with:  (n)Linear  (n 2 )Quadratic  (log(n))Logarithmic and so on...

Assignment for October 25th Hand in a 15—20 step recipe of a task which you are an expert.