Algorithms (7A) Young Won Lim 4/10/17

Similar documents
Algorithms (7A) Young Won Lim 4/18/17

Algorithms Overview (1A) Young Won Lim 3/29/18

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

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

Binary Search Tree (2A) Young Won Lim 5/17/18

Rational numbers as decimals and as integer fractions

Accessibility (1A) Young Won Lim 8/22/13

Binary Search Tree (3A) Young Won Lim 6/2/18

Pointers (1A) Young Won Lim 1/5/18

Pointers (1A) Young Won Lim 1/9/18

Pointers (1A) Young Won Lim 11/1/17

Structure (1A) Component

RAM (1A) Young Won Lim 11/12/13

The Complexity of Algorithms (3A) Young Won Lim 4/3/18

Applications of Pointers (1A) Young Won Lim 12/26/17

Binary Search Tree (3A) Young Won Lim 6/4/18

Introduction to Programming in C Department of Computer Science and Engineering\ Lecture No. #02 Introduction: GCD

Pointers (1A) Young Won Lim 3/5/18

And Now From a New Angle Special Angles and Postulates LEARNING GOALS

Applications of Arrays (1A) Young Won Lim 2/11/17

Tiny CPU Data Path (2B) Young Won Lim 5/2/16

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

Class (1A) Young Won Lim 9/8/14

Overview (1A) Young Won Lim 9/25/17

GHCi: Getting started (1A) Young Won Lim 5/26/17

Discrete Mathematics Lecture 4. Harper Langston New York University

1 Elementary number theory

Eulerian Cycle (2A) Young Won Lim 4/26/18

Pointers (1A) Young Won Lim 1/14/18

Applications of Arrays (1A) Young Won Lim 3/15/17

Algorithms Bubble Sort (1B) Young Won Lim 4/5/18

Math Introduction to Advanced Mathematics

FPGA Configuration (1C) Young Won Lim 12/1/13

Binary Search Tree (3A) Young Won Lim 6/6/18

Overview (1A) Young Won Lim 9/14/17

Haskell Overview III (3A) Young Won Lim 10/4/16

Function Overview (1A) Young Won Lim 10/23/17

Overview (1A) Young Won Lim 9/9/17

Memory Arrays (4H) Gate Level Design. Young Won Lim 3/15/16

Big Mathematical Ideas and Understandings

Scan Scheduling Specification and Analysis

SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics. Numbers & Number Systems

A Sudoku Solver Pruning (3A)

! Addition! Multiplication! Bigger Example - RSA cryptography

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

COP 4516: Math for Programming Contest Notes

Minimum Spanning Tree (5A) Young Won Lim 5/11/18

A.1 Numbers, Sets and Arithmetic

ELEMENTARY NUMBER THEORY AND METHODS OF PROOF

Univ. of Illinois Due Wednesday, Sept 13, 2017 Prof. Allen

Planar Graph (7A) Young Won Lim 5/21/18

GAS Tutorial - 6. Expression

Libraries (1A) Young Won Lim 6/5/17

Planar Graph (7A) Young Won Lim 6/20/18

CS 6402 DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK

Polymorphism Overview (1A) Young Won Lim 2/20/18

Adders (A) Young Won Lim 10/7/13

Applications of Pointers (1A) Young Won Lim 3/31/18

Monad (1A) Young Won Lim 6/9/17

JavaScript (5A) JavaScript

Algorithm Analysis. (Algorithm Analysis ) Data Structures and Programming Spring / 48

Solutions to the Second Midterm Exam

Eulerian Cycle (2A) Walk : vertices may repeat, edges may repeat (closed or open) Trail: vertices may repeat, edges cannot repeat (open)

The Challenges of Non-linear Parameters and Variables in Automatic Loop Parallelisation

A Sudoku Solver (1A) Richard Bird Implementation. Young Won Lim 11/15/16

Pointers (1A) Young Won Lim 2/6/18

Week - 01 Lecture - 03 Euclid's Algorithm for gcd. Let us continue with our running example of gcd to explore more issues involved with program.

MOST attention in the literature of network codes has

State Monad (3D) Young Won Lim 9/25/17

Monad Background (3A) Young Won Lim 11/20/17

Integers and Mathematical Induction

Applications of Pointers (1A) Young Won Lim 4/11/18

Latch Based Design (1A) Young Won Lim 2/18/15

Pointers (1A) Young Won Lim 1/22/18

HW / SW Implementation Overview (0A) Young Won Lim 7/16/16

CORDIC Fixed Point Simulation. Young Won Lim 2/28/12

Pointers (1A) Young Won Lim 2/10/18

Day06 A. Young W. Lim Mon. Young W. Lim Day06 A Mon 1 / 16

Haskell Overview II (2A) Young Won Lim 8/9/16

Chapter 1 An Introduction to Computer Science. INVITATION TO Computer Science 1

CSc 225 Algorithms and Data Structures I Case Studies

Programming Languages Third Edition

Number- Algebra. Problem solving Statistics Investigations

Course Learning Outcomes for Unit I. Reading Assignment. Unit Lesson. UNIT I STUDY GUIDE Number Theory and the Real Number System

One of the most important areas where quantifier logic is used is formal specification of computer programs.

Operators (2A) Young Won Lim 10/2/13

Background Type Classes (1B) Young Won Lim 6/28/18

Lecture Notes on Contracts

Background Type Classes (1B) Young Won Lim 6/14/18

Algorithms, Part 1 of 3. Problem Solving. Algorithms

Algorithms, Part 1 of 3

ELEMENTARY NUMBER THEORY AND METHODS OF PROOF

Applications of Pointers (1A) Young Won Lim 3/21/18

Applications of Pointers (1A) Young Won Lim 3/14/18

Haskell Overview IV (4A) Young Won Lim 10/13/16

ELEMENTARY NUMBER THEORY AND METHODS OF PROOF

FPGA RAM (C1) Young Won Lim 5/13/16

Operators (2A) Young Won Lim 10/5/13

Math 302 Introduction to Proofs via Number Theory. Robert Jewett (with small modifications by B. Ćurgus)

Chapter 4. Number Theory. 4.1 Factors and multiples

Transcription:

Algorithms (7A)

Copyright (c) 2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". Please send corrections (or suggestions) to youngwlim@hotmail.com. This document was produced by using OpenOffice and Octave.

Algorithms Flow chart of an algorithm (Euclid's algorithm) for calculating the greatest common divisor (g.c.d.) of two numbers a and b in locations named A and B. The algorithm proceeds by successive subtractions in two loops: IF the test B A yields "yes" (or true) (more accurately the number b in location B is greater than or equal to the number a in location A) THEN, the algorithm specifies B B A (meaning the number b a replaces the old b). Similarly, IF A > B, THEN A A B. The process terminates when (the contents of) B is 0, yielding the g.c.d. in A. (Algorithm derived from Scott 2009:13; symbols and drawing style from Tausworthe 1977). Algorithms (7A) 3

Euclid Algorithm Euclid's method for finding the greatest common divisor (GCD) of two starting lengths BA and DC, both defined to be multiples of a common "unit" length. The length DC being shorter, it is used to "measure" BA, but only once because remainder EA is less than DC. EA now measures (twice) the shorter length DC, with remainder FC shorter than EA. Then FC measures (three times) length EA. Because there is no remainder, the process ends with FC being the GCD. On the right Nicomachus' example with numbers 49 and 21 resulting in their GCD of 7 (derived from Heath 1908:300). https://en.wikipedia.org/wiki/euclidean_algorithm Algorithms (7A) 4

Informal Definitions An informal definition could be "a set of rules that precisely defines a sequence of operations."[12] which would include all computer programs, including programs that do not perform numeric calculations. Generally, a program is only an algorithm if it stops eventually. [13] A prototypical example of an algorithm is the Euclidean algorithm to determine the maximum common divisor of two integers; an example (there are others) is described by the flow chart above and as an example in a later section. An "enumerably infinite set" is one whose elements can be put into one-to-one correspondence with the integers. Thus, Boolos and Jeffrey are saying that an algorithm implies instructions for a process that "creates" output integers from an arbitrary "input" integer or integers that, in theory, can be arbitrarily large. Thus an algorithm can be an algebraic equation such as y = m + n two arbitrary "input variables" m and n that produce an output y. But various authors' attempts to define the notion indicate that the word implies much more than this, something on the order of (for the addition example): Algorithms (7A) 5

Best, Worst, Average Case Complexities The best, worst and average case complexity refer to three different ways of measuring the time complexity (or any other complexity measure) of different inputs of the same size. Since some inputs of size n may be faster to solve than others, we define the following complexities: Best-case complexity: This is the complexity of solving the problem for the best input of size n. Worst-case complexity: This is the complexity of solving the problem for the worst input of size n. Average-case complexity: This is the complexity of solving the problem on an average. This complexity is only defined with respect to a probability distribution over the inputs. For instance, if all inputs of the same size are assumed to be equally likely to appear, the average case complexity can be defined with respect to the uniform distribution over all inputs of size n. Algorithms (7A) 6

Upper and Lower Bounds To classify the computation time (or similar resources, such as space consumption), one is interested in proving upper and lower bounds on the minimum amount of time required by the most efficient algorithm solving a given problem. The complexity of an algorithm is usually taken to be its worst-case complexity, unless specified otherwise. Analyzing a particular algorithm falls under the field of analysis of algorithms. To show an upper bound T(n) on the time complexity of a problem, one needs to show only that there is a particular algorithm with running time at most T(n). However, proving lower bounds is much more difficult, since lower bounds make a statement about all possible algorithms that solve a given problem. The phrase "all possible algorithms" includes not just the algorithms known today, but any algorithm that might be discovered in the future. To show a lower bound of T(n) for a problem requires showing that no algorithm can have time complexity lower than T(n). Upper and lower bounds are usually stated using the big O notation, which hides constant factors and smaller terms. This makes the bounds independent of the specific details of the computational model used. For instance, if T(n) = 7n2 + 15n + 40, in big O notation one would write T(n) = O(n2). Algorithms (7A) 7

Upper and Lower Bounds Diagram of complexity classes provided that P NP. The existence of problems in NP outside both P and NP-complete in this case was established by Ladner.[3] Algorithms (7A) 8

Algorithm Analysis Graphs of number of operations, N vs input size, n for common complexities, assuming a coefficient of 1 Algorithms (7A) 9

Upper and Lower Bounds https://en.wikipedia.org/wiki/https://en.wikipedia.org/wiki/big_o_notation Algorithms (7A) 10

Upper and Lower Bounds https://en.wikipedia.org/wiki/https://en.wikipedia.org/wiki/big_o_notation` Algorithms (7A) 11

Upper and Lower Bounds Algorithms (7A) 12

References [1] http://en.wikipedia.org/ [2]