W13:Homework:H08. CS40 Foundations of Computer Science W13. From 40wiki

Similar documents
W13:Homework:H07. CS40 Foundations of Computer Science W13. From 40wiki

Functions. How is this definition written in symbolic logic notation?

CMPSCI 250: Introduction to Computation. Lecture #1: Things, Sets and Strings David Mix Barrington 22 January 2014

Functions. Def. Let A and B be sets. A function f from A to B is an assignment of exactly one element of B to each element of A.

CS16 Midterm Exam 2 E02, 09F, Phill Conrad, UC Santa Barbara Wednesday, 11/18/2009

Basic Data Types and Operators CS 8: Introduction to Computer Science, Winter 2019 Lecture #2

CSCI 136 Data Structures & Advanced Programming. Fall 2018 Instructors Bill Lenhart & Bill Jannen

Grade 6 Math Circles November 6 & Relations, Functions, and Morphisms

Let A(x) be x is an element of A, and B(x) be x is an element of B.

CS16 Midterm Exam 2 E02, 10W, Phill Conrad, UC Santa Barbara Tuesday, 03/02/2010

Functions 2/1/2017. Exercises. Exercises. Exercises. and the following mathematical appetizer is about. Functions. Functions

CS 1803 Pair Homework 3 Calculator Pair Fun Due: Wednesday, September 15th, before 6 PM Out of 100 points

Computation, Computers, and Programs. Administrivia. Resources. Course texts: Kozen: Introduction to Computability Hickey: Introduction to OCaml

CS16 Midterm Exam 1 E01, 10S, Phill Conrad, UC Santa Barbara Wednesday, 04/21/2010, 1pm-1:50pm

2.3: FUNCTIONS. abs( x)

CS 1803 Individual Homework 1 Python Practice Due: Wednesday, January 26th, before 6 PM Out of 100 points

Number System. Introduction. Natural Numbers (N) Whole Numbers (W) Integers (Z) Prime Numbers (P) Face Value. Place Value

CS16 Final Exam E03, 10S, Phill Conrad, UC Santa Barbara Wednesday, 06/09/2010

Functions and Sequences Rosen, Secs. 2.3, 2.4

Introduction to Sets and Logic (MATH 1190)

0.1 Welcome. 0.2 Insertion sort. Jessica Su (some portions copied from CLRS)

Lecture 1. Course Overview, Python Basics

Lecture 1. Course Overview, Python Basics

Midterm Practice Exam Sample Solutions

Overview of the Class

CS32 Final Exam. E03, F15, Phill Conrad, UC Santa Barbara

Welcome to Solving Problems with Computers I

Regarding Python level necessary for the course

MATH 1131Q - Calculus 1.

Reviewing all Topics this term

The Language of Sets and Functions

More on Arrays CS 16: Solving Problems with Computers I Lecture #13

January 30, 2019 LECTURE 2: FUNCTIONS OF SEVERAL VARIABLES.

COE428 Lecture Notes Week 1 (Week of January 9, 2017)

Problem Set 7 Solutions

CPSC 467b: Cryptography and Computer Security

Introduction to Data Structures

Math 152: Applicable Mathematics and Computing

CS8 Final Exam E03, 09M, Phill Conrad, UC Santa Barbara 09/10/2009

Functions (4A) Young Won Lim 5/8/17

MATH 139 W12 Review 1 Checklist 1. Exam Checklist. 1. Introduction to Predicates and Quantified Statements (chapters ).

Section 1.1. Inductive Reasoning. Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Some announcements. Game reflections deadline extended to Monday (4/4)

CS 1803 Individual Homework 2 Conditionals & Loops Due: Wednesday, February 2 nd, before 6 PM Out of 100 points

CS 1803 Pair Homework 4 Greedy Scheduler (Part I) Due: Wednesday, September 29th, before 6 PM Out of 100 points

Repetition Through Recursion

Polynomial and Rational Functions

CS 1301 Exam 1 Answers Fall 2009

#101 Page: 1 Name: CS32 Midterm Exam. E01, W15, Phill Conrad, UC Santa Barbara

COMP Analysis of Algorithms & Data Structures

Elements of Cryptography and Computer and Networking Security Computer Science 134 (COMPSCI 134) Fall 2016 Instructor: Karim ElDefrawy

ACORN.COM CS 1110 SPRING 2012: ASSIGNMENT A1

CprE 281: Digital Logic

CIS 110: Introduction to Computer Programming

Discrete Mathematics SECOND EDITION OXFORD UNIVERSITY PRESS. Norman L. Biggs. Professor of Mathematics London School of Economics University of London

Introduction to Computer Systems

Table of Contents. Course Minutiae. Course Overview Algorithm Design Strategies Algorithm Correctness Asymptotic Analysis 2 / 32

Know the Well-ordering principle: Any set of positive integers which has at least one element contains a smallest element.

CS583 Lecture 01. Jana Kosecka. some materials here are based on Profs. E. Demaine, D. Luebke A.Shehu, J-M. Lien and Prof. Wang s past lecture notes

. As x gets really large, the last terms drops off and f(x) ½x

3. Determine whether f is a function from the set of all bit strings to the set of integers if

Comparing sizes of sets

Lecture 1. Types, Expressions, & Variables

BOSTON UNIVERSITY Metropolitan College MET CS342 Data Structures with Java Dr. V.Shtern (Fall 2011) Course Syllabus

17 February Given an algorithm, compute its running time in terms of O, Ω, and Θ (if any). Usually the big-oh running time is enough.

Functions. Jason Filippou UMCP. Jason Filippou UMCP) Functions / 19

2. Functions, sets, countability and uncountability. Let A, B be sets (often, in this module, subsets of R).

Notes on metric spaces and topology. Math 309: Topics in geometry. Dale Rolfsen. University of British Columbia

Functions (4A) Young Won Lim 3/16/18

Lecture 1 August 9, 2017

Simplifying Square Root Expressions[In Class Version][Algebra 1 Honors].notebook August 26, Homework Assignment. Example 5 Example 6.

Algebraic Expressions

CS 111X - Fall Test 1

(Refer Slide Time: 01.26)

CS1 Lecture 3 Jan. 18, 2019

CS 245: Database System Principles

CS302: Fundamental Algorithms (and Data Structures)

CS415 Compilers Overview of the Course. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

NOTE: All references to Python on this exam mean Python 3, so you should answer accordingly.

CPS 104 Computer Organization and Programming

Digital Logic Design: a rigorous approach c

6.00 Introduction to Computer Science and Programming Fall 2008

CS 3030 Scripting Languages Syllabus

CS 483. Jana Kosecka CS Dept Eng. Building

CSc 2310 Principles of Programming (Java) Jyoti Islam

Math 2280: Introduction to Differential Equations- Syllabus

61A Lecture 4. Monday, September 9

Math 180 Written Homework Solutions Assignment #1 Due Thursday, September 4th at the beginning of your discussion class.

CS 2316 Homework 9b GT Room Reservation

CS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague December 16, CS1800 Discrete Structures Final

Announcements. 1. Forms to return today after class:

Database Systems Management

CS 1301 Individual Homework 3 Conditionals & Loops Due: Monday February 8 th before 11:55pm Out of 100 points

CS 2316 Individual Homework 1 Python Practice Due: Wednesday, January 20 th, before 11:55 PM Out of 100 points

CPSC 121 Some Sample Questions for the Final Exam Tuesday, April 15, 2014, 8:30AM

CSC2100-Data Structures

CS 2316 Individual Homework 4 Greedy Scheduler (Part I) Due: Wednesday, September 18th, before 11:55 PM Out of 100 points

Test 1 Review Questions with Solutions

Slide 1 CS 170 Java Programming 1 Expressions Duration: 00:00:41 Advance mode: Auto

Computer Science II Data Structures

Transcription:

W13:Homework:H08 From 40wiki CS40 Foundations of Computer Science W13 W13:Exams W13:Homework in Class and Web Work W13:Calendar W13:Syllabus and Lecture Notes UCSB-CS40-W13 on Facebook (https://www.facebook.com/groups/ucsb.cs40.w13/) Next in the Array of Talks Series: Talks[5]: From Academia to Business: All about startups! (https://www.facebook.com/events/101188656717515 Wednesday Jan 23, 3pm-5pm click above to learn more and/or to RSVP on Facebook! CS40 on Gauchospace (https://gauchospace.ucsb.edu/courses/cour id=5907) H01 H02 H03 H04 H05 H06 H07 H08 H09 H10 H11 H12 H13 H14 H15 H16 H17 H18 H19 H20 H21 W01 W02 W03 W04 W05 W06 W07 W08 W09 W10 IC01 IC02 IC03 IC04 IC05 IC06 IC07 IC08 IC09 IC10 IC11 IC12 [Print-friendly PDF (http://www.cs.ucsb.edu/~pconrad/cs40/13w/hwk/cs40_w13_h08.pdf) ]

H08-W13-CS40 page 1 First name (color-in initial) A B C D E F G H I J K L M N O P Q R S T U V W X Y Z section (1 or 4) first name initial last name initial Last name (color-in initial) A B C D E F G H I J K L M N O P Q R S T U V W X Y Z H08: Due Monday 01.28.2012 in Lecture. Total Points: 50 MAY ONLY BE TURNED IN DURING Lecture ON Monday 01.28.2012, or offered in person, for in person grading, during instructor or TAs office hours. See the course syllabus at https://foo.cs.ucsb.edu/40wiki/index.php/w13:syllabus for more details. (1) (10 pts) Fill in the information below. Also, fill in the A-Z header by coloring in the first letter of your first and last name (as it would appears in Gauchospace), writing either 1 or 4 to indicate your discussion section meeting time, i.e., Tuesday at 1pm or Tuesday at 4pm. writing your first and last initial in large capital letters (e.g. P C). All of this helps us to manage the avalanche of paper that results from the daily homework. name: umail address: @umail.ucsb.edu For this assignment, please also refer to the handout that was given with Homework H08 (on the web at the link on the wiki.) (2) See the handout and the textbook for info on the mod function. Let g(x) = x mod 3, where x is any integer. (a) (2 pts) How would you fill in the blanks here: g: (b) (2 pts) What set is the co-domain of g? (Review definition of co-domain in Section 2.1.1) (c) (2 pts) What set is the domain of g? (Review definition of co-domain in Section 2.1.1) (d) (2 pts) Is the function g injective (i.e. 1-to-1)? (See Section 2.3.1) Explain your answer. (e) (2 pts) Is the function g surjective (i.e. onto)? (See Section 2.3.1) Explain your answer. (f) (2 pts) Is the function g a bijection? (See Section 2.3.2) Explain your answer. (g) (2 pts) Consider the set N 5 (see Section 2.1.4, p.87 in text for definition.) Review the definition of image of S under f, where S is a subset of the domain of the function (Section 2.1.1) Now consider the image of N 2 under g, i.e. g(n 2 ) List the elements of g(n 2 using set notation. (h) (3 pts) Continuing along these lines, consider the definition of pre-image of T, where T is a subset of the co-domain of a function (Section 2.1.1). The pre-image of the set {1,2} under g, i.e. g -1 ({1,2}) is an infinite set. Using set notation, list eight elements of this set, using ellipsis (...) to indicate that the set goes on forever in both directions. Include at least four negative numbers and four positive numbers in your answer.

CS40-W13-H08 page 2 (3) For this assignment, please also refer to the handout that was given with Homework H08 (on the web at the link on the wiki.) There is information about floor, ceiling, log, and powers of 2. (a) (2 pts) What is log 2 (4)? (b) (2 pts) What is log 2 (1024)? (c) (2 pts) What is log 2 (512)? (c) (3 pts) What is log 2 (500)? (d) (3 pts) What is log 2 (500)? (e) (3 pts) Refer to the handout that came with H08, and read about how we can divide an array of size 14 "in half" in multiple recursive steps, until we are left with arrays only of size 1. Your job is to do the same thing for an array of 18 elements, showing all of the intermediate splits. (4) Let P = the set of all human beings. Let f: P P be the function f(x) = the biological mother of x. (a) (4 pts) Is f injective? Explain. (b) (4 pts) Is f surjective? Explain.

CS40-W13-H08 HANDOUT page 1 Info on mod The mod function (known to C, C++, Java and Python programmers as the % operator) is defined as the remainder after integer division. Formally, (see p. 86), if a and b are integers, where b > 0, then the division algorithm states that there are two unique integers q and r such that: a = bq + r where 0 r < b q is the quotient, r = a-bq is the remainder, and the definition of a mod b The book also denotes the set of integers from from 0 up to n-1 with the notation N n (see p. 87), and that Z is a notation for the set of all integers. Recall that f: A B is the notation for a function that maps each value in the set A to exactly one value in the set B. Info on powers of 2 Powers of 2 are very important in Computer Science. So is the function f(x) = log 2 (x), which is the inverse of the function g(x)=2 x. In general (see p. 89): log b = y means b y = x The main reason this comes up is that many algorithms and data structures that enable us to speed up operations such as inserting, deleting, and finding and sorting involve a "divide and conquer" approach, where we take our data set and cut it in half, repeatedly (and recursively) until we get down to either a pair of elements, or a single element. If you consider the number 8, you can cut it in half three times before you get to 1: These three steps correspond to these facts, all equivalent: 8 4 2 1 2 2 2 = 8 2 3 =8 log 2 (8)=3 We also often combine the floor and ceiling functions with log 2 (x), especially when dealing with divide and conquer on problems where the data set sizes are not exact powers of two. For example, how many times can I cut the number 24 in half before reaching 1? At some point, I reach a place where I can't divide evenly in half. Here, I show how we might divide an array of 14 elements into two arrays of 7, then 4 arrays with uneven sizes, etc until each array is of size one. Note that the number of steps needed is four. Note that 14 falls between 2 3 = 8 and 2 4 = 16. Therefore log 2 (14)) =4, which is the number of steps needed to divide and conquer 14 elements down to individual elements. 14 (7,7) (4,3,4,3) (2,2,2,1,2,2,2,1) (1,1,1,1,1,1,1,1,1,1,1,1,1,1)

CS40-W13-H08 HANDOUT page 2 Retrieved from "https://foo.cs.ucsb.edu/40wiki/index.php?title=w13:homework:h08&oldid=2819" This page was last modified on 22 January 2013, at 16:30. Content is available under Attribution-NonCommercial-ShareAlike 3.0 Unported.