Extended Introduction to Computer Science CS1001.py Lecture 7: Basic Algorithms: Sorting, Merge; Time Complexity and the O( ) notation

Size: px
Start display at page:

Download "Extended Introduction to Computer Science CS1001.py Lecture 7: Basic Algorithms: Sorting, Merge; Time Complexity and the O( ) notation"

Transcription

1 Extended Introduction to Computer Science CS1001.py Lecture 7: Basic Algorithms: Sorting, Merge; Time Complexity and the O( ) notation Instructors: Daniel Deutch, Amir Rubinstein Teaching Assistants: Michal Kleinbort, Amir Gilad School of Computer Science Tel-Aviv University Winter Semester

2 Lecture 6: Highlights Integer exponentiation - Naïve method vs. (fast) iterated squaring Basic algorithms: - Sequential vs. Binary search 2

3 Lecture 7: Plan Basic algorithms (cont.): Sorting using selection sort Merging sorted lists Complexity of algorithms The O( ) notation a formal definition for complexity Worst / best case analysis Tractable and intractable algorithms 3

4 20 (reminder)

5 Binary Search the code (reminder) def binary_search(lst, key): """ iterative binary search. lst must be sorted """ n= len(lst) left = 0 right = n-1 while left <= right : middle = (right + left)//2 # middle rounded down if key == lst[middle]: # item found return middle elif key < lst[middle]: # item not in top half right = middle-1 else: # item not in bottom half left = middle+1 #print(key, "not found") return None 14

6 16

7 import time Binary Search - Real Time Measurements repeat = 20 #repeat execution several times, for more significant results for n in [10**6, 2*10**6, 4*10**6]: print("n=", n) L = [i for i in range(n)] key = -1 # why? t0 = time.clock() for i in range(repeat): res = sequential_search(l, key) t1 = time.clock() print("sequential search:", t1-t0) t0 = time.clock() for i in range(repeat): res = binary_search(l, key) t1 = time.clock() print("binary search:", t1-t0) 17

8 Binary Search - Real Time Measurements n= sequential search: binary search: n= sequential search: binary search: n= sequential search: binary search: How would the results change if we searched an element that does exist in the list? Does it depend on where in the list the element is found? 18

9 Logarithmic vs. Linear Time Algorithms n log(n) Created using Log: input x2 time + constant Linear: input x2 time x2 (approximately) 19

10 21

11 11 Sorting

12 The computational problem: The Sorting Problem Input: a set of elements Output: a sequence of the same elements, ordered by size Note that a computational problem is described in abstract terms, and is merely a desired relation between legal inputs and their outputs Technically, we will represent a sequence as a python list Possible algorithms? We will see at least 3 in this course, one today 12 These solutions employ different strategies, which has consequences in terms of efficiency, as we will see

13 The (abstract) algorithm: Selection sort Selection-Sort(lst of size n) for i=0 to n-1: find the minimum of lst[i:] swap it with the element at index i Implementation in code: def selection_sort(lst): ''' sort lst (in-place) ''' n = len(lst) for i in range(n): m_index = i #index of minimum for j in range(i+1,n): if lst[m_index] > lst[j]: m_index = j swap(lst, i, m_index) return None #no need to return lst?? def swap(lst, i, j): tmp = lst[i] lst[i] = lst[j] lst[j] = tmp 13

14 Selection Sort - Efficiency We will analyze in class the total number of iterations as a function of the list size, n. Then we will measure actual running time and see if it fits the analysis. def selection_sort(lst): ''' sort lst (in-place) ''' n = len(lst) for i in range(n): m_index = i #index of minimum for j in range(i+1,n): if lst[m_index] > lst[j]: m_index = j swap(lst, i, m_index) return None #no need to return lst?? 14

15 Selection Sort - Analysis As a measure for efficiency, we will look at the number of iterations. An underlying assumption: the time needed for all the (basic) operations in each iteration is bounded by some constant. Therefore each iteration takes a constant amount of time What is considered a basic operation? This is context dependent (discussion in class). Note that this assumption does not always hold (recall integer exponentiation as an example) So, how many iterations are needed, as a function of the input size? Input size in this case is the list s length, denoted n Does the result depend on the content of the list, or on its length only? Answers: in class and on board 15

16 Selection Sort (another version) Another, more Pythonic implementation: def selection_sort2(lst): n = len(lst) for i in range(n): m = min(lst[i:n]) m_index = lst.index(m) #find the index of the minimum lst[i], lst[m_index] = lst[m_index], lst[i] return None Is this version expected to be more efficient? 16

17 Selection Sort Actual Running Time import time import random for n in [1000,2000,4000]: lst = list(range(n)) # [0,1,2,,n-1] random.shuffle(lst) # balagan Output: t0 = time.clock() # stopper go! selection_sort(lst) t1= time.clock() # stopper end print("n=", n, t1-t0) n= n= n= How does running time seem to change with input size?

18 Selection Sort - Efficiency n 2 n log(n) Quadratic: input x2 time x2 2 (approximately) 18

19 19 Merge

20 The computational problem: Merge Input: two sorted sequences of elements Output: one sorted sequence containing all elements in both sequences Possible algorithms? 20

21 Merge - possible algorithms Simply concatenate both lists and sort them all def merge_by_sort(a,b): """ merging two lists """ C = A + B selection_sort(c) return C However, this solution does not take advantage of the input lists being sorted already. 3 running indices, for input lists (A, B) and the output (C). At each iteration, select the minimal element from A or B and copy it to C. What happens when one of the lists is completed? 21

22 Example A B C 22

23 A B C 1 23

24 A B C

25 A B C

26 A B C

27 A B C

28 A B C

29 A B C

30 A B C

31 A B C

32 A B C

33 A B ? C

34 A B ? C

35 A ? B ? C

36 def merge(a, B): ''' Merge list A of size n and list B of size m A and B must be sorted! ''' n = len(a) m = len(b) C = Code a=0; b=0; c=0 while a<n and b<m: #more element in both A and B if A[a] < B[b]: C[c] a = a+1 else: C[c] = B[b] c = c+1 if else: :#A was completed while : C[c] = B[b] b = b+1 c = c+1 #B was completed : return 36

37 def merge(a, B): ''' Merge list A of size n and list B of size m A and B must be sorted! ''' n = len(a) m = len(b) C = [0 for i in range(n+m)] Code a=0; b=0; c=0 while a<n and b<m: #more element in both A and B if A[a] < B[b]: C[c] = A[a] a+=1 else: C[c] = B[b] b+=1 c+=1 if a==n: #A was completed while b<m: C[c] = B[b] b+=1 c+=1 else: #B was completed while a<n: C[c] = A[a] a+=1 c+=1 return C C[c:] = A[a:]+B[b:] #append remaining elements one of the lists A or B is non-empty 37

38 Merge - analysis Again, we will look at the number of iterations. So, how many iterations are needed, as a function of the input size? Denote: A =n, B =m Does the answer depend on the content of the lists, or on their length only? Compare to merge_by_sort we saw earlier: def merge_by_sort(a,b): """ merging two lists """ C = A + B selection_sort(c) return C 38

39 Merge Actual Running Times for merge_func in [merge_by_sort, merge]: print(merge_func. name ) for n in [1000,2000,4000]: lst1 = [random.choice(range(10000)) for i in range(n)] lst1 = sorted(lst1) lst2 = [random.choice(range(10000)) for i in range(n)] lst2 = sorted(lst2) t0 = time.clock() #Stopper go! merge_func(lst1,lst2) t1 = time.clock() #Stopper end print("n=", n, t1-t0) Note: we chose n=m for simplicity. merge_by_sort n= n= n= merge n= n= n= Consistent with the theoretical analysis: - merge_by_sort is quadratic - merge is linear 39

40 Merge_by_python_sort merge_by_sort n= n= n= merge_by_python_sort n= n= n= merge n= n= n= def merge_by_python_sort(a,b): return sorted(a+b) Python s sort function So, python s sorted does a farely nice job! However we will not get into the interiors of sorted (at least not now). 40

41 41 Crash Intro to Complexity

42 Time Complexity: A Crash Intro A problem is a general computational question: description of parameters (input) description of solution (output) An algorithm is a step-by-step procedure, a recipe can be represented e.g. as a computer program (but also in natural languages, diagrams, animations, etc.) an abstract notion Efficient algorithms are usually preferred fastest time complexity most economical in terms of memory space complexity Time complexity analysis: measured in terms of operations, not actual timings We want to say something about the algorithm, not a specific machine/execution/programming language implementation expressed as a function of the problem size We will be interested in how the number of operations changes with input size 42

43 Growth Rate We will be interested in how the number of operations changes with input size. In most cases, we will not care about the exact function, but in its order, or growth rate (e.g., logarithmic, linear, quadratic, etc.) Sometimes we will only be interested/able to give an upper bound for this growth rate. We will, however, strive to make this upper bound as tight (=low) as we can. In this course, we will almost always be able to give tight upper bounds. We need some formal definition for growth rate upper bound. 43

44 Big O Notation We say that a function f(n) is O(g(n)) if there is a constant c such that for large enough n, f(n) c g(n) We denote this as f(n) = O(g(n)) In our context, f(n) will usually denote the number of operation an algorithm performs on an input of size n (a number with n bits, a list with n elements, etc.). sometimes f(n) will denote the number of memory cells required by the algorithm 44

45 Big O Notation Visualized f n = O(g n ) c g(n) f(n) 45

46 Big O Notation - Examples Examples: 3n + 7 = O n 3n + 7 = O(n 2 ) * 3n + 7 O( n) 5n log 2 n = O(n log n) 6log 2 n = O(n) * 2log 2 n + 12 = O(n) * 1000 n log 2 n = O(n 2 ) * 3 n 2 n [where did the log base disappear?] 2 n/100 O(n 100 ) 46 * not the tightest possible bound

47 The Asymptotic nature of Big O Consider the two functions f(n) = 10nlog 2 n + 1, and g(n) = n 2 (2 + sin (n)/3) + 2. It is not hard to verify that f(n) = O(g n ). Yet, for small values of n, f(n) > g(n), as can be seen in the following plot: f(n) g(n) 47

48 The Asymptotic nature of Big O (CONT.) But for large enough n, indeed f(n) < g(n), as can be seen in the next plot: g(n) f(n) Also, remember that for big O, f(n) may be larger than g(n), as long as there is a constant c such that f(n) < c g(n). 48

49 Complexity Hierarchy Polynomial constant logarithmic Poly-logarithmic linear O(1) O(logn) O(log 2 n) O(n) Unless asked to prove formally, You can use this hierarchical orderings as facts. O(nlogn) quadratic O(n 2 ) exponential O(2 n ) O(3 n ) We ll meet this guy later in the course 49

50 O(1) Do you understand the meaning of this? 50

51 Worst / Best Case Complexity In many cases, for the same size of input, the content of the input itself affects the complexity. We may separate between worst case and best case complexity. Examples we have seen? Examples in which this is not the case? - binary search - selection sort T wwwww n = max {tttt I : I = n} T bbbb n = min {tttt I : I = n} Note that this statement is completely nonsense: "The best time complexity is when n is very small " 51

52 Average Complexity Often the average complexity is more informative (e.g. when the worst case is rather rare). However analyzing it is usually more complicated, and requires some knowledge on the distribution of input probability. Assuming distribution is uniform: T aaaaaaa n = tttt I : I = n) I: I = n Examples from our course you will encounter soon: - Quicksort runs on average in O(nlogn) - Hash table chains are of average length O(n/m) 52

53 53 Some Previous Results All these results refer to worst case scenarios. Algorithms on integers: Addition of two n-bit integers takes O(n) iterations Multiplication of two n-bit integers takes O(n 2 ) iterations Naïve integer exponentiation a b where b = n bits takes O(2 n ) multiplications (the number of iterations depends on the size of the multiplied numbers) Iterated squaring for a b where b = n bits takes O(n) multiplications (the number of iterations depends on the size of the multiplied numbers) Algorithms on lists: Binary search on a sorted list of length n takes O(llll) iterations Selection Sort on a list of length n takes O(n 2 ) iterations Merging of 2 sorted lists of sizes n and m takes O(n + m) iterations Algorithms on strings: Palindrome checking on a string of length n takes O(n) iterations

54 54 Input Size - Clarifications We measure running time (or computational complexity) as a function of the input size. For integers, input size is the number of bits in the representation of the number in the computer. we normally count the number of "simple" bit operations (such as adding or multiplying two bits). For lists/strings/dictionaries/other collections, the input size is typically the number of elements in the collection. we normally count the number of "simple" list element operations (such as comparisons, assignments), and often ignore the size of each element. When the number of relevant operations in each iteration in bound by some constant, we can count iterations instead.

55 Tractability - Basic Distinction: How would execution time for a very fast, modern processor (10 10 ops per second, say) vary for a task with the following time complexities and n = input sizes? E E E E E E-09 n seconds seconds seconds seconds seconds seconds n 2 1.0E E E E E E-07 seconds seconds seconds seconds seconds seconds n 3 1.0E E E E E E-05 seconds seconds seconds seconds seconds seconds n 5 1.0E seconds seconds seconds seconds seconds seconds 2 n 1.02E E seconds seconds seconds minutes days years 3 n 5.9E E+09 seconds seconds hours years centuries centuries Modified from Garey and Johnson's classical book 55 Polynomial time = tractable. Exponential time = intractable.

56 Time Complexity - What is tractable in Practice? A polynomial-time algorithm is good. n 100 is polynomial, hence good. An exponential-time algorithm is bad. 2 n/100 is exponential, hence bad. Yet for input of size n = 4000, the n 100 time algorithm takes more than centuries on the above mentioned machine, while the 2 n/100 algorithm runs in just under two minutes. 56

57 Time Complexity - Advice Trust, but check! Don't just mumble "polynomial-time algorithms are good", "exponential-time algorithms are bad" because the lecturer told you so. Asymptotic run time and the O notation are important, and in most cases help clarify and simplify the analysis. But when faced with a concrete task on a specific problem size, you may be far away from "the asymptotic". In addition, constants hidden in the O notation may have unexpected impact on actual running time. 57

58 Time Complexity Advice (cont.) We will employ both asymptotic analysis and direct measurements of the actual running time. For direct measurements, we will use either the time package and the time.clock() function. Or the timeit package and the timeit.timeit() function. Both have some deficiencies, yet are highly useful for our needs. 58

Extended Introduction to Computer Science CS1001.py

Extended Introduction to Computer Science CS1001.py Extended Introduction to Computer Science CS00.py Lecture 6: Basic algorithms: Search, Merge and Sort; Time Complexity Instructors: Benny Chor, Amir Rubinstein Teaching Assistants: Michal Kleinbort, Yael

More information

Instructors: Daniel Deutch, Amir Rubinstein, Teaching Assistants: Amir Gilad, Michal Kleinbort

Instructors: Daniel Deutch, Amir Rubinstein, Teaching Assistants: Amir Gilad, Michal Kleinbort Extended Introduction to Computer Science CS1001.py Lecture 10b: Recursion and Recursive Functions Instructors: Daniel Deutch, Amir Rubinstein, Teaching Assistants: Amir Gilad, Michal Kleinbort School

More information

Lecture 11: Recursion (2) - Binary search, Quicksort, Mergesort

Lecture 11: Recursion (2) - Binary search, Quicksort, Mergesort Extended Introduction to Computer Science CS1001.py Lecture 11: Recursion (2) - Binary search, Quicksort, Mergesort Instructors: Daniel Deutch, Amir Rubinstein, Teaching Assistants: Amir Gilad, Michal

More information

Lecture 5 Part B (+6): Integer Exponentiation

Lecture 5 Part B (+6): Integer Exponentiation Extended Introduction to Computer Science CS1001.py Lecture 5 Part B (+6): Integer Exponentiation Instructors: Daniel Deutch, Amir Rubinstein Teaching Assistants: Michal Kleinbort, Ben Bogin, Noam Pan

More information

Extended Introduction to Computer Science CS1001.py. Lecture 5 Part A: Integer Representation (in Binary and other bases)

Extended Introduction to Computer Science CS1001.py. Lecture 5 Part A: Integer Representation (in Binary and other bases) Extended Introduction to Computer Science CS1001.py Lecture 5 Part A: Integer Representation (in Binary and other bases) Instructors: Daniel Deutch, Amir Rubinstein Teaching Assistants: Michal Kleinbort,

More information

CSE 373 APRIL 3 RD ALGORITHM ANALYSIS

CSE 373 APRIL 3 RD ALGORITHM ANALYSIS CSE 373 APRIL 3 RD ALGORITHM ANALYSIS ASSORTED MINUTIAE HW1P1 due tonight at midnight HW1P2 due Friday at midnight HW2 out tonight Second Java review session: Friday 10:30 ARC 147 TODAY S SCHEDULE Algorithm

More information

Extended Introduction to Computer Science CS1001.py

Extended Introduction to Computer Science CS1001.py Extended Introduction to Computer Science CS1001.py Lecture 7: Complexity continued Higher Order Functions and Lambda Expressions Numeric Derivative and Integral Floating Point Arithmetic Instructors:

More information

Extended Introduction to Computer Science CS1001.py Lecture 5: Integer Exponentiation; Search: Sequential vs. Binary Search

Extended Introduction to Computer Science CS1001.py Lecture 5: Integer Exponentiation; Search: Sequential vs. Binary Search Extended Introduction to Computer Science CS1001.py Lecture 5: Integer Exponentiation; Search: Sequential vs. Binary Search Instructors: Daniel Deutch, Amir Rubinstein Teaching Assistants: Yael Baran,

More information

Computer Science 1001.py. Lecture 11: Recursion and Recursive Functions

Computer Science 1001.py. Lecture 11: Recursion and Recursive Functions Computer Science 1001.py Lecture 11: Recursion and Recursive Functions Instructors: Daniel Deutch, Amiram Yehudai Teaching Assistants: Michal Kleinbort, Amir Rubinstein School of Computer Science Tel-Aviv

More information

Instructors: Amir Rubinstein, Daniel Deutch Teaching Assistants: Amir Gilad, Michal Kleinbort. Founding instructor: Benny Chor

Instructors: Amir Rubinstein, Daniel Deutch Teaching Assistants: Amir Gilad, Michal Kleinbort. Founding instructor: Benny Chor Extended Introduction to Computer Science CS1001.py Lecture 9: Recursion and Recursive Functions Instructors: Amir Rubinstein, Daniel Deutch Teaching Assistants: Amir Gilad, Michal Kleinbort Founding instructor:

More information

Extended Introduction to Computer Science CS1001.py Lecture 10, part A: Interim Summary; Testing; Coding Style

Extended Introduction to Computer Science CS1001.py Lecture 10, part A: Interim Summary; Testing; Coding Style Extended Introduction to Computer Science CS1001.py Lecture 10, part A: Interim Summary; Testing; Coding Style Instructors: Benny Chor, Amir Rubinstein Teaching Assistants: Michal Kleinbort, Amir Gilad

More information

Data structure and algorithm in Python

Data structure and algorithm in Python Data structure and algorithm in Python Algorithm Analysis Xiaoping Zhang School of Mathematics and Statistics, Wuhan University Table of contents 1. Experimental studies 2. The Seven Functions used in

More information

What is an algorithm?

What is an algorithm? Reminders CS 142 Lecture 3 Analysis, ADTs & Objects Program 1 was assigned - Due on 1/27 by 11:55pm 2 Abstraction Measuring Algorithm Efficiency When you utilize the mylist.index(item) function you are

More information

Computer Science 210 Data Structures Siena College Fall Topic Notes: Complexity and Asymptotic Analysis

Computer Science 210 Data Structures Siena College Fall Topic Notes: Complexity and Asymptotic Analysis Computer Science 210 Data Structures Siena College Fall 2017 Topic Notes: Complexity and Asymptotic Analysis Consider the abstract data type, the Vector or ArrayList. This structure affords us the opportunity

More information

Algorithm Analysis. College of Computing & Information Technology King Abdulaziz University. CPCS-204 Data Structures I

Algorithm Analysis. College of Computing & Information Technology King Abdulaziz University. CPCS-204 Data Structures I Algorithm Analysis College of Computing & Information Technology King Abdulaziz University CPCS-204 Data Structures I Order Analysis Judging the Efficiency/Speed of an Algorithm Thus far, we ve looked

More information

Lecture 5: Running Time Evaluation

Lecture 5: Running Time Evaluation Lecture 5: Running Time Evaluation Worst-case and average-case performance Georgy Gimel farb COMPSCI 220 Algorithms and Data Structures 1 / 13 1 Time complexity 2 Time growth 3 Worst-case 4 Average-case

More information

Lecture 16: Binary Search Trees

Lecture 16: Binary Search Trees Extended Introduction to Computer Science CS1001.py Lecture 16: Binary Search Trees Instructors: Daniel Deutch, Amir Rubinstein Teaching Assistants: Michal Kleinbort, Amir Gilad School of Computer Science

More information

asymptotic growth rate or order compare two functions, but ignore constant factors, small inputs

asymptotic growth rate or order compare two functions, but ignore constant factors, small inputs Big-Oh 1 asymptotic growth rate or order 2 compare two functions, but ignore constant factors, small inputs asymptotic growth rate or order 2 compare two functions, but ignore constant factors, small inputs

More information

Algorithm efficiency can be measured in terms of: Time Space Other resources such as processors, network packets, etc.

Algorithm efficiency can be measured in terms of: Time Space Other resources such as processors, network packets, etc. Algorithms Analysis Algorithm efficiency can be measured in terms of: Time Space Other resources such as processors, network packets, etc. Algorithms analysis tends to focus on time: Techniques for measuring

More information

CS240 Fall Mike Lam, Professor. Algorithm Analysis

CS240 Fall Mike Lam, Professor. Algorithm Analysis CS240 Fall 2014 Mike Lam, Professor Algorithm Analysis HW1 Grades are Posted Grades were generally good Check my comments! Come talk to me if you have any questions PA1 is Due 9/17 @ noon Web-CAT submission

More information

Algorithmic Analysis. Go go Big O(h)!

Algorithmic Analysis. Go go Big O(h)! Algorithmic Analysis Go go Big O(h)! 1 Corresponding Book Sections Pearson: Chapter 6, Sections 1-3 Data Structures: 4.1-4.2.5 2 What is an Algorithm? Informally, any well defined computational procedure

More information

Why efficiency of algorithm matters? CSC148 Intro. to Computer Science. Comparison of growth of functions. Why efficiency of algorithm matters?

Why efficiency of algorithm matters? CSC148 Intro. to Computer Science. Comparison of growth of functions. Why efficiency of algorithm matters? CSC48 Intro. to Computer Science Lecture : Efficiency of Algorithms, Big Oh Why efficiency of algorithm matters? An example of growth of functions: Amir H. Chinaei, Summer 06 Office Hours: R 0- BA4 ahchinaei@cs.toronto.edu

More information

[ 11.2, 11.3, 11.4] Analysis of Algorithms. Complexity of Algorithms. 400 lecture note # Overview

[ 11.2, 11.3, 11.4] Analysis of Algorithms. Complexity of Algorithms. 400 lecture note # Overview 400 lecture note #0 [.2,.3,.4] Analysis of Algorithms Complexity of Algorithms 0. Overview The complexity of an algorithm refers to the amount of time and/or space it requires to execute. The analysis

More information

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

Algorithm Analysis. (Algorithm Analysis ) Data Structures and Programming Spring / 48 Algorithm Analysis (Algorithm Analysis ) Data Structures and Programming Spring 2018 1 / 48 What is an Algorithm? An algorithm is a clearly specified set of instructions to be followed to solve a problem

More information

Why study algorithms? CS 561, Lecture 1. Today s Outline. Why study algorithms? (II)

Why study algorithms? CS 561, Lecture 1. Today s Outline. Why study algorithms? (II) Why study algorithms? CS 561, Lecture 1 Jared Saia University of New Mexico Seven years of College down the toilet - John Belushi in Animal House Q: Can I get a programming job without knowing something

More information

UNIT 5C Merge Sort Principles of Computing, Carnegie Mellon University

UNIT 5C Merge Sort Principles of Computing, Carnegie Mellon University UNIT 5C Merge Sort 15110 Principles of Computing, Carnegie Mellon University 1 Divide and Conquer In computation: Divide the problem into simpler versions of itself. Conquer each problem using the same

More information

Introduction to Programming I

Introduction to Programming I Still image from YouTube video P vs. NP and the Computational Complexity Zoo BBM 101 Introduction to Programming I Lecture #09 Development Strategies, Algorithmic Speed Erkut Erdem, Aykut Erdem & Aydın

More information

CSE 332 Winter 2015: Midterm Exam (closed book, closed notes, no calculators)

CSE 332 Winter 2015: Midterm Exam (closed book, closed notes, no calculators) _ UWNetID: Lecture Section: A CSE 332 Winter 2015: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will give

More information

Introduction to the Analysis of Algorithms. Algorithm

Introduction to the Analysis of Algorithms. Algorithm Introduction to the Analysis of Algorithms Based on the notes from David Fernandez-Baca Bryn Mawr College CS206 Intro to Data Structures Algorithm An algorithm is a strategy (well-defined computational

More information

How do we compare algorithms meaningfully? (i.e.) the same algorithm will 1) run at different speeds 2) require different amounts of space

How do we compare algorithms meaningfully? (i.e.) the same algorithm will 1) run at different speeds 2) require different amounts of space How do we compare algorithms meaningfully? (i.e.) the same algorithm will 1) run at different speeds 2) require different amounts of space when run on different computers! for (i = n-1; i > 0; i--) { maxposition

More information

CS 6402 DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK

CS 6402 DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK CS 6402 DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK Page 1 UNIT I INTRODUCTION 2 marks 1. Why is the need of studying algorithms? From a practical standpoint, a standard set of algorithms from different

More information

UNIT 5C Merge Sort. Course Announcements

UNIT 5C Merge Sort. Course Announcements UNIT 5C Merge Sort 15110 Principles of Computing, Carnegie Mellon University 1 Course Announcements Exam information 2:30 Lecture: Sections F, G, H will go to HH B131. 3:30 Lecture: Section O will go to

More information

Sorting is a problem for which we can prove a non-trivial lower bound.

Sorting is a problem for which we can prove a non-trivial lower bound. Sorting The sorting problem is defined as follows: Sorting: Given a list a with n elements possessing a total order, return a list with the same elements in non-decreasing order. Remember that total order

More information

Analysis of Algorithm. Chapter 2

Analysis of Algorithm. Chapter 2 Analysis of Algorithm Chapter 2 Outline Efficiency of algorithm Apriori of analysis Asymptotic notation The complexity of algorithm using Big-O notation Polynomial vs Exponential algorithm Average, best

More information

10/5/2016. Comparing Algorithms. Analyzing Code ( worst case ) Example. Analyzing Code. Binary Search. Linear Search

10/5/2016. Comparing Algorithms. Analyzing Code ( worst case ) Example. Analyzing Code. Binary Search. Linear Search 10/5/2016 CSE373: Data Structures and Algorithms Asymptotic Analysis (Big O,, and ) Steve Tanimoto Autumn 2016 This lecture material represents the work of multiple instructors at the University of Washington.

More information

STA141C: Big Data & High Performance Statistical Computing

STA141C: Big Data & High Performance Statistical Computing STA141C: Big Data & High Performance Statistical Computing Lecture 2: Background in Algorithms Cho-Jui Hsieh UC Davis April 5/April 10, 2017 Time Complexity Analysis Time Complexity There are always many

More information

Chapter 6 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS

Chapter 6 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS Chapter 6 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS 1 Reference books: The C Programming Language by Brian W. Kernighan and Dennis M. Ritchie Programming in C (3rd Edition) by Stephen G. Kochan. Data

More information

CS240 Fall Mike Lam, Professor. Algorithm Analysis

CS240 Fall Mike Lam, Professor. Algorithm Analysis CS240 Fall 2014 Mike Lam, Professor Algorithm Analysis Algorithm Analysis Motivation: what and why Mathematical functions Comparative & asymptotic analysis Big-O notation ("Big-Oh" in textbook) Analyzing

More information

ASYMPTOTIC COMPLEXITY

ASYMPTOTIC COMPLEXITY Simplicity is a great virtue but it requires hard work to achieve it and education to appreciate it. And to make matters worse: complexity sells better. - Edsger Dijkstra ASYMPTOTIC COMPLEXITY Lecture

More information

PROGRAM EFFICIENCY & COMPLEXITY ANALYSIS

PROGRAM EFFICIENCY & COMPLEXITY ANALYSIS Lecture 03-04 PROGRAM EFFICIENCY & COMPLEXITY ANALYSIS By: Dr. Zahoor Jan 1 ALGORITHM DEFINITION A finite set of statements that guarantees an optimal solution in finite interval of time 2 GOOD ALGORITHMS?

More information

CSE373: Data Structures and Algorithms Lecture 4: Asymptotic Analysis. Aaron Bauer Winter 2014

CSE373: Data Structures and Algorithms Lecture 4: Asymptotic Analysis. Aaron Bauer Winter 2014 CSE373: Data Structures and Algorithms Lecture 4: Asymptotic Analysis Aaron Bauer Winter 2014 Previously, on CSE 373 We want to analyze algorithms for efficiency (in time and space) And do so generally

More information

CS:3330 (22c:31) Algorithms

CS:3330 (22c:31) Algorithms What s an Algorithm? CS:3330 (22c:31) Algorithms Introduction Computer Science is about problem solving using computers. Software is a solution to some problems. Algorithm is a design inside a software.

More information

UNIT 1 ANALYSIS OF ALGORITHMS

UNIT 1 ANALYSIS OF ALGORITHMS UNIT 1 ANALYSIS OF ALGORITHMS Analysis of Algorithms Structure Page Nos. 1.0 Introduction 7 1.1 Objectives 7 1.2 Mathematical Background 8 1.3 Process of Analysis 12 1.4 Calculation of Storage Complexity

More information

STA141C: Big Data & High Performance Statistical Computing

STA141C: Big Data & High Performance Statistical Computing STA141C: Big Data & High Performance Statistical Computing Lecture 3: Background in Algorithms Cho-Jui Hsieh UC Davis April 13, 2017 Time Complexity Analysis Time Complexity There are always many ways

More information

Assignment 1 (concept): Solutions

Assignment 1 (concept): Solutions CS10b Data Structures and Algorithms Due: Thursday, January 0th Assignment 1 (concept): Solutions Note, throughout Exercises 1 to 4, n denotes the input size of a problem. 1. (10%) Rank the following functions

More information

CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims. Lecture 10: Asymptotic Complexity and

CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims. Lecture 10: Asymptotic Complexity and CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims Lecture 10: Asymptotic Complexity and What Makes a Good Algorithm? Suppose you have two possible algorithms or

More information

RUNNING TIME ANALYSIS. Problem Solving with Computers-II

RUNNING TIME ANALYSIS. Problem Solving with Computers-II RUNNING TIME ANALYSIS Problem Solving with Computers-II Performance questions 4 How efficient is a particular algorithm? CPU time usage (Running time complexity) Memory usage Disk usage Network usage Why

More information

Chapter 2: Complexity Analysis

Chapter 2: Complexity Analysis Chapter 2: Complexity Analysis Objectives Looking ahead in this chapter, we ll consider: Computational and Asymptotic Complexity Big-O Notation Properties of the Big-O Notation Ω and Θ Notations Possible

More information

Algorithm Analysis. CENG 707 Data Structures and Algorithms

Algorithm Analysis. CENG 707 Data Structures and Algorithms Algorithm Analysis CENG 707 Data Structures and Algorithms 1 Algorithm An algorithm is a set of instructions to be followed to solve a problem. There can be more than one solution (more than one algorithm)

More information

Measuring algorithm efficiency

Measuring algorithm efficiency CMPT 225 Measuring algorithm efficiency Timing Counting Cost functions Cases Best case Average case Worst case Searching Sorting O Notation O notation's mathematical basis O notation classes and notations

More information

Asymptotic Analysis of Algorithms

Asymptotic Analysis of Algorithms Asymptotic Analysis of Algorithms EECS2030 B: Advanced Object Oriented Programming Fall 2018 CHEN-WEI WANG Algorithm and Data Structure A data structure is: A systematic way to store and organize data

More information

EECS 477: Introduction to algorithms. Lecture 6

EECS 477: Introduction to algorithms. Lecture 6 EECS 477: Introduction to algorithms. Lecture 6 Prof. Igor Guskov guskov@eecs.umich.edu September 24, 2002 1 Lecture outline Finish up with asymptotic notation Asymptotic analysis of programs Analyzing

More information

Today s Outline. CSE 326: Data Structures Asymptotic Analysis. Analyzing Algorithms. Analyzing Algorithms: Why Bother? Hannah Takes a Break

Today s Outline. CSE 326: Data Structures Asymptotic Analysis. Analyzing Algorithms. Analyzing Algorithms: Why Bother? Hannah Takes a Break Today s Outline CSE 326: Data Structures How s the project going? Finish up stacks, queues, lists, and bears, oh my! Math review and runtime analysis Pretty pictures Asymptotic analysis Hannah Tang and

More information

Module 1: Asymptotic Time Complexity and Intro to Abstract Data Types

Module 1: Asymptotic Time Complexity and Intro to Abstract Data Types Module 1: Asymptotic Time Complexity and Intro to Abstract Data Types Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu

More information

O(1) How long does a function take to run? CS61A Lecture 6

O(1) How long does a function take to run? CS61A Lecture 6 How long does a function take to run? It depends on what computer it is run on! CS6A Lecture 6 20-06-28 Colleen Lewis Assumptions We want something independent of the speed of the computer We typically

More information

Algorithm. Algorithm Analysis. Algorithm. Algorithm. Analyzing Sorting Algorithms (Insertion Sort) Analyzing Algorithms 8/31/2017

Algorithm. Algorithm Analysis. Algorithm. Algorithm. Analyzing Sorting Algorithms (Insertion Sort) Analyzing Algorithms 8/31/2017 8/3/07 Analysis Introduction to Analysis Model of Analysis Mathematical Preliminaries for Analysis Set Notation Asymptotic Analysis What is an algorithm? An algorithm is any well-defined computational

More information

Algorithm Analysis. Performance Factors

Algorithm Analysis. Performance Factors Algorithm Analysis How can we demonstrate that one algorithm is superior to another without being misled by any of the following problems: Special cases Every algorithm has certain inputs that allow it

More information

Extended Introduction to Computer Science CS1001.py Lecture 15: The Dictionary Problem Hash Functions and Hash Tables

Extended Introduction to Computer Science CS1001.py Lecture 15: The Dictionary Problem Hash Functions and Hash Tables Extended Introduction to Computer Science CS1001.py Lecture 15: The Dictionary Problem Hash Functions and Hash Tables Instructors: Amir Rubinstein, Amiram Yehudai Teaching Assistants: Yael Baran, Michal

More information

Algorithms and Programming

Algorithms and Programming Algorithms and Programming Lecture 8 Recursion. Computational complexity Camelia Chira Course content Programming in the large Programming in the small Introduction in the software development process

More information

Algorithms and Data Structures

Algorithms and Data Structures Algorithms and Data Structures Spring 2019 Alexis Maciel Department of Computer Science Clarkson University Copyright c 2019 Alexis Maciel ii Contents 1 Analysis of Algorithms 1 1.1 Introduction.................................

More information

Another Sorting Algorithm

Another Sorting Algorithm 1 Another Sorting Algorithm What was the running time of insertion sort? Can we do better? 2 Designing Algorithms Many ways to design an algorithm: o Incremental: o Divide and Conquer: 3 Divide and Conquer

More information

(Refer Slide Time: 1:27)

(Refer Slide Time: 1:27) Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture 1 Introduction to Data Structures and Algorithms Welcome to data

More information

Math 4242 Polynomial Time algorithms, IndependentSet problem

Math 4242 Polynomial Time algorithms, IndependentSet problem Math 4242 Polynomial Time algorithms, IndependentSet problem Many of the algorithms we have looked at so far have a reasonable running time. Not all algorithms do. We make this idea more precise. Definition:

More information

Intro to Algorithms. Professor Kevin Gold

Intro to Algorithms. Professor Kevin Gold Intro to Algorithms Professor Kevin Gold What is an Algorithm? An algorithm is a procedure for producing outputs from inputs. A chocolate chip cookie recipe technically qualifies. An algorithm taught in

More information

Data Structures and Algorithms

Data Structures and Algorithms Berner Fachhochschule - Technik und Informatik Data Structures and Algorithms Topic 1: Algorithm Analysis Philipp Locher FS 2018 Outline Course and Textbook Overview Analysis of Algorithm Pseudo-Code and

More information

Outline and Reading. Analysis of Algorithms 1

Outline and Reading. Analysis of Algorithms 1 Outline and Reading Algorithms Running time ( 3.1) Pseudo-code ( 3.2) Counting primitive operations ( 3.4) Asymptotic notation ( 3.4.1) Asymptotic analysis ( 3.4.2) Case study ( 3.4.3) Analysis of Algorithms

More information

15110 Principles of Computing, Carnegie Mellon University - CORTINA. Binary Search. Required: List L of n unique elements.

15110 Principles of Computing, Carnegie Mellon University - CORTINA. Binary Search. Required: List L of n unique elements. UNIT 5B Binary Search 1 Binary Search Required: List L of n unique elements. The elements must be sorted in increasing order. Result: The index of a specific element (called the key) or None if the key

More information

Extended Introduction to Computer Science CS1001.py. Lecture 4: Functions & Side Effects ; Integer Representations: Unary, Binary, and Other Bases

Extended Introduction to Computer Science CS1001.py. Lecture 4: Functions & Side Effects ; Integer Representations: Unary, Binary, and Other Bases Extended Introduction to Computer Science CS1001.py Lecture 4: Functions & Side Effects ; Integer Representations: Unary, Binary, and Other Bases Instructors: Daniel Deutch, Amir Rubinstein Teaching Assistants:

More information

Data Structures and Algorithms

Data Structures and Algorithms Data Structures and Algorithms About the course (objectives, outline, recommended reading) Problem solving Notions of Algorithmics (growth of functions, efficiency, programming model, example analysis)

More information

Extended Introduction to Computer Science CS1001.py Lecture 11: Recursion and Recursive Functions, cont.

Extended Introduction to Computer Science CS1001.py Lecture 11: Recursion and Recursive Functions, cont. Extended Introduction to Computer Science CS1001.py Lecture 11: Recursion and Recursive Functions, cont. Instructors: Amir Rubinstein, Amiram Yehudai Teaching Assistants: Yael Baran, Michal Kleinbort Founding

More information

Intro. Speed V Growth

Intro. Speed V Growth Intro Good code is two things. It's elegant, and it's fast. In other words, we got a need for speed. We want to find out what's fast, what's slow, and what we can optimize. First, we'll take a tour of

More information

Algorithm Analysis. Part I. Tyler Moore. Lecture 3. CSE 3353, SMU, Dallas, TX

Algorithm Analysis. Part I. Tyler Moore. Lecture 3. CSE 3353, SMU, Dallas, TX Algorithm Analysis Part I Tyler Moore CSE 5, SMU, Dallas, TX Lecture how many times do you have to turn the crank? Some slides created by or adapted from Dr. Kevin Wayne. For more information see http://www.cs.princeton.edu/~wayne/kleinberg-tardos.

More information

Recitation 9. Prelim Review

Recitation 9. Prelim Review Recitation 9 Prelim Review 1 Heaps 2 Review: Binary heap min heap 1 2 99 4 3 PriorityQueue Maintains max or min of collection (no duplicates) Follows heap order invariant at every level Always balanced!

More information

CSE 146. Asymptotic Analysis Interview Question of the Day Homework 1 & Project 1 Work Session

CSE 146. Asymptotic Analysis Interview Question of the Day Homework 1 & Project 1 Work Session CSE 146 Asymptotic Analysis Interview Question of the Day Homework 1 & Project 1 Work Session Comparing Algorithms Rough Estimate Ignores Details Or really: independent of details What are some details

More information

Data Structures Lecture 8

Data Structures Lecture 8 Fall 2017 Fang Yu Software Security Lab. Dept. Management Information Systems, National Chengchi University Data Structures Lecture 8 Recap What should you have learned? Basic java programming skills Object-oriented

More information

QB LECTURE #1: Algorithms and Dynamic Programming

QB LECTURE #1: Algorithms and Dynamic Programming QB LECTURE #1: Algorithms and Dynamic Programming Adam Siepel Nov. 16, 2015 2 Plan for Today Introduction to algorithms Simple algorithms and running time Dynamic programming Soon: sequence alignment 3

More information

Algorithm Analysis. Applied Algorithmics COMP526. Algorithm Analysis. Algorithm Analysis via experiments

Algorithm Analysis. Applied Algorithmics COMP526. Algorithm Analysis. Algorithm Analysis via experiments Applied Algorithmics COMP526 Lecturer: Leszek Gąsieniec, 321 (Ashton Bldg), L.A.Gasieniec@liverpool.ac.uk Lectures: Mondays 4pm (BROD-107), and Tuesdays 3+4pm (BROD-305a) Office hours: TBA, 321 (Ashton)

More information

Analysis of Algorithms

Analysis of Algorithms ITP21 - Foundations of IT 1 Analysis of Algorithms Analysis of algorithms Analysis of algorithms is concerned with quantifying the efficiency of algorithms. The analysis may consider a variety of situations:

More information

csci 210: Data Structures Program Analysis

csci 210: Data Structures Program Analysis csci 210: Data Structures Program Analysis Summary Summary analysis of algorithms asymptotic analysis and notation big-o big-omega big-theta commonly used functions discrete math refresher Analysis of

More information

Extended Introduction to Computer Science CS1001.py. Lecture 5: Integer Exponentiation Efficiency of Computations; Search

Extended Introduction to Computer Science CS1001.py. Lecture 5: Integer Exponentiation Efficiency of Computations; Search Extended Introduction to Computer Science CS1001.py Lecture 5: Integer Exponentiation Efficiency of Computations; Search Instructors: Benny Chor, Amir Rubinstein Teaching Assistants: Amir Gilad, Michal

More information

Computer Science 1000: Part #2. Algorithms

Computer Science 1000: Part #2. Algorithms Computer Science 1000: Part #2 Algorithms PROBLEMS, ALGORITHMS, AND PROGRAMS REPRESENTING ALGORITHMS AS PSEUDOCODE EXAMPLE ALGORITHMS ASSESSING ALGORITHM EFFICIENCY ... To Recap... The fundamental task

More information

LECTURE 9 Data Structures: A systematic way of organizing and accessing data. --No single data structure works well for ALL purposes.

LECTURE 9 Data Structures: A systematic way of organizing and accessing data. --No single data structure works well for ALL purposes. LECTURE 9 Data Structures: A systematic way of organizing and accessing data. --No single data structure works well for ALL purposes. Input Algorithm Output An algorithm is a step-by-step procedure for

More information

Sorting and Selection

Sorting and Selection Sorting and Selection Introduction Divide and Conquer Merge-Sort Quick-Sort Radix-Sort Bucket-Sort 10-1 Introduction Assuming we have a sequence S storing a list of keyelement entries. The key of the element

More information

MergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: September 28, 2016 Edited by Ofir Geri

MergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: September 28, 2016 Edited by Ofir Geri CS161, Lecture 2 MergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: September 28, 2016 Edited by Ofir Geri 1 Introduction Today, we will introduce a fundamental algorithm design paradigm,

More information

1 Introduction. 2 InsertionSort. 2.1 Correctness of InsertionSort

1 Introduction. 2 InsertionSort. 2.1 Correctness of InsertionSort CS 161, Lecture 2 MergeSort, Recurrences 101, and Asymptotic Analysis Scribes: Michael Kim (2015), Ofir Geri (2016), M. Wootters (2017) Date: September 27, 2017 Adapted From Virginia Williams lecture notes

More information

CS 261 Data Structures. Big-Oh Analysis: A Review

CS 261 Data Structures. Big-Oh Analysis: A Review CS 261 Data Structures Big-Oh Analysis: A Review Big-Oh: Purpose How can we characterize the runtime or space usage of an algorithm? We want a method that: doesn t depend upon hardware used (e.g., PC,

More information

Algorithm Analysis. Gunnar Gotshalks. AlgAnalysis 1

Algorithm Analysis. Gunnar Gotshalks. AlgAnalysis 1 Algorithm Analysis AlgAnalysis 1 How Fast is an Algorithm? 1 Measure the running time» Run the program for many data types > Use System.currentTimeMillis to record the time Worst Time Average Best» Usually

More information

Run Times. Efficiency Issues. Run Times cont d. More on O( ) notation

Run Times. Efficiency Issues. Run Times cont d. More on O( ) notation Comp2711 S1 2006 Correctness Oheads 1 Efficiency Issues Comp2711 S1 2006 Correctness Oheads 2 Run Times An implementation may be correct with respect to the Specification Pre- and Post-condition, but nevertheless

More information

Elementary maths for GMT. Algorithm analysis Part I

Elementary maths for GMT. Algorithm analysis Part I Elementary maths for GMT Algorithm analysis Part I 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

More information

Extended Introduction to Computer Science CS1001.py

Extended Introduction to Computer Science CS1001.py Extended Introduction to Computer Science CS1001.py Lecture 11: Recursion and Recursive Functions (cont.) Instructors: Daniel Deutch, Amir Rubinstein Teaching Assistants: Michal Kleinbort, Yael Baran,

More information

Algorithm Efficiency & Sorting. Algorithm efficiency Big-O notation Searching algorithms Sorting algorithms

Algorithm Efficiency & Sorting. Algorithm efficiency Big-O notation Searching algorithms Sorting algorithms Algorithm Efficiency & Sorting Algorithm efficiency Big-O notation Searching algorithms Sorting algorithms Overview Writing programs to solve problem consists of a large number of decisions how to represent

More information

Algorithm Efficiency & Sorting. Algorithm efficiency Big-O notation Searching algorithms Sorting algorithms

Algorithm Efficiency & Sorting. Algorithm efficiency Big-O notation Searching algorithms Sorting algorithms Algorithm Efficiency & Sorting Algorithm efficiency Big-O notation Searching algorithms Sorting algorithms Overview Writing programs to solve problem consists of a large number of decisions how to represent

More information

Algorithm Analysis. Review of Terminology Some Consequences of Growth Rates. The book s big example: Detecting anagrams. There be math here!

Algorithm Analysis. Review of Terminology Some Consequences of Growth Rates. The book s big example: Detecting anagrams. There be math here! Algorithm Analysis Review of Terminology Some Consequences of Growth Rates There be math here! The book s big example: Detecting anagrams 4 different algorithms! Big O Definition: T(N) = O(f(N)) if there

More information

Lecture 5 Sorting Arrays

Lecture 5 Sorting Arrays Lecture 5 Sorting Arrays 15-122: Principles of Imperative Computation (Spring 2018) Frank Pfenning, Rob Simmons We begin this lecture by discussing how to compare running times of functions in an abstract,

More information

3. Java - Language Constructs I

3. Java - Language Constructs I Names and Identifiers A program (that is, a class) needs a name public class SudokuSolver {... 3. Java - Language Constructs I Names and Identifiers, Variables, Assignments, Constants, Datatypes, Operations,

More information

Algorithm Analysis. Big Oh

Algorithm Analysis. Big Oh Algorithm Analysis with Big Oh Data Structures and Design with Java and JUnit Chapter 12 Rick Mercer Algorithm Analysis w Objectives Analyze the efficiency of algorithms Analyze a few classic algorithms

More information

Today. CISC101 Reminders & Notes. Searching in Python - Cont. Searching in Python. From last time

Today. CISC101 Reminders & Notes. Searching in Python - Cont. Searching in Python. From last time CISC101 Reminders & Notes Test 3 this week in tutorial USATs at the beginning of next lecture Please attend and fill out an evaluation School of Computing First Year Information Session Thursday, March

More information

Introduction to Computer Science

Introduction to Computer Science Introduction to Computer Science CSCI 109 Readings St. Amant, Ch. 4, Ch. 8 China Tianhe-2 Andrew Goodney Spring 2018 An algorithm (pronounced AL-go-rithum) is a procedure or formula for solving a problem.

More information

1. Attempt any three of the following: 15

1. Attempt any three of the following: 15 (Time: 2½ hours) Total Marks: 75 N. B.: (1) All questions are compulsory. (2) Make suitable assumptions wherever necessary and state the assumptions made. (3) Answers to the same question must be written

More information

CMPSCI 187: Programming With Data Structures. Lecture 5: Analysis of Algorithms Overview 16 September 2011

CMPSCI 187: Programming With Data Structures. Lecture 5: Analysis of Algorithms Overview 16 September 2011 CMPSCI 187: Programming With Data Structures Lecture 5: Analysis of Algorithms Overview 16 September 2011 Analysis of Algorithms Overview What is Analysis of Algorithms? L&C s Dishwashing Example Being

More information