Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Example of Asymptotic Notation - Algorithm - Lecture Slides, Slides of Algorithms and Programming

Main points of this lecture are Example, Asymptotic, Notation, Lower, Upper, Bound, Quadtric, Cubic, Function.

Typology: Slides

2011/2012

Uploaded on 11/05/2012

ramprasad
ramprasad 🇮🇳

4.3

(22)

123 documents

1 / 34

Toggle sidebar

Related documents


Partial preview of the text

Download Example of Asymptotic Notation - Algorithm - Lecture Slides and more Slides Algorithms and Programming in PDF only on Docsity! Algorithms Lecture #07 Docsity.com Asymptotic Notation y "gn42+2h-3 — 7nhr2->F | 80000 100000 e The lower bound is satisfied because f(n) = 8n? + 2n - 3 does grow at least as fast asymptotically as n. e But the upper bound is false.Upper bounds requires that there exist positive constants cz and no such that f(n) < cen for all n = no. e Informally we know that f(n) = 8n?+ 2n - 3 will eventually exceed C2n no matter how large we make C2. e To see this,suppose we assume that constants C2 and no did exist such that S8n2+ 2n - 3 < con foralln > no If we divide both sides by n,we m (8n + 2-=) =—c2. late hvAs) a It is easy to see that in the limit, the left side tends tooo. So, no matter how large c2 is, the statement is violated. Thus f (n) ¢ O(n). The definition of ©-notation relies on proving both a lower and upper asymptotic bound. Sometimes we only interested in proving one bound or the other. The is used to state only the asymptotic upper bounds. The allows us to state only the asymptotic lower bounds. e O(g(n)) = {f(n) | there exist positive constants c and no such that O < f(n) < cg(n) for all n > no} QO(g(n)) = {f(n) | there exist positive constants c and no such that O < cg(n) < f(n) for all n > no} lim 0) - nee scone GD) for some constant c > O (nonnegative but not infinite) then f(n) € O(g(n)). lim 0) #0, N>o0 g(Nn) (either a strictly positive constant or infinity) then f(n) € ©2 (g(n)). Here is a list of common asymptotic running times: ©(1): Constant time; can’t beat it! @ (log n): Inserting into a balanced binary tree; time to find an item in a sorted array of length n using binary search. @(n): About the fastest that an algorithm can run. The divide and conquer is a strategy employed to solve a large number of computational problems: the problem into a small number of pieces solve each piece by applying divide and conquer to it recursively the pieces together into a global solution. Divide and conquer strategy is applicable in a huge number of computational problems. The first example of divide and conquer algorithm we will discuss is a simple and efficient sorting procedure called We are given a sequence of n numbers A,which we will assume are stored in an array A[1..n]. The objective is to output a permutation of this sequence sorted in increasing order. This is normally done by permuting the elements within the array A. The dividing process ends when we have split the subsequences down to a single item. A sequence of length one is trivially sorted. The key operation is the combine stage which merges together two sorted lists into a single sorted list. A sequence of length one is trivially sorted. The key operation is the combine stage which merges together two sorted lists into a single sorted list. Fortunately, the combining process is quite easy to implement. Divide and Conquer Strategy Docsity.com Merge Sort Merge sort The divide phase: split the list top- down into smaller pieces BMI) Docsity.com Limit Rule Docsity.com Merge Sort Docsity.com
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved