CS/COE 1501 http://cs.pitt.edu/~bill/1501/

Similar documents
CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Linda Shapiro Winter 2015

Why? A central concept in Computer Science. Algorithms are ubiquitous.

IMPROVING PERFORMANCE OF RANDOMIZED SIGNATURE SORT USING HASHING AND BITWISE OPERATORS

The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge,

Efficiency of algorithms. Algorithms. Efficiency of algorithms. Binary search and linear search. Best, worst and average case.

Zabin Visram Room CS115 CS126 Searching. Binary Search

Data Structures. Algorithm Performance and Big O Analysis

Cost Model: Work, Span and Parallelism. 1 The RAM model for sequential computation:

Class Overview. CSE 326: Data Structures. Goals. Goals. Data Structures. Goals. Introduction

ON THE COMPLEXITY OF THE GAME OF SET.

02-201: Programming for Scientists

CS 300 Data Structures Syllabus - Fall 2014

Integer factorization is in P

Sample Questions Csci 1112 A. Bellaachia

Master of Science in Computer Science College of Computer and Information Science. Course Syllabus

the recursion-tree method

Factoring & Primality

Access Code: RVAE4-EGKVN Financial Aid Code: 6A9DB-DEE3B-74F

Analysis of Binary Search algorithm and Selection Sort algorithm

1.00 Lecture 1. Course information Course staff (TA, instructor names on syllabus/faq): 2 instructors, 4 TAs, 2 Lab TAs, graders

Information Theory and Coding Prof. S. N. Merchant Department of Electrical Engineering Indian Institute of Technology, Bombay

Analysis of Algorithms, I

Integer Factorization using the Quadratic Sieve

Faster deterministic integer factorisation

Probability and Statistics Prof. Dr. Somesh Kumar Department of Mathematics Indian Institute of Technology, Kharagpur

Sorting revisited. Build the binary search tree: O(n^2) Traverse the binary tree: O(n) Total: O(n^2) + O(n) = O(n^2)

Introduction to Algorithms March 10, 2004 Massachusetts Institute of Technology Professors Erik Demaine and Shafi Goldwasser Quiz 1.

CS473 - Algorithms I

In mathematics, it is often important to get a handle on the error term of an approximation. For instance, people will write

Outline. NP-completeness. When is a problem easy? When is a problem hard? Today. Euler Circuits

Assignment 2: Option Pricing and the Black-Scholes formula The University of British Columbia Science One CS Instructor: Michael Gelbart

Math 131 College Algebra Fall 2015

Polynomial Degree and Lower Bounds in Quantum Complexity: Collision and Element Distinctness with Small Range

recursion, O(n), linked lists 6/14

Developing MapReduce Programs

Introduction to Algorithms. Part 3: P, NP Hard Problems

Gamma Distribution Fitting

CS 575 Parallel Processing

The degree of a polynomial function is equal to the highest exponent found on the independent variables.

07/15/10 Math E-10 Precalculus Fall Course Requirements

Computer Science 210: Data Structures. Introduction

Algebra 1 Course Information

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. !-approximation algorithm.

Lecture 2: Universality

Data Structures and Algorithms Written Examination

Fundamentals of Computer Programming CS 101 (3 Units)

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. #-approximation algorithm.

Notes from Week 1: Algorithms for sequential prediction

NP-Completeness I. Lecture Overview Introduction: Reduction and Expressiveness

CORRELATED TO THE SOUTH CAROLINA COLLEGE AND CAREER-READY FOUNDATIONS IN ALGEBRA

Management Information Systems 260 Web Programming Fall 2006 (CRN: 42459)

Analysis of Computer Algorithms. Algorithm. Algorithm, Data Structure, Program

CSC2420 Fall 2012: Algorithm Design, Analysis and Theory

SIMS 255 Foundations of Software Design. Complexity and NP-completeness

Lectures 5-6: Taylor Series

GRID SEARCHING Novel way of Searching 2D Array

Parallel Scalable Algorithms- Performance Parameters

Math 120 Final Exam Practice Problems, Form: A

CS 2302 Data Structures Spring 2015

PRE-CALCULUS GRADE 12

AP Computer Science AB Syllabus 1

South Carolina College- and Career-Ready (SCCCR) Algebra 1

Approximation Algorithms

MATHEMATICS FOR ENGINEERING BASIC ALGEBRA

REVIEW EXERCISES DAVID J LOWRY

Review of Fundamental Mathematics

Lecture 3. Linear Programming. 3B1B Optimization Michaelmas 2015 A. Zisserman. Extreme solutions. Simplex method. Interior point method

Chapter Objectives. Chapter 9. Sequential Search. Search Algorithms. Search Algorithms. Binary Search

Math 35 Section Spring Class meetings: 6 Saturdays 9:00AM-11:30AM (on the following dates: 2/22, 3/8, 3/29, 5/3, 5/24, 6/7)

How To Understand And Solve Algebraic Equations

CASPER COLLEGE COURSE SYLLABUS

LeMoyne-Owen College Division of Natural and Mathematical Sciences COMPUTER ALGORITHMS, COSI 335 Fall Syllabus

1 Shapes of Cubic Functions

COURSE SYLLABUS. Office Hours: MWF 08:30am-09:55am or by appointment, DAV 238

Offline 1-Minesweeper is NP-complete

Dynamic programming formulation

Introduction to Programming System Design. CSCI 455x (4 Units)

Introduction to Database Systems CS4320/CS5320. CS4320/4321: Introduction to Database Systems. CS4320/4321: Introduction to Database Systems

8 Polynomials Worksheet

This unit will lay the groundwork for later units where the students will extend this knowledge to quadratic and exponential functions.

A Time Efficient Algorithm for Web Log Analysis

MAT College Algebra

Mathematics Department Laboratory Technology - Analytical Chemistry Program Calculus I 201-NYA-05

CPSC 211 Data Structures & Implementations (c) Texas A&M University [ 313]

CPLEX Tutorial Handout

T E C H N I C A L R E P O R T

U.C. Berkeley CS276: Cryptography Handout 0.1 Luca Trevisan January, Notes on Algebra

parent ROADMAP MATHEMATICS SUPPORTING YOUR CHILD IN HIGH SCHOOL

(Refer Slide Time: 01:11-01:27)

How To Teach C++ Data Structure Programming

Fast Sequential Summation Algorithms Using Augmented Data Structures

Binary Heap Algorithms

The Running Time of Programs

Math 1314 Online Syllabus. College Algebra

3.2 LOGARITHMIC FUNCTIONS AND THEIR GRAPHS. Copyright Cengage Learning. All rights reserved.

A Practical Method to Diagnose Memory Leaks in Java Application Alan Yu

COMP-202B: Foundations of Programming

Spring 2015: Gordon State College. Barnesville, GA Online Course: Econ 2106 Microeconomics. Course Meeting Time and Location: Internet (D2L)

Transcription:

CS/COE 1501 http://cs.pitt.edu/~bill/1501/ Lecture 01 Course Introduction

Meta-notes These notes are intended for use by students in CS1501 at the University of Pittsburgh. They are provided free of charge and may not be sold in any shape or form. These notes are NOT a substitute for material covered during course lectures. If you miss a lecture, you should obtain both these notes and notes written by a student who attended the lecture. Material from these notes is obtained from various sources, including, but not limited to, the following: Algorithms in C++ by Robert Sedgewick Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne Introduction to Algorithms, by Cormen, Leiserson and Rivest Various Java and C++ textbooks Various online resources (see notes for specifics)

Instructor Info William Garrison (bill@cs.pitt.edu) Office: 6311 Sennott Square Office hours: TBA TAs: TBA NO RECITATIONS THIS WEEK

Course Info Website: http://cs.pitt.edu/~bill/1501/ Please review the Course Information and Policies Grading breakdown: Midterm: 25% Cumulative Final: 25% Assignments: 40% Quizzes: 5% Participation: 5% Assignments will not be accepted after the deadline No late assignment submissions If you do not submit an assignment by the deadline, you will receive a 0 for that assignment

How to succeed in this class Attend class and recitation Actively participate in class Review all code posted to the schedule Get assignments done early Do extra problems in the book

Up until now, your classes have focused on how you could solve a problem. Here, we will start to look at how you should solve a problem.

Alright, then, down to business First some definitions: Offline problem We provide the computer with some input and after some time receive some acceptable output Algorithm A step-by-step procedure for solving a problem or accomplishing some end Program An algorithm expressed in a language the computer can understand An algorithm solves a problem if it produces an acceptable output on every input

Goals of the course To learn to convert non-trivial algorithms into programs Many seemingly simple algorithms can become much more complicated as they are converted into programs Algorithms can also be very complex to begin with, and their implementation must be considered carefully Various issues will always pop up during implementation

Example Pseudocode for dynamic programming algorithm for relational query optimization The optimizer portion of the PostgreSQL codebase is over 28,000 lines of code (i.e., not counting blank/comment lines)

Goals of the course To see and understand differences in algorithms and how they affect the run-times of the associated programs Different algorithms can be used to solve the same problem Different solutions can be compared using many metrics Run-time is a big one Better run-times can make an algorithm more desirable Better run-times can sometimes make a problem solution feasible where it was not feasible before There are many other metrics, though...

How to determine an algorithm s performance Implement it and measure performance Any problems with this approach? Algorithm Analysis Determine resource usage as a function of input size Measure asymptotic performance Performance as input size increases to infinity

Mathematically modelling runtime Runtime primarily determined by two factors: Cost of executing each statement Determined by machine used, environment running on the machine Frequency of execution of each statement Determined by program and input

Algorithm Analysis Ignore multiplicative constants and lower terms Use standard measures for comparison Big O Upper bound on asymptotic performance Big Omega Lower bound on asymptotic performance Theta Upper and Lower bound on asymptotic performance Exact bound

Formal definitions f(x) is O(g(x)) if constants c and x 0 exist such that: f(x) <= c * g(x) x > x 0 f(x) is Ω(g(x)) if constants c and x 0 exist such that: f(x) >= c * g(x) x > x 0 if f(x) is O(g(x)) and Ω(g(x)), the f(x) is Θ(g(x)) c 1, c 2, and x 0 exist such that: c 1 * g(x) <= f(x) <= c 2 * g(x) May also see f(x) O(g(x)) or f(x) = O(g(x)) used to mean that f(x) is O(g(x)) Same for Ω and Θ

Let s consider ThreeSum example from text Problem: Given a set of arbitrary integers (could be negative), find out how many distinct triples sum to exactly zero Simple solution: triple for loops! public static int count(int[] a) { int n = a.length; int cnt = 0; for (int i = 0; i < n; i++) { for (int j = i+1; j < n; j++) { for (int k = j+1; k < n; k++) { if (a[i] + a[j] + a[k] == 0) { cnt++; } } } } return cnt; }

Why aren t lower order terms important? Remember, this is asymptotic analysis n 3 /6 - n 2 /2 + n/3 vs. n 3 /6 for n = 10 100 1000 10000 What about multiplicative constants? n 3 for n = 10, 100, 1000, 10000

Tilde approximations and Order of Growth Can we establish the order of growth for ThreeSum s model? Upper bound? O(n 3 ) Lower bound? Ω(n 3 ) And hence: Θ(n 3 ) Tilde approximations Introduced in section 1.4 of the text In this case: ~n 3 /6

Well, that was easy to get Theta Why do we need to bother with Big O and Big Omega? Not always that easy to prove Theta Lower bounds can prove quite tricky In general, upper bounds are easier to find

Common orders of growth Constant - 1 Logarithmic - log n Linear - n Linearithmic - n log n Quadratic - n 2 Cubic - n 3 Exponential - 2 n Factorial - n!

Graphical orders of growth

Back to ThreeSum Is there a better way? What if we sorted the array first? Pick two numbers, then binary search for the third one that will make a sum of zero a[i] = 10, a[j] = -7, binary search for -3 Still have two for loops, but we replace the third with a binary search Θ(n 2 log n) We add time to sort Fast comparison sort is O(n log n) Doesn t affect our rate of growth n 2 log n dominates in n 2 log n + n log n See ThreeSumFast.java

Topics for the term Sorting Searching Hashing Compression Heaps and Priority Queues Graph Algorithms Dynamic Programming P vs NP Heuristic Approximation Cryptography