×

### Let's log you in.

or

Don't have a StudySoup account? Create one here!

×

or

## ANALYS OF ALGORITHMS

by: Carlo Monahan

7

0

13

# ANALYS OF ALGORITHMS COT 5405

Marketplace > University of Florida > OTHER > COT 5405 > ANALYS OF ALGORITHMS
Carlo Monahan
UF
GPA 3.85

Sanjay Ranka

These notes were just uploaded, and will be ready to view shortly.

Either way, we'll remind you when they're ready :)

Get a free preview of these Notes, just enter your email below.

×
Unlock Preview

COURSE
PROF.
Sanjay Ranka
TYPE
Class Notes
PAGES
13
WORDS
KARMA
25 ?

## Popular in OTHER

This 13 page Class Notes was uploaded by Carlo Monahan on Friday September 18, 2015. The Class Notes belongs to COT 5405 at University of Florida taught by Sanjay Ranka in Fall. Since its upload, it has received 7 views. For similar materials see /class/206636/cot-5405-university-of-florida in OTHER at University of Florida.

×

## Reviews for ANALYS OF ALGORITHMS

×

×

### What is Karma?

#### You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 09/18/15
ANALYSIS OF ALGORITHMS Sanjay Ranka September 13 2002 Divide and Conquer Part ll Divide and Conquer Method At each level of recursion 1 Divide the problem into a number of subproblems 2 Conquer the problems by solving them recursively or for small subproblems solve in a straightforward manner 3 Combine the solutions to the subproblem into the solution of the original problem Merge Sort Sanjay Ranka 1 COT 5405 Divide and Conquer Part ll Maximum Subsequence Problem Given possibly negative integers am a2 an nd the maximum value of the Sim ak for some values of 2 and j 1 g 2 g j g n For convenience the maximum subsequence sum is 0 if all the integers are negative As an example for inputs 4 W the answer is 22 Sanjay Ranka 2 COT 5405 Divide and Conquer Part II Maximum Subsequence Problem Algorithm 1 Step 1 Set MAXSUM 0 Step 2 Calculate 8Z j zigz al and update the MAXSUM by 3z j if 3z j gt MAXSUM for 1 g z gj g 71 Step 3 MAXSUM is the answer COT 5405 Sanjay Ranka Divide and Conquer Part II Analysis In sij we sum j 2 1 terms Therefore the complexity of the algorithm is n n j n n 2 221 2120 z1 z jZ n nz 1n z 2 A 2391 2 1 n 3214M 3n 2 2n 3Z 2 2 W 0013 Note that sij zigz al sij 1 am Sanjay Ranka 4 COT 5405 Divide and Conquer Part ll Maximum Subsequence Problem Algorithm 2 We should be able to nd the M AX S U M in either the left half or the right half of the sequence For example in 4 10 12 5 7 7 8 3 1 the MAXSUM of the rst half is 22 and M AX S U M of the second half is 12 Step 1 Divide the sequence in two equal halves Step 2 Find the MAXSUML of the left half Via this recursive method Step 3 Find the M AX SU M R of the right half Via this recursive rnethod COT 5405 Sanjay Ranka Divide and Conquer Part II Step 4 Find MAXSUM maxMAXSUML MAXSUMR Sanjay Ranka 6 COT 5405 Divide and Conquer Part ll Flaw What happens if the maximum sum is due to terms in the middle of of the sequence as m the following example 4 3 5 2 7 1 2 6 2 Here M AX S U M L is 6 due to sum of rst three terms M AX SU M R is 8 due to sum of 6th and 7th terms and M AX S U M is 11 due to sum of terms 1 through 7 Sanjay Ranka 7 COT 5405 Divide and Conquer Part 11 Maximum Subsequence Problem Algorithm 3 Step 1 Divide the sequence in two equal halves Set m L1n2j Step 2 Find the MAXSUML of the left half Via this recursive method Step 3 Find the M AX SU M R of the right half Via this recursive method Step 4a Set MAXSUMBL 0 For 2 m set BORDERm L am and for 239 m 1 1 Sanjay Ranka 8 COT 5405 Divide and Conquer Part ll calculate BORDERQ L BORDERQ 1 L am Step 4b If BORDERQ L gt MAXSUMBL then MAXSUMBL BORDERQ L Step 5 As step 4 except for the right half of the sequence Step 6 Finally M AX S U M inaxMAXSUML MAXSUMR MAXSUMBL MAXSUMBR Analysis If Tn denotes the total number of basic operations of addition then Tn 2Tn 2 71 Here we have ignored the costs of managing of the stacks Sanjay Ranka 9 COT 5405 Divide and Conquer Part II assignments etc The term 71 represents the cost of adding sums from the border to the edges Solution of this equation With T1 1 gives Tn 71 lg n n Sanjay Ranka 10 COT 5405 Divide and Conquer Part ll Multiplication of two numbers Let U Ugn1UQn2 u1u02 and V U2n 1U2n 2 U11Jo2 and our goal is to nd U gtlt V Ordinary multiplication requires execution time 012 Sanjay Ranka ll COT 5405

×

×

### BOOM! Enjoy Your Free Notes!

×

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

## Why people love StudySoup

Bentley McCaw University of Florida

#### "I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"

Janice Dongeun University of Washington

#### "I used the money I made selling my notes & study guides to pay for spring break in Olympia, Washington...which was Sweet!"

Bentley McCaw University of Florida

Forbes

#### "Their 'Elite Notetakers' are making over \$1,200/month in sales by creating high quality content that helps their classmates in a time of need."

Become an Elite Notetaker and start selling your notes online!
×

### Refund Policy

#### STUDYSOUP CANCELLATION POLICY

All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email support@studysoup.com

#### STUDYSOUP REFUND POLICY

StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here: support@studysoup.com

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to support@studysoup.com