# Algorithms and Data Structures

Save this PDF as:

Size: px
Start display at page:

## Transcription

1 Algorithm Analysis Page 1 BFH-TI: Softwareschule Schweiz Algorithm Analysis Dr. CAS SD01

2 Algorithm Analysis Page 2 Outline Course and Textbook Overview Analysis of Algorithm Pseudo-Code and Primitive Operations Big-Oh Notation and Complexity

3 Algorithm Analysis Course and Textbook Overview Page 3 Outline Course and Textbook Overview Analysis of Algorithm Pseudo-Code and Primitive Operations Big-Oh Notation and Complexity

4 Algorithm Analysis Course and Textbook Overview Page 4

5 Algorithm Analysis Course and Textbook Overview Page 5 Algorithm Design I Part I. Fundamental Tools 1. Algorithm Analysis 1.1 Methodologies for Analyzing Algorithms 1.2 Asymptotic Notation 1.3 A Quick Mathematical Review 1.4 Case Studies in Algorithm Analysis 1.5 Amortization 1.6 Experimentation 1.7 Exercises 2. Basic Data Structures 2.1 Stacks and Queues 2.2 Vectors, Lists, and Sequences 2.3 Trees 2.4 Priority Queues and Heaps 2.5 Dictionaries and Hash Tables

6 Algorithm Analysis Course and Textbook Overview Page 6 Algorithm Design II 2.6 Java Example: Heap 2.7 Exercises 3. Search Trees and Skip Lists 3.1 Ordered Dictionaries and Binary Search Trees 3.2 AVL Trees 3.3 Bounded-Depth Search Trees 3.4 Splay Trees 3.5 Skip Lists 3.6 Java Example: AVL and Red-Black Trees 3.7 Exercises 4. Sorting, Sets, and Selection 4.1 Merge-Sort 4.2 The Set Abstract Data Type 4.3 Quick-Sort 4.4 A Lower Bound on Comparison-Based Sorting 4.5 Bucket-Sort and Radix-Sort

7 Algorithm Analysis Course and Textbook Overview Page 7 Algorithm Design III 4.6 Comparison of Sorting Algorithms 4.7 Selection 4.8 Java Example: In-Place Quick-Sort 4.9 Exercises 5. Fundamental Techniques 5.1 The Greedy Method 5.2 Divide-and-Conquer 5.3 Dynamic Programming 5.4 Exercises Part II. Graph Algorithms 1. Graphs 1.1 The Graph Abstract Data Type 1.2 Data Structures for Graphs 1.3 Graph Traversal 1.4 Directed Graphs

8 Algorithm Analysis Course and Textbook Overview Page 8 Algorithm Design IV 1.5 Java Example: Depth-First Search 1.6 Exercises 2. Weighted Graphs 2.1 Single-Source Shortest Paths 2.2 All-Pairs Shortest Paths 2.3 Minimum Spanning Trees 2.4 Java Example: Dijkstra s Algorithm 2.5 Exercises 3. Network Flow and Matching 3.1 Flows and Cuts 3.2 Maximum Flow 3.3 Maximum Bipartite Matching 3.4 Minimum-Cost Flow 3.5 Java Example: Minimum-Cost Flow 3.6 Exercises

9 Algorithm Analysis Course and Textbook Overview Page 9 Algorithm Design V Part III. Internet Algorithmics 1. Text Processing 1.1 Strings and Pattern Matching Algorithms 1.2 Tries 1.3 Text Compression 1.4 Text Similarity Testing 1.5 Exercises 2. Number Theory and Cryptography 2.1 Fundamental Algorithms Involving Numbers 2.2 Cryptographic Computations 2.3 Information Security Algorithms and Protocols 2.4 The Fast Fourier Transform 2.5 Java Example: FFT 2.6 Exercises 3. Network Algorithms

10 Algorithm Analysis Course and Textbook Overview Page 10 Algorithm Design VI 3.1 Complexity Measures and Models 3.2 Fundamental Distributed Algorithms 3.3 Broadcast and Unicast Routing 3.4 Multicast Routing 3.5 Exercises Part IV. Additional Topics 1. Computational Geometry 1.1 Range Trees 1.2 Priority Search Trees 1.3 Quadtrees and k-d Trees 1.4 The Plane Sweep Technique 1.5 Convex Hulls 1.6 Java Example: Convex Hull 1.7 Exercises 2. NP-Completeness

11 Algorithm Analysis Course and Textbook Overview Page 11 Algorithm Design VII 2.1 P and NP 2.2 NP-Completeness 2.3 Important NP-Complete Problems 2.4 Approximation Algorithms 2.5 Backtracking and Branch-and-Bound 2.6 Exercises 3. Algorithmic Frameworks 3.1 External-Memory Algorithms 3.2 Parallel Algorithms 3.3 Online Algorithms 3.4 Exercises

12 Algorithm Analysis Analysis of Algorithm Page 12 Outline Course and Textbook Overview Analysis of Algorithm Pseudo-Code and Primitive Operations Big-Oh Notation and Complexity

13 Algorithm Analysis Analysis of Algorithm Page 13 Algorithms An algorithm is a step-by-step procedure for solving a problem in a finite amount of time Most algorithms transform input objects into output objects The running time (and the memory consumption) of an algorithm typically grows with the input size The average case running time is often difficult to determine We focus on the worst case running time Easier to analyse Crucial to applications such as games, finance, robotics Sometimes, it is also worth to study the best case running time

14 Algorithm Analysis Analysis of Algorithm Page 14 Running Time: Example Running Time Best case Average case Worst case Input Size

15 Algorithm Analysis Analysis of Algorithm Page 15 Problem Classes I There are feasible problems, which can be solved by an algorithm efficiently Examples: sorting a list, draw a line between two points, decide whether n is prime, etc. There are computable problems, which can be solved by an algorithm, but not efficiently Example: finding the shortest solution for large sliding puzzles There are undecidable problems, which can not be solved by an algorithm Example: for a given a description of a program and an input, decide whether the program finishes running or will run forever (halting problem)

16 Algorithm Analysis Analysis of Algorithm Page 16 Problem Classes II All Problems Computable Problems Feasible Problems

17 Algorithm Analysis Analysis of Algorithm Page 17 Experimental Studies There are two ways to analyse the running time (complexity) of an algorithm: Experimental studies Theoretical analysis Experiments usually involve the following major steps: Write a program implementing the algorithm Run the program with inputs of varying size and composition Use a method like System.currentTimeMillis() to get an accurate measure of the actual running time Plot the results

18 Algorithm Analysis Analysis of Algorithm Page 18 Experimental Studies: Example Running Time (ms) Input Size

19 Algorithm Analysis Analysis of Algorithm Page 19 Limits of Experiments It is necessary to implement the algorithm, which may be difficult Results may not be indicative of the running time on other inputs not included in the experiment The running times may depend strongly on the chosen setting (hardware, software, programming language) In order to compare two algorithms, the same hardware and software environments must be used

20 Algorithm Analysis Analysis of Algorithm Page 20 Theoretical Analysis Uses a high-level description of the algorithm instead of an implementation Describes the running time (complexity) as a function of the input size n: T (n) = number of primitive operations Allows to evaluate the speed of an algorithm independent of hardware software programming language actual implementation Takes into account all possible inputs

21 Algorithm Analysis Pseudo-Code and Primitive Operations Page 21 Outline Course and Textbook Overview Analysis of Algorithm Pseudo-Code and Primitive Operations Big-Oh Notation and Complexity

22 Algorithm Analysis Pseudo-Code and Primitive Operations Page 22 Pseudo-Code Pseudo-code allows a high-level description of an algorithm More structured than English prose, but less detailed than a program Preferred notation for describing algorithms Hides program design issues and details of a particular language

23 Algorithm Analysis Pseudo-Code and Primitive Operations Page 23 Pseudo-Code: Example Find the maximum element of an array: Algorithm arraymax(a, n) Input array A of n integers Output maximum element of A currentmax A[0] for i 1 to n 1 do if A[i] > currentmax then currentmax A[i] return currentmax

24 Algorithm Analysis Pseudo-Code and Primitive Operations Page 24 Details of Pseudo-Code I The rules of using pseudo-code are very flexible, but following some guidelines is recommended Method/function declaration Algorithm method or function(arg 1, arg 2,...) Input... Output... Control flow if... then... [else...] while... do... repeat... until... for... do... Indentation replaces braces {} resp. begin...end

25 Algorithm Analysis Pseudo-Code and Primitive Operations Page 25 Details of Pseudo-Code II Expressions Assignments: (like = in Java) Equality testing: = (like == in Java) Superscript like n 2 and other mathematical notation is allowed Array access: A[i 1] Function/method call function(arg 1, arg 2,...) object.method(arg 1, arg 2,...) Return value return expression

26 Algorithm Analysis Pseudo-Code and Primitive Operations Page 26 The Random Access Machine Model To study algorithms in pseudo-code analytically, we need a theoretical model of a computing machine A random access machine consists of a CPU a bank of memory cells, each of which can hold an arbitrary number (of any size) or character The size of the memory is unlimited Memory cells are numbered and accessing any cell in memory takes 1 unit time (= random access) All primitive operations of the CPU take 1 unit time

27 Algorithm Analysis Pseudo-Code and Primitive Operations Page 27 Primitive Operations The primitive operations of a random access machine are the once we allow in a pseudo-code algorithm Evaluating an expression (arithmetic operations, comparisons) Assigning a value to a variable Indexing into an array Calling a method/function Returning from a method/function Largely independent from the programming language By inspecting the pseudo-code, we can count the maximum (or minimum) number of primitive operations executed by an algorithm, as a function of the input size T (n) = Running time for input of size n

28 Algorithm Analysis Pseudo-Code and Primitive Operations Page 28 Primitive Operations: Example Algorithm arraymax(a, n) currentmax A[0] for i 1 to n 1 do {i > n 1} if A[i] > currentmax then currentmax A[i] {i i + 1} return currentmax # Operations 2 1 2n 2(n 1) 2(n 1) 2(n 1) 1 Hence, the running time of arraymax is T (n) = 8n 2.

29 Algorithm Analysis Pseudo-Code and Primitive Operations Page 29 Worst Case vs. Best Case For a given input size n, the running time of an algorithm may still depend on the input Sorting a list of size n (the list may already be sorted) Finding an element in a list of size n (the element may be at the beginning of the list) Usually, if an algorithm contains if-then-else statements, it can have different running times Worst case: maximal number of primitive operations Best case: minimal number of primitive operations Example: arraymax Worst case: T (n) = 8n 2 Best case: T (n) = 6n

30 Algorithm Analysis Big-Oh Notation and Complexity Page 30 Outline Course and Textbook Overview Analysis of Algorithm Pseudo-Code and Primitive Operations Big-Oh Notation and Complexity

31 Algorithm Analysis Big-Oh Notation and Complexity Page 31 Running Time Examples n 2n 2 10n log(n) n n log(n)

32 Algorithm Analysis Big-Oh Notation and Complexity Page 32 Polynomial Running Times Feasible algorithms are those with polynomial (or better) running times: T (n) n d, d > 0 Linear: T (n) n Quadratic: T (n) n 2 Cubic: T (n) n 3 The asymptotic growth rate is not affected by constants, factors, or lower-order terms T (n) = 15n + 8 is linear T (n) = 100n is quadratic T (n) = 5n 3 + 5n 2 2n + 35 is cubic In a log-log chart, a polynomial running time turns out to be a straight line (its slope corresponds to the highest-order exponent of the polynom)

33 Algorithm Analysis Big-Oh Notation and Complexity Page 33 Log-Log Chart superpolynomial cubic Running Time T(n) quadratic linear sub- Polynomial Input Size n

34 Algorithm Analysis Big-Oh Notation and Complexity Page 34 Constants and Factors Running Time T(n) n n Input Size n

35 Algorithm Analysis Big-Oh Notation and Complexity Page 35 Big-Oh Notation The so-called big-oh notation is useful to better compare and classify the growth rates of different functions Given functions f (n) and g(n), we say that f (n) is O(g(n)), if there is a constant c > 0 and an integer n 0 1 such that Example 1: 2n + 10 is O(n) f (n) c g(n), for n n 0 2n + 10 c n n 10/(c 2), e.g. pick c = 3 and n 0 = 10 Example 2: n 2 is not O(n) n 2 c n n c, which can not be satisfied since c is a constant

36 Algorithm Analysis Big-Oh Notation and Complexity Page 36 Big-Oh Example Running Time T(n) n +10 3n n Input Size n

37 Algorithm Analysis Big-Oh Notation and Complexity Page 37 Big-Oh Example n n 1000 Running Time T(n) n n Input Size n

38 Algorithm Analysis Big-Oh Notation and Complexity Page 38 Simplification Rules If f is a function f and c a constant, then O(c f ) = O(f ) If f and g are functions, then O(f + g) = max(o(f ), O(g)) If f (n) is a polynomial of degree d, i.e. then f (n) is O(n d ) f (n) = a d n d a 2 n 2 + a 1 n + a 0 drop lower-order terms, factors, and constants e.g. 5n 4 + 2n 2 3 is O(n 4 ) Use the smallest possible equivalence class say 2n is O(n) instead of 2n is O(n 2 ) say 3n + 5 is O(n) instead of 3n + 5 is O(3n)

39 Algorithm Analysis Big-Oh Notation and Complexity Page 39 Big-Oh Ordering The statement f (n) is O(g(n)) means that the growth rate of f (n) is no more than the growth rate of g(n) We can use the big-oh notation to order functions according to their growth rate f (n) is O(g(n)) g(n) is O(f (n)) f (n) g(n) Yes No f (n) g(n) No Yes f (n) g(n) Yes Yes The set Θ(f (n)) = {g(n) : f (n) g(n)} denotes the equivalence class of functions with growth rates equal to f (n)

40 Algorithm Analysis Big-Oh Notation and Complexity Page 40 Typical Running Times Constant: O(1) Logarithmic: O(log n) Linear: O(n) Quadratic: O(n 2 ) Cubic: O(n 3 ) Polynomial: O(n d ), d > 0 Exponential: O(b n ), b > 1 Others: O( n), O(n log n) Growth rate order: 1 log n n n n log n n 2 n 3 2 n 3 n

41 Algorithm Analysis Big-Oh Notation and Complexity Page 41 Growth Rate Comparison n log n n n n log n n 2 n 3 2 n ,096 65, ,024 32, , , ,384 2,097, ,048 65,536 16,777, , , , ,024 10,240 1,048, Atoms in the universe: ca

42 Algorithm Analysis Big-Oh Notation and Complexity Page 42 The Importance of Asymptotics 1 operation/µs 256 ops./µs Running Time Maximum Problem Size n New Size 400n 2, , 000 9, 000, n 20n log n 4, , 666 7, 826, n log n 7+log n 2n , , n n n 2 n n second 1 minute 1 hour

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

Analysis of Computer Algorithms Hiroaki Kobayashi Input Algorithm Output 12/13/02 Algorithm Theory 1 Algorithm, Data Structure, Program Algorithm Well-defined, a finite step-by-step computational procedure

### Discrete Mathematics, Chapter 3: Algorithms

Discrete Mathematics, Chapter 3: Algorithms Richard Mayr University of Edinburgh, UK Richard Mayr (University of Edinburgh, UK) Discrete Mathematics. Chapter 3 1 / 28 Outline 1 Properties of Algorithms

### Running Time ( 3.1) Analysis of Algorithms. Experimental Studies ( 3.1.1) Limitations of Experiments. Pseudocode ( 3.1.2) Theoretical Analysis

Ruig Time ( 3.) Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Most algorithms trasform iput objects ito output objects.

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

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Linda Shapiro Today Registration should be done. Homework 1 due 11:59 pm next Wednesday, January 14 Review math essential

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

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

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

Analysis of Algorithms: A Brief Introduction Why? A central concept in Computer Science. Algorithms are ubiquitous. Using the Internet (sending email, transferring files, use of search engines, online

### O(n) linear time This means that the algorithm requires a number of steps proportional to the size of the task.

Time complexity : Big O notation f(n) = O(g(n)) means There are positive constants c and k such that: 0

### AP Computer Science AB Syllabus 1

AP Computer Science AB Syllabus 1 Course Resources Java Software Solutions for AP Computer Science, J. Lewis, W. Loftus, and C. Cocking, First Edition, 2004, Prentice Hall. Video: Sorting Out Sorting,

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

Introduction to Algorithms Part 3: P, NP Hard Problems 1) Polynomial Time: P and NP 2) NP-Completeness 3) Dealing with Hard Problems 4) Lower Bounds 5) Books c Wayne Goddard, Clemson University, 2004 Chapter

### Software: how we tell the machine what to do

Software: how we tell the machine what to do hardware is a general purpose machine capable of doing instructions repetitively and very fast doesn't do anything itself unless we tell it what to do software:

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

SIMS 255 Foundations of Software Design Complexity and NP-completeness Matt Welsh November 29, 2001 mdw@cs.berkeley.edu 1 Outline Complexity of algorithms Space and time complexity ``Big O'' notation Complexity

### Exam study sheet for CS2711. List of topics

Exam study sheet for CS2711 Here is the list of topics you need to know for the final exam. For each data structure listed below, make sure you can do the following: 1. Give an example of this data structure

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

Algorithms Efficiency of algorithms Computational resources: time and space Best, worst and average case performance How to compare algorithms: machine-independent measure of efficiency Growth rate Complexity

### 2. (a) Explain the strassen s matrix multiplication. (b) Write deletion algorithm, of Binary search tree. [8+8]

Code No: R05220502 Set No. 1 1. (a) Describe the performance analysis in detail. (b) Show that f 1 (n)+f 2 (n) = 0(max(g 1 (n), g 2 (n)) where f 1 (n) = 0(g 1 (n)) and f 2 (n) = 0(g 2 (n)). [8+8] 2. (a)

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

Big O notation (with a capital letter O, not a zero), also called Landau's symbol, is a symbolism used in complexity theory, computer science, and mathematics to describe the asymptotic behavior of functions.

### CSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) 3 4 4 7 5 9 6 16 7 8 8 4 9 8 10 4 Total 92.

Name: Email ID: CSE 326, Data Structures Section: Sample Final Exam Instructions: The exam is closed book, closed notes. Unless otherwise stated, N denotes the number of elements in the data structure

### CS5310 Algorithms 3 credit hours 2 hours lecture and 2 hours recitation every week

CS5310 Algorithms 3 credit hours 2 hours lecture and 2 hours recitation every week This course is a continuation of the study of data structures and algorithms, emphasizing methods useful in practice.

### Eastern Washington University Department of Computer Science. Questionnaire for Prospective Masters in Computer Science Students

Eastern Washington University Department of Computer Science Questionnaire for Prospective Masters in Computer Science Students I. Personal Information Name: Last First M.I. Mailing Address: Permanent

### 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)

Sorting revisited How did we use a binary search tree to sort an array of elements? Tree Sort Algorithm Given: An array of elements to sort 1. Build a binary search tree out of the elements 2. Traverse

### Assignment 3 (concept) Solutions

CS10b Data Structures and Algorithms Assignment 3 (concept) Solutions Due: Friday, February 18th 1. (0%) Consider the following algorithm: Algorithm Power(x, n) Input: A number x and integer n 0 Output:

### 2 Exercises and Solutions

2 Exercises and Solutions Most of the exercises below have solutions but you should try first to solve them. Each subsection with solutions is after the corresponding subsection with exercises. 2.1 Sorting

### Two General Methods to Reduce Delay and Change of Enumeration Algorithms

ISSN 1346-5597 NII Technical Report Two General Methods to Reduce Delay and Change of Enumeration Algorithms Takeaki Uno NII-2003-004E Apr.2003 Two General Methods to Reduce Delay and Change of Enumeration

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

Class Overview CSE 326: Data Structures Introduction Introduction to many of the basic data structures used in computer software Understand the data structures Analyze the algorithms that use them Know

### CSC148 Lecture 8. Algorithm Analysis Binary Search Sorting

CSC148 Lecture 8 Algorithm Analysis Binary Search Sorting Algorithm Analysis Recall definition of Big Oh: We say a function f(n) is O(g(n)) if there exists positive constants c,b such that f(n)

### Data Structures and Algorithms. with Object-Oriented Design Patterns in C++

Data Structures and Algorithms with Object-Oriented Design Patterns in C++ Data Structures and Algorithms with Object-Oriented Design Patterns in C++ Bruno R. Preiss B.A.Sc., M.A.Sc., Ph.D., P.Eng. Associate

### The divide and conquer strategy has three basic parts. For a given problem of size n,

1 Divide & Conquer One strategy for designing efficient algorithms is the divide and conquer approach, which is also called, more simply, a recursive approach. The analysis of recursive algorithms often

### Textbook: Data Structures and Algorithm Analysis in C++ (3rd edition), by M. A. Weiss. Addison-Wesley, ISBN-10: X & ISBN-13:

SYLLABUS: Data Structures, Algorithms, and Generic Programming COP-4530/CGS-5425 Fall 2006 Mon./Wed. 3:35-4:50pm @ 301 LOVE BLDG Thu. 11:00am-12:15pm (sec. 01) and 12:30-1:45pm (sec. 02) @ 202 Carothers

### Merge Sort. 2004 Goodrich, Tamassia. Merge Sort 1

Merge Sort 7 2 9 4 2 4 7 9 7 2 2 7 9 4 4 9 7 7 2 2 9 9 4 4 Merge Sort 1 Divide-and-Conquer Divide-and conquer is a general algorithm design paradigm: Divide: divide the input data S in two disjoint subsets

### Theoretical Computer Science (Bridging Course) Complexity

Theoretical Computer Science (Bridging Course) Complexity Gian Diego Tipaldi A scenario You are a programmer working for a logistics company Your boss asks you to implement a program that optimizes the

### Persistent Binary Search Trees

Persistent Binary Search Trees Datastructures, UvA. May 30, 2008 0440949, Andreas van Cranenburgh Abstract A persistent binary tree allows access to all previous versions of the tree. This paper presents

### Algorithms. Margaret M. Fleck. 18 October 2010

Algorithms Margaret M. Fleck 18 October 2010 These notes cover how to analyze the running time of algorithms (sections 3.1, 3.3, 4.4, and 7.1 of Rosen). 1 Introduction The main reason for studying big-o

### State Space Problem Definition

Blind Search State Space Problem Definition One widely used way to describe problems is by listing or describing all possible states. Solving a problem means moving through the state space from a start

### Algorithms and recursion

Read: Chapter 13 from textbook Algorithms and recursion What programs implement is recipes for solving problems. These recipes are called algorithms. We have already seen (in the practice problems from

### LECTURE NOTES ON DESIGN AND ANALYSIS OF ALGORITHMS

LECTURE NOTES ON DESIGN AND ANALYSIS OF ALGORITHMS INSTITUTE OF AERONAUTICAL ENGINEERING Dundigal 500 043, Hyderabad CONTENTS UNIT 1 BASIC CONCEPTS Algorithm Performance of Programs Algorithm Design Goals

### Writing programs to solve problem consists of a large. how to represent aspects of the problem for solution

Algorithm Efficiency & Sorting Algorithm efficiency Big-O notation Searching algorithms Sorting algorithms 1 Overview 2 If a given ADT (i.e. stack or queue) is attractive as part of a solution How will

### CSC 180 H1F Algorithm Runtime Analysis Lecture Notes Fall 2015

1 Introduction These notes introduce basic runtime analysis of algorithms. We would like to be able to tell if a given algorithm is time-efficient, and to be able to compare different algorithms. 2 Linear

### Computer Algorithms. NP-Complete Problems. CISC 4080 Yanjun Li

Computer Algorithms NP-Complete Problems NP-completeness The quest for efficient algorithms is about finding clever ways to bypass the process of exhaustive search, using clues from the input in order

### 12 Abstract Data Types

12 Abstract Data Types 12.1 Source: Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: Define the concept of an abstract data type (ADT).

### Today s Outline. Exercise. Binary Search Analysis. Linear Search Analysis. Asymptotic Analysis. Analyzing Code. Announcements. Asymptotic Analysis

Today s Outline Announcements Assignment #1 due Thurs, Oct 7 at 11:45pm Asymptotic Analysis Asymptotic Analysis CSE 7 Data Structures & Algorithms Ruth Anderson Autumn 2010 Exercise Analyzing Code bool

### Uninformed Search. Chapter 3. (Based on slides by Stuart Russell, Dan Weld, Oren Etzioni, Henry Kautz, and other UW-AI faculty)

Uninformed Search Chapter 3 (Based on slides by Stuart Russell, Dan Weld, Oren Etzioni, Henry Kautz, and other UW-AI faculty) What is Search? Search is a class of techniques for systematically finding

### 6.080 / 6.089 Great Ideas in Theoretical Computer Science Spring 2008

MIT OpenCourseWare http://ocw.mit.edu 6.080 / 6.089 Great Ideas in Theoretical Computer Science Spring 008 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.

### Binary Heap Algorithms

CS Data Structures and Algorithms Lecture Slides Wednesday, April 5, 2009 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks CHAPPELLG@member.ams.org 2005 2009 Glenn G. Chappell

### To My Parents -Laxmi and Modaiah. To My Family Members. To My Friends. To IIT Bombay. To All Hard Workers

To My Parents -Laxmi and Modaiah To My Family Members To My Friends To IIT Bombay To All Hard Workers Copyright 2010 by CareerMonk.com All rights reserved. Designed by Narasimha Karumanchi Printed in

### CS2223 Algorithms B Term 2013 Exam 2 Solutions

CS2223 Algorithms B Term 2013 Exam 2 Solutions Dec. 3, 2013 By Prof. Carolina Ruiz Dept. of Computer Science WPI PROBLEM 1: Solving Recurrences (15 points) Solve the recurrence T (n) = 2T (n/3) + n using

### ALGEBRA 1/ALGEBRA 1 HONORS

ALGEBRA 1/ALGEBRA 1 HONORS CREDIT HOURS: 1.0 COURSE LENGTH: 2 Semesters COURSE DESCRIPTION The purpose of this course is to allow the student to gain mastery in working with and evaluating mathematical

Answers to Homework 1 p. 13 1.2 3 What is the smallest value of n such that an algorithm whose running time is 100n 2 runs faster than an algorithm whose running time is 2 n on the same machine? Find the

### 1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D.

1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D. base address 2. The memory address of fifth element of an array can be calculated

### Algebraic Computation Models. Algebraic Computation Models

Algebraic Computation Models Ζυγομήτρος Ευάγγελος ΜΠΛΑ 201118 Φεβρουάριος, 2013 Reasons for using algebraic models of computation The Turing machine model captures computations on bits. Many algorithms

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

CPSC 211 Data Structures & Implementations (c) Texas A&M University [ 313] File Structures A file is a collection of data stored on mass storage (e.g., disk or tape) Why on mass storage? too big to fit

### The Selection Problem

The Selection Problem The selection problem: given an integer k and a list x 1,..., x n of n elements find the k-th smallest element in the list Example: the 3rd smallest element of the following list

### Open Data Structures (in pseudocode)

Open Data Structures (in pseudocode) Edition 0.1Gβ Pat Morin Contents Acknowledgments Why This Book? ix xi 1 Introduction 1 1.1 The Need for Efficiency..................... 2 1.2 Interfaces.............................

### Fundamental Computer Science Concepts Sequence TCSU CSCI SEQ A

Fundamental Computer Science Concepts Sequence TCSU CSCI SEQ A A. Description Introduction to the discipline of computer science; covers the material traditionally found in courses that introduce problem

### Sorting algorithms. Mergesort and Quicksort. Merge Sort. Partitioning Choice 1. Partitioning Choice 3. Partitioning Choice 2 2/5/2015

Sorting algorithms Mergesort and Quicksort Insertion, selection and bubble sort have quadratic worst case performance The faster comparison based algorithm? O(nlogn) Mergesort and Quicksort Merge Sort

### CMSC 451: Graph Properties, DFS, BFS, etc.

CMSC 451: Graph Properties, DFS, BFS, etc. Slides By: Carl Kingsford Department of Computer Science University of Maryland, College Park Based on Chapter 3 of Algorithm Design by Kleinberg & Tardos. Graphs

### 4. Factor polynomials over complex numbers, describe geometrically, and apply to real-world situations. 5. Determine and apply relationships among syn

I The Real and Complex Number Systems 1. Identify subsets of complex numbers, and compare their structural characteristics. 2. Compare and contrast the properties of real numbers with the properties of

### Data Structure. Lecture 3

Data Structure Lecture 3 Data Structure Formally define Data structure as: DS describes not only set of objects but the ways they are related, the set of operations which may be applied to the elements

### Lecture 4: Properties of and Rules for

Lecture 4: Properties of and Rules for Asymptotic Big-Oh, Big-Omega, and Big-Theta Notation Georgy Gimel farb COMPSCI 220 Algorithms and Data Structures 1 / 13 1 Time complexity 2 Big-Oh rules Scaling

### Programming Using Python

Introduction to Computation and Programming Using Python Revised and Expanded Edition John V. Guttag The MIT Press Cambridge, Massachusetts London, England CONTENTS PREFACE xiii ACKNOWLEDGMENTS xv 1 GETTING

### Binary Search. Search for x in a sorted array A.

Divide and Conquer A general paradigm for algorithm design; inspired by emperors and colonizers. Three-step process: 1. Divide the problem into smaller problems. 2. Conquer by solving these problems. 3.

### Analysis of Algorithms: The Non-recursive Case

Analysis of Algorithms: The Non-recursive Case Key topics: * Introduction * Generalizing Running Time * Doing a Timing Analysis * Big-Oh Notation * Big-Oh Operations * Analyzing Some Simple Programs -

### Data Structures. Algorithm Performance and Big O Analysis

Data Structures Algorithm Performance and Big O Analysis What s an Algorithm? a clearly specified set of instructions to be followed to solve a problem. In essence: A computer program. In detail: Defined

### CSC 143. Two important problems. Searching and Sorting. Review: Linear Search. Example. Review: Binary Search. How Efficient Is Linear Search?

CSC 43 Searching and Sorting [Chapter 9, pp. 402-432] Two important problems Search: finding something in a set of data Sorting: putting a set of data in order Both very common, very useful operations

### SEARCHING AND SORTING

SEARCHING AND SORTING Searching A basic operation in computer science Problem formulation Given: Collection (array) of values A property on values Find: a value having the property in the array Examples

### CS420/520 Algorithm Analysis Spring 2010 Lecture 04

CS420/520 Algorithm Analysis Spring 2010 Lecture 04 I. Chapter 4 Recurrences A. Introduction 1. Three steps applied at each level of a recursion a) Divide into a number of subproblems that are smaller

### Basic Programming and PC Skills: Basic Programming and PC Skills:

Texas University Interscholastic League Contest Event: Computer Science The contest challenges high school students to gain an understanding of the significance of computation as well as the details of

### Zabin Visram Room CS115 CS126 Searching. Binary Search

Zabin Visram Room CS115 CS126 Searching Binary Search Binary Search Sequential search is not efficient for large lists as it searches half the list, on average Another search algorithm Binary search Very

### COMPUTER SCIENCE SUB-GROUP

1 P a g e http://cs.stormingrobots.com Computer Science skill should go beyond just programming itself but much more importantly in problems solving skill with computational thinking even for grade schools.

### Arithmetic Coding: Introduction

Data Compression Arithmetic coding Arithmetic Coding: Introduction Allows using fractional parts of bits!! Used in PPM, JPEG/MPEG (as option), Bzip More time costly than Huffman, but integer implementation

### Eastern Washington University Department of Computer Science. Questionnaire for Prospective Masters in Computer Science Students

Eastern Washington University Department of Computer Science Questionnaire for Prospective Masters in Computer Science Students I. Personal Information Name: Last First M.I. Mailing Address: Permanent

### The Running Time of Programs

CHAPTER 3 The Running Time of Programs In Chapter 2, we saw two radically different algorithms for sorting: selection sort and merge sort. There are, in fact, scores of algorithms for sorting. This situation

### Algorithms and data structures

Algorithms and data structures This course will examine various data structures for storing and accessing information together with relationships between the items being stored, and algorithms for efficiently

### 2) What is the structure of an organization? Explain how IT support at different organizational levels.

(PGDIT 01) Paper - I : BASICS OF INFORMATION TECHNOLOGY 1) What is an information technology? Why you need to know about IT. 2) What is the structure of an organization? Explain how IT support at different

### Faster deterministic integer factorisation

David Harvey (joint work with Edgar Costa, NYU) University of New South Wales 25th October 2011 The obvious mathematical breakthrough would be the development of an easy way to factor large prime numbers

### Approximation Algorithms

Approximation Algorithms or: How I Learned to Stop Worrying and Deal with NP-Completeness Ong Jit Sheng, Jonathan (A0073924B) March, 2012 Overview Key Results (I) General techniques: Greedy algorithms

### Division of Mathematical Sciences

Division of Mathematical Sciences Chair: Mohammad Ladan, Ph.D. The Division of Mathematical Sciences at Haigazian University includes Computer Science and Mathematics. The Bachelor of Science (B.S.) degree

### 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

### Computer. Course Description

Computer Science Computer Science A Computer Science AB Course Description May 2009 The College Board: Connecting Students to College Success The College Board is a not-for-profit membership association

### Curriculum Reform. Department of Computer Sciences University of Texas at Austin 7/10/08 UTCS

Curriculum Reform Department of Computer Sciences University of Texas at Austin 7/10/08 1 CS Degrees BA with a major in CS BS, Option I: Computer Sciences BS, Option II: Turing Scholars Honors BS, Option

### Integer Factorization using the Quadratic Sieve

Integer Factorization using the Quadratic Sieve Chad Seibert* Division of Science and Mathematics University of Minnesota, Morris Morris, MN 56567 seib0060@morris.umn.edu March 16, 2011 Abstract We give

### Announcements. CSE332: Data Abstractions. Lecture 9: B Trees. Today. Our goal. M-ary Search Tree. M-ary Search Tree. Ruth Anderson Winter 2011

Announcements CSE2: Data Abstractions Project 2 posted! Partner selection due by 11pm Tues 1/25 at the latest. Homework due Friday Jan 28 st at the BEGINNING of lecture Lecture 9: B Trees Ruth Anderson

### Algorithm Homework and Test Problems

Algorithm Homework and Test Problems Steven S. Skiena Department of Computer Science State University of New York Stony Brook, NY 11794-4400 skiena@cs.sunysb.edu January 29, 2006 All of the midterm and

### IMPROVING PERFORMANCE OF RANDOMIZED SIGNATURE SORT USING HASHING AND BITWISE OPERATORS

Volume 2, No. 3, March 2011 Journal of Global Research in Computer Science RESEARCH PAPER Available Online at www.jgrcs.info IMPROVING PERFORMANCE OF RANDOMIZED SIGNATURE SORT USING HASHING AND BITWISE

### Course Descriptions for 7 th & 8 th Grade Mathematics

Course Descriptions for 7 th & 8 th Grade Mathematics 7 th Grade Academic Math This course is based upon the 7 th grade PA core standards to prepare students for future algebra based understandings. The

### Data Structures Using Java

Data Structures Using Java D. S. Malik P. S. Nair THOMSON COURSE TECHNOLOGY Australia Canada Mexico Singapore Spain United Kingdom United States TABLE OF Contents PREFACE XXV 1.Software Engineering Principles

### Data Structures and Algorithms

Data Structures and Algorithms Computational Complexity Escola Politècnica Superior d Alcoi Universitat Politècnica de València Contents Introduction Resources consumptions: spatial and temporal cost Costs

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

Introduction to Programming System Design CSCI 455x (4 Units) Description This course covers programming in Java and C++. Topics include review of basic programming concepts such as control structures,

### Data Structures and Algorithms Written Examination

Data Structures and Algorithms Written Examination 22 February 2013 FIRST NAME STUDENT NUMBER LAST NAME SIGNATURE Instructions for students: Write First Name, Last Name, Student Number and Signature where

### Chapter 1. Computation theory

Chapter 1. Computation theory In this chapter we will describe computation logic for the machines. This topic is a wide interdisciplinary field, so that the students can work in an interdisciplinary context.

### ESIEE Paris International Master of Computer Science DMC (Diplôme National de Master) Official program for years 2016 to 2018

ESIEE Paris International Master of Computer Science DMC (Diplôme National de Master) Official program for years 2016 to 2018 International Master of Computer Science DMC DMC Programme The DMC programme

### Part VII Conclusion: Computer Science

Part VII Conclusion: Computer Science This is the end of the technical material in this book. We ve explored the big ideas of composition of functions, functions as data, recursion, abstraction, and sequential

### Diagonalization. Ahto Buldas. Lecture 3 of Complexity Theory October 8, 2009. Slides based on S.Aurora, B.Barak. Complexity Theory: A Modern Approach.

Diagonalization Slides based on S.Aurora, B.Barak. Complexity Theory: A Modern Approach. Ahto Buldas Ahto.Buldas@ut.ee Background One basic goal in complexity theory is to separate interesting complexity

### Department of Industrial Engineering

Department of Industrial Engineering Master of Engineering Program in Industrial Engineering (International Program) M.Eng. (Industrial Engineering) Plan A Option 2: Total credits required: minimum 39

### Computer Science III

Computer Science III Dr. Chris Bourke Department of Computer Science & Engineering University of Nebraska Lincoln Lincoln, NE 68588, USA http://cse.unl.edu/~cbourke cbourke@cse.unl.edu 2015/08/13 14:38:26

### International Journal of Advanced Research in Computer Science and Software Engineering

Volume 3, Issue 7, July 23 ISSN: 2277 28X International Journal of Advanced Research in Computer Science and Software Engineering Research Paper Available online at: www.ijarcsse.com Greedy Algorithm:

### def: A worst-case complexity measure estimates the time required for the most timeconsuming

Section 2.3 Complexity 2.3.1 2.3 COMPLEXITY disambiguation: In the early 1960 s, Chaitin and Kolmogorov used complexity to mean measures of complicatedness. However, most theoretical computer scientists

### Theory of Computation Prof. Kamala Krithivasan Department of Computer Science and Engineering Indian Institute of Technology, Madras

Theory of Computation Prof. Kamala Krithivasan Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture No. # 31 Recursive Sets, Recursively Innumerable Sets, Encoding

### On the effect of forwarding table size on SDN network utilization

IBM Haifa Research Lab On the effect of forwarding table size on SDN network utilization Rami Cohen IBM Haifa Research Lab Liane Lewin Eytan Yahoo Research, Haifa Seffi Naor CS Technion, Israel Danny Raz

### Final Exam Solutions

Introduction to Algorithms May 19, 2011 Massachusetts Institute of Technology 6.006 Spring 2011 Professors Erik Demaine, Piotr Indyk, and Manolis Kellis Final Exam Solutions Problem 1. Final Exam Solutions