CSc 372. Comparative Programming Languages. 21 : Haskell Accumulative Recursion. Department of Computer Science University of Arizona
|
|
|
- Alexis Evans
- 9 years ago
- Views:
Transcription
1 1/18 CSc 372 Comparative Programming Languages 21 : Haskell Accumulative Recursion Department of Computer Science University of Arizona [email protected] Copyright c 2013 Christian Collberg
2 2/18 Stack Recursion The dots n function returns a string consisting of n dots. The dots are stacked until we reach the terminating arm of the recursion. O(n) items are stored on the stack. dots 0 = "" dots n = "." ++ dots (n-1) dots 3 "." ++ dots 2 "." ++ ("." ++ dots 1) "." ++ ("." ++ ("." ++ dots 0)) "." ++ ("." ++ ("." ++ "")) "." ++ ("." ++ ".") "." ++ ".." "..."
3 3/18 Accumulative Recursion We can sometimes get a more efficient solution by giving the function one extra argument, the accumulator, which is used to gather the final result. We will need to use an extra function. In the case of the dots function, the stack recursive definition is actually more efficient. dots n = dots n "" dots 0 acc = acc dots n acc = dots (n-1) (acc ++ ".")
4 4/18 Accumulative Recursion... dots n = dots n "" dots 0 acc = acc dots n acc = dots (n-1) (acc ++ ".") dots 3 dots 3 "" dots 2 ("" ++ ".") dots 2 (".") dots 1 ("." ++ ".") dots 1 ("..") dots 0 (".." ++ ".") dots 0 ("...") "..."
5 5/18 Stack vs. Accumulative Recursion dots 3 "." ++ dots (3 1) dots 2 "." ++ dots (2 1) "..." ".." dots 3 dots 3 "" "..." dots (3 1) ("" ++ ".") dots 2 "." "..." dots 1 "." ++ dots (1 1) dots 0 "" "" "." dots (2 1) ("." ++ ".") dots 1 ".." "..." dots (1 1) (".." ++ ".") dots 0 "..." "..." "..."
6 6/18 Stack vs. Accumulative Recursion... Notice how with stack recursion we re building the result on the way back up through the layers of recursion. This means that for each recursive call many arguments have to be stacked, until they can be used on the way back up. With accumulative recursion we re instead building the result on the way down. Once we re at the bottom of the recursion (when the base case has been reached) the result is ready and only needs to be passed up through the layers of recursion.
7 7/18 Stack Recursion Over Lists Stack recursive functions all look very much alike. All we need to do is to fill in the template below with the appropriate values and functions. do is the operation we want to apply to every element of the list. combine is the operation we want to use to combine the value computed from the head of the list, with the value produced from the tail. Template: f [ ] = final val f (x:xs) = combine (do x) (f xs)
8 8/18 Stack Recursion Over Lists... f [ ] = final val f (x:xs) = combine (do x) (f xs) sumlist :: [Int] -> Int sumlist [] = 0 sumlist (x:xs) = x + sumlist xs final val=0; do x = x; combine="+" double :: [Int] -> [Int] double [] = [] double (x:xs) = 2*x : double xs final val=[]; do x = 2*x; combine=":"
9 9/18 Accumulative Recursion Over Lists main calls aux, the function that does the actual work. main passes along init val, the value used to initiate the accumulator. do is the operation we want to apply to every element of the list. combine is the operation we want to use to combine the value computed from the head of the list with the accumulator. Template: main xs = aux xs init val aux [] acc = acc aux (x:xs) acc = aux xs (combine do x acc)
10 10/18 Accumulative Recursion Over Lists... main xs = aux xs init val aux [] acc = acc aux (x:xs) acc = aux xs (combine do x acc) sumlist xs = sumlist xs 0 Example sumlist: sumlist [] acc = acc sumlist (x:xs) acc = sumlist xs (x + acc) init val=0; do x = x; combine="+"
11 11/18 Accumulative Recursion Over Lists... main xs = aux xs init val aux [] acc = acc aux (x:xs) acc = aux xs (combine do x acc) Example maxlist: maxlist [] = error("...") maxlist (x:xs) = maxlist xs x maxlist [] acc = acc maxlist (x:xs) acc = maxlist xs (max x a) init val=head xs; do x = x; combine="max"
12 12/18 The reverse Function The reverse of an empty list is the empty list. The reverse of a list (x:xs) is the reverse of xs followed by x. Examples: reverse [1,2] reverse [2] ++ [1] (reverse [] ++ [2]) ++ [1] ([] ++ [2]) ++ [1] [2] ++ [1] [2,1] In Haskell: reverse :: [Int] -> [Int] reverse [] = [] reverse (x:xs) = (reverse xs) ++ [x]
13 13/18 The reverse Function... reverse [1,2,3,4] reverse [2,3,4] ++ [1] (reverse [3,4] ++ [2]) ++ [1] ((reverse [4] ++ [3]) ++ [2]) ++ [1] (((reverse [] ++ [4]) ++ [3]) ++ [2]) ++ [1] ((([] ++ [4]) ++ [3]) ++ [2]) ++ [1] (([4] ++ [3]) ++ [2]) ++ [1] ([4,3] ++ [2]) ++ [1] [4,3,2] ++ [1] [4,3,2,1]
14 14/18 The reverse Function... reverse [1,2,3,4] reverse [] ++ [4] [4] [4,3,2,1] reverse [2,3,4] ++ [1] reverse [3,4] ++ [2] reverse [4] ++ [3] [4,3,2] [4,3] Each list append A ++ B takes O(length A) time. There are O(n) applications of reverse, where n is the length of the list. Each application invokes append on a list of length O(n). Total time = O(n 2 ). [] [ ]
15 15/18 The reverse Function... We can devise a more efficient solution by using accumulative recursion. At each step we tack the first element of the remaining list on to the beginning of the accumulator. Examples: reverse [1,2] reverse [1,2] [] reverse [2] (1:[]) reverse [] (2:[1]) [2,1] In Haskell: reverse xs = rev xs [] rev [] acc = acc rev (x:xs) acc = rev xs (x:acc)
16 16/18 The reverse Function... reverse [1,2,3,4] rev [1,2,3,4] [] [1,2,3,4] rev [2,3,4] 1:[] rev [3,4] 2:[1] rev [4] 3:[2,1] rev [] 4:[3,2,1] [1,2,3,4] [1,2,3,4] [1,2,3,4] [1,2,3,4] There are O(n) applications of reverse. Each application of rev invokes : which is an O(1) operation. Total time = O(n). [4,3,2,1] [1,2,3,4]
17 17/18 Summary Accumulative recursion uses an extra parameter in which we collect new information as we go deeper into the recursion. The computed value is returned unchanged back up through the layers of recursion. Stack recursion performs much of the work on the way back up through the layers of recursion. Accumulative recursion is often more efficient than stack recursion.
18 18/18 Exercise occurs x xs returns the number of times the item x occurs in the list xs. 1 Write a stack recursive definition of occurs. 2 Write an accumulative recursive definition of occurs. 3 Try the two definitions with a large list as input. How many cells/reductions do they use? Template: occurs :: Int -> [Int] -> Int Examples:? occurs 1 [3,1,4,5,1,1,2,1] 4
Functional Programming in C++11
Functional Programming in C++11 science + computing ag IT-Dienstleistungen und Software für anspruchsvolle Rechnernetze Tübingen München Berlin Düsseldorf An Overview Programming in a functional style
15-150 Lecture 11: Tail Recursion; Continuations
15-150 Lecture 11: Tail Recursion; Continuations Lecture by Dan Licata February 21, 2011 In this lecture we will discuss space usage: analyzing the memory it takes your program to run tail calls and tail
C++ INTERVIEW QUESTIONS
C++ INTERVIEW QUESTIONS http://www.tutorialspoint.com/cplusplus/cpp_interview_questions.htm Copyright tutorialspoint.com Dear readers, these C++ Interview Questions have been designed specially to get
Semester Review. CSC 301, Fall 2015
Semester Review CSC 301, Fall 2015 Programming Language Classes There are many different programming language classes, but four classes or paradigms stand out:! Imperative Languages! assignment and iteration!
Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013
Masters programmes in Computer Science and Information Systems Object-Oriented Design and Programming Sample module entry test xxth December 2013 This sample paper has more questions than the real paper
Chapter 7: Functional Programming Languages
Chapter 7: Functional Programming Languages Aarne Ranta Slides for the book Implementing Programming Languages. An Introduction to Compilers and Interpreters, College Publications, 2012. Fun: a language
Module 2 Stacks and Queues: Abstract Data Types
Module 2 Stacks and Queues: Abstract Data Types A stack is one of the most important and useful non-primitive linear data structure in computer science. It is an ordered collection of items into which
Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)
Boolean Expressions, Conditions, Loops, and Enumerations Relational Operators == // true if two values are equivalent!= // true if two values are not equivalent < // true if left value is less than the
The Clean programming language. Group 25, Jingui Li, Daren Tuzi
The Clean programming language Group 25, Jingui Li, Daren Tuzi The Clean programming language Overview The Clean programming language first appeared in 1987 and is still being further developed. It was
The countdown problem
JFP 12 (6): 609 616, November 2002. c 2002 Cambridge University Press DOI: 10.1017/S0956796801004300 Printed in the United Kingdom 609 F U N C T I O N A L P E A R L The countdown problem GRAHAM HUTTON
UNIVERSITY OF LONDON (University College London) M.Sc. DEGREE 1998 COMPUTER SCIENCE D16: FUNCTIONAL PROGRAMMING. Answer THREE Questions.
UNIVERSITY OF LONDON (University College London) M.Sc. DEGREE 1998 COMPUTER SCIENCE D16: FUNCTIONAL PROGRAMMING Answer THREE Questions. The Use of Electronic Calculators: is NOT Permitted. -1- Answer Question
Template 1: Test Helicopter
5) Fold back along Template 1: Test Helicopter Follow the steps below 2) Cut from the to the dotted line 3) Fold forwards 3) Fold 4) Cut along these two lines, stopping 6) Fold up here 1 Template 2: Rotor
Copyright 2013 wolfssl Inc. All rights reserved. 2
- - Copyright 2013 wolfssl Inc. All rights reserved. 2 Copyright 2013 wolfssl Inc. All rights reserved. 2 Copyright 2013 wolfssl Inc. All rights reserved. 3 Copyright 2013 wolfssl Inc. All rights reserved.
Recursion and Recursive Backtracking
Recursion and Recursive Backtracking Computer Science E-119 Harvard Extension School Fall 01 David G. Sullivan, Ph.D. Iteration When we encounter a problem that requires repetition, we often use iteration
Training Manual. Pre-Employment Math. Version 1.1
Training Manual Pre-Employment Math Version 1.1 Created April 2012 1 Table of Contents Item # Training Topic Page # 1. Operations with Whole Numbers... 3 2. Operations with Decimal Numbers... 4 3. Operations
Functions Recursion. C++ functions. Declare/prototype. Define. Call. int myfunction (int ); int myfunction (int x){ int y = x*x; return y; }
Functions Recursion C++ functions Declare/prototype int myfunction (int ); Define int myfunction (int x){ int y = x*x; return y; Call int a; a = myfunction (7); function call flow types type of function
Recursion. Definition: o A procedure or function that calls itself, directly or indirectly, is said to be recursive.
Recursion Definition: o A procedure or function that calls itself, directly or indirectly, is said to be recursive. Why recursion? o For many problems, the recursion solution is more natural than the alternative
Chapter 5. Recursion. Data Structures and Algorithms in Java
Chapter 5 Recursion Data Structures and Algorithms in Java Objectives Discuss the following topics: Recursive Definitions Method Calls and Recursion Implementation Anatomy of a Recursive Call Tail Recursion
Detecting Pattern-Match Failures in Haskell. Neil Mitchell and Colin Runciman York University www.cs.york.ac.uk/~ndm/catch
Detecting Pattern-Match Failures in Haskell Neil Mitchell and Colin Runciman York University www.cs.york.ac.uk/~ndm/catch Does this code crash? risers [] = [] risers [x] = [[x]] risers (x:y:etc) = if x
Common Data Structures
Data Structures 1 Common Data Structures Arrays (single and multiple dimensional) Linked Lists Stacks Queues Trees Graphs You should already be familiar with arrays, so they will not be discussed. Trees
Python for Rookies. Example Examination Paper
Python for Rookies Example Examination Paper Instructions to Students: Time Allowed: 2 hours. This is Open Book Examination. All questions carry 25 marks. There are 5 questions in this exam. You should
QUICK SETUP GUIDE: USB-MIDI Cubase AI4 / Motif XS Editor / Windows
QUICK SETUP GUIDE: USB-MIDI Cubase AI4 / Motif XS Editor / Windows Install _ Install Cubase AI4 on your computer. Update to the latest version at www.steinberg.net Download and Install _ The Motif XS Operating
University of Toronto Department of Electrical and Computer Engineering. Midterm Examination. CSC467 Compilers and Interpreters Fall Semester, 2005
University of Toronto Department of Electrical and Computer Engineering Midterm Examination CSC467 Compilers and Interpreters Fall Semester, 2005 Time and date: TBA Location: TBA Print your name and ID
Output: 12 18 30 72 90 87. struct treenode{ int data; struct treenode *left, *right; } struct treenode *tree_ptr;
50 20 70 10 30 69 90 14 35 68 85 98 16 22 60 34 (c) Execute the algorithm shown below using the tree shown above. Show the exact output produced by the algorithm. Assume that the initial call is: prob3(root)
Lecture 12 Doubly Linked Lists (with Recursion)
Lecture 12 Doubly Linked Lists (with Recursion) In this lecture Introduction to Doubly linked lists What is recursion? Designing a node of a DLL Recursion and Linked Lists o Finding a node in a LL (recursively)
The Tower of Hanoi. Recursion Solution. Recursive Function. Time Complexity. Recursive Thinking. Why Recursion? n! = n* (n-1)!
The Tower of Hanoi Recursion Solution recursion recursion recursion Recursive Thinking: ignore everything but the bottom disk. 1 2 Recursive Function Time Complexity Hanoi (n, src, dest, temp): If (n >
Programming Fundamentals. Lesson 20 Sections
Programming Fundamentals Lesson 20 Sections Today, we will Study sections, in Haskell. Sections are another class of expressions that represent functions. A section is a binary operation where one of the
Special Directions for this Test
1 Spring, 2013 Name: (Please do not write your id number!) COP 4020 Programming Languages I Test on Haskell and Functional Programming Special Directions for this Test This test has 7 questions and pages
Practical Generic Programming with OCaml
Practical Generic Programming with OCaml Jeremy Yallop LFCS, University of Edinburgh ML Workshop 2007 Instead of this... type α tree = Node of α Branch of (α tree) (α tree) val show_tree : (α string) (α
Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings: 9.1-9.
Code Generation I Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings: 9.1-9.7 Stack Machines A simple evaluation model No variables
PROBLEMS (Cap. 4 - Istruzioni macchina)
98 CHAPTER 2 MACHINE INSTRUCTIONS AND PROGRAMS PROBLEMS (Cap. 4 - Istruzioni macchina) 2.1 Represent the decimal values 5, 2, 14, 10, 26, 19, 51, and 43, as signed, 7-bit numbers in the following binary
Sample Questions Csci 1112 A. Bellaachia
Sample Questions Csci 1112 A. Bellaachia Important Series : o S( N) 1 2 N N i N(1 N) / 2 i 1 o Sum of squares: N 2 N( N 1)(2N 1) N i for large N i 1 6 o Sum of exponents: N k 1 k N i for large N and k
Datatype-generic data migrations
Datatype-generic data migrations IFIP WG 21 meeting #73, Lökeberg, Sweden Andres Löh August 31, 2015 The Haskell Consultants Motivation Datatypes evolve Motivation Datatypes evolve Example: data Person
ALGEBRA. Find the nth term, justifying its form by referring to the context in which it was generated
ALGEBRA Pupils should be taught to: Find the nth term, justifying its form by referring to the context in which it was generated As outcomes, Year 7 pupils should, for example: Generate sequences from
Queues Outline and Required Reading: Queues ( 4.2 except 4.2.4) COSC 2011, Fall 2003, Section A Instructor: N. Vlajic
Queues Outline and Required Reading: Queues ( 4. except 4..4) COSC, Fall 3, Section A Instructor: N. Vlajic Queue ADT Queue linear data structure organized according to first-in/first-out (FIFO) principle!
Using Visual C++ and Pelles C
Using Visual C++ and Pelles C -IDE & Compilerswww.tenouk.com, 1/48 (2008) In this session we will learn how to use VC++ to build a sample C program. We assume VC++ (Visual Studio) was successfully installed.
16. Recursion. COMP 110 Prasun Dewan 1. Developing a Recursive Solution
16. Recursion COMP 110 Prasun Dewan 1 Loops are one mechanism for making a program execute a statement a variable number of times. Recursion offers an alternative mechanism, considered by many to be more
RECOMMENDED JAVA SETTINGS
RECOMMENDED JAVA SETTINGS FOR WINDOWS XP MACHINES Internet Explorer version 6 o Java version 1.5.0_xx suggested Internet Explorer version 7 o Java version 1.6.0_xx suggested Internet Explorer version 8
Solving Problems Recursively
Solving Problems Recursively Recursion is an indispensable tool in a programmer s toolkit Allows many complex problems to be solved simply Elegance and understanding in code often leads to better programs:
Linked Lists, Stacks, Queues, Deques. It s time for a chainge!
Linked Lists, Stacks, Queues, Deques It s time for a chainge! Learning Goals After this unit, you should be able to... Differentiate an abstraction from an implementation. Define and give examples of problems
Gluing things together with Haskell. Neil Mitchell http://nmitchell.co.uk/
Gluing things together with Haskell Neil Mitchell http://nmitchell.co.uk/ Code Elegantly designed Build system Test harness Continuous integration Release bundling Installer generator Release distribution
CmpSci 187: Programming with Data Structures Spring 2015
CmpSci 187: Programming with Data Structures Spring 2015 Lecture #12 John Ridgway March 10, 2015 1 Implementations of Queues 1.1 Linked Queues A Linked Queue Implementing a queue with a linked list is
What Is Recursion? 5/12/10 1. CMPSC 24: Lecture 13 Recursion. Lecture Plan. Divyakant Agrawal Department of Computer Science UC Santa Barbara
CMPSC 24: Lecture 13 Recursion Divyakant Agrawal Department of Computer Science UC Santa Barbara 5/12/10 1 Lecture Plan Recursion General structure of recursive soluions Why do recursive soluions terminate?
Using Parametric Equations in SolidWorks, Example 1
Using Parametric Equations in SolidWorks, Example 1 (Draft 4, 10/25/2006, SW 2006) Introduction In this example the goal is to place a solid roller on a solid wedge. Their relationship will be governed
The resulting tile cannot merge with another tile again in the same move. When a 2048 tile is created, the player wins.
2048 2048 is number puzzle game created in March 2014 by 19-year-old Italian web developer Gabriele Cirulli, in which the objective is to slide numbered tiles on a grid to combine them and create a tile
Testing and Tracing Lazy Functional Programs using QuickCheck and Hat
Testing and Tracing Lazy Functional Programs using QuickCheck and Hat Koen Claessen 1, Colin Runciman 2, Olaf Chitil 2, John Hughes 1, and Malcolm Wallace 2 1 Chalmers University of Technology, Sweden
QUICK SETUP GUIDE: Firewire/mLAN Windows Cubase AI4 / Studio Manager / Motif XS Editor / Windows
QUICK SETUP GUIDE: Firewire/mLAN Windows Cubase AI4 / Studio Manager / Motif XS Editor / Windows Install _ Install Cubase AI4 on your computer. Update to the latest version at www.steinberg.net Download
Optimising Your EAMS through Business Processes. Wyhan Jooste [email protected]
Optimising Your EAMS through Business Processes Wyhan Jooste [email protected] Presentation Overview Definitions and terminology What is a successful EAMS? Why EAMS implementations fail The benefit
Understand the role that hypothesis testing plays in an improvement project. Know how to perform a two sample hypothesis test.
HYPOTHESIS TESTING Learning Objectives Understand the role that hypothesis testing plays in an improvement project. Know how to perform a two sample hypothesis test. Know how to perform a hypothesis test
Instructions for the Epson Perfection 1670 Scanner
Instructions for the Epson Perfection 1670 Scanner Mathew Dando 7-11-05 Basic Scanning One file at a time Double click on the Epson Scan icon on the desktop Or Start -> Programs -> Epson Scan Put the object
Algorithms and Data Structures
Algorithms and Data Structures Part 2: Data Structures PD Dr. rer. nat. habil. Ralf-Peter Mundani Computation in Engineering (CiE) Summer Term 2016 Overview general linked lists stacks queues trees 2 2
Binary search algorithm
Binary search algorithm Definition Search a sorted array by repeatedly dividing the search interval in half. Begin with an interval covering the whole array. If the value of the search key is less than
what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored?
Inside the CPU how does the CPU work? what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored? some short, boring programs to illustrate the
Outline. CSc 466/566. Computer Security. 8 : Cryptography Digital Signatures. Digital Signatures. Digital Signatures... Christian Collberg
Outline CSc 466/566 Computer Security 8 : Cryptography Digital Signatures Version: 2012/02/27 16:07:05 Department of Computer Science University of Arizona [email protected] Copyright c 2012 Christian
ALGEBRA. sequence, term, nth term, consecutive, rule, relationship, generate, predict, continue increase, decrease finite, infinite
ALGEBRA Pupils should be taught to: Generate and describe sequences As outcomes, Year 7 pupils should, for example: Use, read and write, spelling correctly: sequence, term, nth term, consecutive, rule,
Data Structure and Algorithm I Midterm Examination 120 points Time: 9:10am-12:10pm (180 minutes), Friday, November 12, 2010
Data Structure and Algorithm I Midterm Examination 120 points Time: 9:10am-12:10pm (180 minutes), Friday, November 12, 2010 Problem 1. In each of the following question, please specify if the statement
Poor Man's Type Classes
Poor Man's Type Classes Martin Odersky EPFL IFIP WG2.8 workin roup meetin Boston, July 2006. 1 Goals Type classes are nice. A cottae industry of Haskell prorammers has sprun up around them. Should we add
Stack Allocation. Run-Time Data Structures. Static Structures
Run-Time Data Structures Stack Allocation Static Structures For static structures, a fixed address is used throughout execution. This is the oldest and simplest memory organization. In current compilers,
Introduction to Parallel Programming and MapReduce
Introduction to Parallel Programming and MapReduce Audience and Pre-Requisites This tutorial covers the basics of parallel programming and the MapReduce programming model. The pre-requisites are significant
Arrays. number: Motivation. Prof. Stewart Weiss. Software Design Lecture Notes Arrays
Motivation Suppose that we want a program that can read in a list of numbers and sort that list, or nd the largest value in that list. To be concrete about it, suppose we have 15 numbers to read in from
AP Computer Science A 2004 Free-Response Questions
AP Computer Science A 2004 Free-Response Questions The materials included in these files are intended for noncommercial use by AP teachers for course and exam preparation; permission for any other use
Modifying Colors and Symbols in ArcMap
Modifying Colors and Symbols in ArcMap Contents Introduction... 1 Displaying Categorical Data... 3 Creating New Categories... 5 Displaying Numeric Data... 6 Graduated Colors... 6 Graduated Symbols... 9
Programming Language Features (cont.) CMSC 330: Organization of Programming Languages. Parameter Passing in OCaml. Call-by-Value
CMSC 33: Organization of Programming Languages Programming Language Features (cont.) Names & binding Namespaces Static (lexical) scopes Dynamic scopes Polymorphism Parametric Subtype Ad-hoc Parameter Passing
WRITING DATA TO A BINARY FILE
WRITING DATA TO A BINARY FILE TEXT FILES VS. BINARY FILES Up to now, we have looked at how to write and read characters to and from a text file. Text files are files that contain sequences of characters.
LINEAR INEQUALITIES. less than, < 2x + 5 x 3 less than or equal to, greater than, > 3x 2 x 6 greater than or equal to,
LINEAR INEQUALITIES When we use the equal sign in an equation we are stating that both sides of the equation are equal to each other. In an inequality, we are stating that both sides of the equation are
What Is Recursion? Recursion. Binary search example postponed to end of lecture
Recursion Binary search example postponed to end of lecture What Is Recursion? Recursive call A method call in which the method being called is the same as the one making the call Direct recursion Recursion
Pseudo code Tutorial and Exercises Teacher s Version
Pseudo code Tutorial and Exercises Teacher s Version Pseudo-code is an informal way to express the design of a computer program or an algorithm in 1.45. The aim is to get the idea quickly and also easy
Text Processing In Java: Characters and Strings
Text Processing In Java: Characters and Strings Wellesley College CS230 Lecture 03 Monday, February 5 Handout #10 (Revised Friday, February 9) Reading: Downey: Chapter 7 Problem Set: Assignment #1 due
A-level COMPUTER SCIENCE
A-level COMPUTER SCIENCE Paper 2 TBC am/pm 2 hours 30 minutes Materials There are no additional materials required for this paper. Instructions Use black ink or black ball-point pen. Fill in the boxes
Solutions to Quick Check Questions. Defining Your Own Classes Part 1
Solutions to Quick Check Questions 4 Defining Your Own Classes Part 1 4.1 First Example: Defining and Using a Class 1. Extend the Bicycle class by adding the second data member tagno of type String. Declare
MQL4 COURSE By Coders guru www.forex-tsd.com
MQL4 COURSE By Coders guru www.forex-tsd.com -11- Your First Indicator Part 2 ------------------------------- Welcome to the second part of Your First Indicator lesson. In the previous lesson we didn t
Lecture Outline. Stack machines The MIPS assembly language. Code Generation (I)
Lecture Outline Code Generation (I) Stack machines The MIPS assembl language Adapted from Lectures b Profs. Ale Aiken and George Necula (UCB) A simple source language Stack- machine implementation of the
CS177 MIDTERM 2 PRACTICE EXAM SOLUTION. Name: Student ID:
CS177 MIDTERM 2 PRACTICE EXAM SOLUTION Name: Student ID: This practice exam is due the day of the midterm 2 exam. The solutions will be posted the day before the exam but we encourage you to look at the
customer rewards Use this guide to create customized customer rewards and redeem points earned by customers.
customer rewards Use this guide to create customized customer rewards and redeem points earned by customers. Setting Security 2. Click on the Security Customer Rewards Edit Ticket - Process 3. Click the
Lecture 12: Abstract data types
Lecture 12: Abstract data types Algebras Abstract data types Encapsulation and information hiding Parameterization Algebras Definition Which kinds of data do we want to discuss? What can we do with it?
Programming Language Rankings. Lecture 15: Type Inference, polymorphism & Type Classes. Top Combined. Tiobe Index. CSC 131! Fall, 2014!
Programming Language Rankings Lecture 15: Type Inference, polymorphism & Type Classes CSC 131 Fall, 2014 Kim Bruce Top Combined Tiobe Index 1. JavaScript (+1) 2. Java (-1) 3. PHP 4. C# (+2) 5. Python (-1)
Class 16: Function Parameters and Polymorphism
Class 16: Function Parameters and Polymorphism SI 413 - Programming Languages and Implementation Dr. Daniel S. Roche United States Naval Academy Fall 2011 Roche (USNA) SI413 - Class 16 Fall 2011 1 / 15
Code Obfuscation. Mayur Kamat Nishant Kumar
Code Obfuscation Mayur Kamat Nishant Kumar Agenda Malicious Host Problem Code Obfuscation Watermarking and Tamper Proofing Market solutions Traditional Network Security Problem Hostile Network Malicious
For the next three questions, consider the class declaration: Member function implementations put inline to save space.
Instructions: This homework assignment focuses on basic facts regarding classes in C++. Submit your answers via the Curator System as OQ4. For the next three questions, consider the class declaration:
A Table of the Most Common Standard Pipe Sizes. Nominal Bore 1/2 inch (DN 15 mm), Outside Diameter 21.34 mm
Standard Pipe Sizes Standard Pipe Sizes Except for specialist applications, commercially available pipe comes in standard sizes. Pipes in a variety of materials - including carbon steel, steel alloys,
Project 2: Bejeweled
Project 2: Bejeweled Project Objective: Post: Tuesday March 26, 2013. Due: 11:59PM, Monday April 15, 2013 1. master the process of completing a programming project in UNIX. 2. get familiar with command
both double. A. T and v max B. T remains the same and v max doubles. both remain the same. C. T and v max
Q13.1 An object on the end of a spring is oscillating in simple harmonic motion. If the amplitude of oscillation is doubled, how does this affect the oscillation period T and the object s maximum speed
6. Standard Algorithms
6. Standard Algorithms The algorithms we will examine perform Searching and Sorting. 6.1 Searching Algorithms Two algorithms will be studied. These are: 6.1.1. inear Search The inear Search The Binary
High-Level Programming Languages. Nell Dale & John Lewis (adaptation by Michael Goldwasser)
High-Level Programming Languages Nell Dale & John Lewis (adaptation by Michael Goldwasser) Low-Level Languages What are disadvantages of low-level languages? (e.g., machine code or assembly code) Programming
SizmekFeatures. HTML5JSSyncFeature
Features HTML5JSSyncFeature Table of Contents Overview... 2 Supported Platforms... 2 Demos/Downloads... 3 Note... 3 For Tags Served in iframes... 3 Features... 3 Use Case... 3 Included Files... 4 Implementing
Comp 248 Introduction to Programming
Comp 248 Introduction to Programming Chapter 2 - Console Input & Output Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia University, Montreal, Canada These slides has been
CS104: Data Structures and Object-Oriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team
CS104: Data Structures and Object-Oriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team Lecture Summary In this lecture, we learned about the ADT Priority Queue. A
Enter Here --> Photography Business Quick Steps > Get it Here <
Photography business action plan, starting a photography business prices, photography business for sale arizona, 10 steps to starting a wedding photography business. Enter Here --> Photography Business
Anatomy of Programming Languages. William R. Cook
Anatomy of Programming Languages William R. Cook Copyright (C) 2013 2 Chapter 1 Preliminaries Preface What? This document is a series of notes about programming languages, originally written for students
From Interpreter to Compiler and Virtual Machine
BRICS From Interpreter to Compiler and Virtual Machine Mads Sig Ager BRICS, University of Aarhus, Denmark Joint work with Dariusz Biernacki, Olivier Danvy, and Jan Midtgaard 1 Examples of machines Krivine
Problem 1. CS 61b Summer 2005 Homework #2 Due July 5th at the beginning of class
CS 61b Summer 2005 Homework #2 Due July 5th at the beginning of class This homework is to be done individually. You may, of course, ask your fellow classmates for help if you have trouble editing files,
How To Monitor Performance On A Microsoft Powerbook (Powerbook) On A Network (Powerbus) On An Uniden (Powergen) With A Microsatellite) On The Microsonde (Powerstation) On Your Computer (Power
A Topology-Aware Performance Monitoring Tool for Shared Resource Management in Multicore Systems TADaaM Team - Nicolas Denoyelle - Brice Goglin - Emmanuel Jeannot August 24, 2015 1. Context/Motivations
Introduction to Java and Eclipse
Algorithms and Data-Structures Exercise Week 0 Outline 1 Introduction Motivation The Example 2 Setting things up Setting command line parameters in Eclipse 3 Debugging Understanding stack traces Breakpoints
Recursion vs. Iteration Eliminating Recursion
Recursion vs. Iteration Eliminating Recursion continued CS 311 Data Structures and Algorithms Lecture Slides Monday, February 16, 2009 Glenn G. Chappell Department of Computer Science University of Alaska
Data Types. Abstract Data Types. ADTs as Design Tool. Abstract Data Types. Integer ADT. Principle of Abstraction
bstract ata Types Previous lectures: algorithms and their efficiency analysis. oming lectures: data structures In this lecture: bstract data types Ts as a design tool Examples: integer T, List T ata Types
Termination Checking: Comparing Structural Recursion and Sized Types by Examples
Termination Checking: Comparing Structural Recursion and Sized Types by Examples David Thibodeau Decemer 3, 2011 Abstract Termination is an important property for programs and is necessary for formal proofs
