View by Category

Loading...

PPT – Divide and Conquer PowerPoint presentation | free to download

The Adobe Flash plugin is needed to view this content

About This Presentation

Write a Comment

User Comments (0)

Transcript and Presenter's Notes

CHAPTER 5

- Divide and Conquer

Algorithm 5.1.4 Tiling a Deficient Board with

Trominoes

This algorithm constructs a tiling by trominoes

of a deficient nn board where n is a power of 2.

Input Parameters n, a power of 2 (the board

size) the location L of the

missing square Output Parameters None tile(n,L)

if (n 2) // the board is a right

tromino T tile with T return

divide the board into four n/2 n/2 subboards

place one tromino as in Figure 5.1.4(b) //

each of the 1 1 squares in this tromino // is

considered as missing let m1,m2,m3,m4 be the

locations of the missing squares tile(n/2,m1) t

ile(n/2,m2) tile(n/2,m3) tile(n/2,m4)

Algorithm 5.2.2 Merge

This algorithm receives as input indexes i, m,

and j, and an array a, where ai, ... , am and

am 1, ... , aj are each sorted in

nondecreasing order. These two nondecreasing

subarrays are merged into a single nondecreasing

array.

Input Parameters a,i,m,j Output Parameter

a merge(a,i,m,j) p i // index in ai, ...

, am q m 1 // index in am 1, ... ,

aj r i // index in a local array c while

(p m q j) // copy smaller value to

c if (ap aq) cr ap

p p 1 else cr

aq q q 1 r r 1

...

... // copy remainder, if any, of first

subarray to c while (p m) cr

ap p p 1 r r 1 //

copy remainder, if any, of second subarray to c

while (q j) cr aq q q

1 r r 1 // copy c back to a

for r i to j ar cr

Algorithm 5.2.3 Mergesort

This algorithm sorts the array ai, ... , aj

in nondecreasing order. It uses the merge

algorithm (Algorithm 5.2.2).

Input Parameters a,i,j Output Parameter

a mergesort(a,i,j) // if only one element,

just return if (i j) return // divide a

into two nearly equal parts m (i j)/2 //

sort each half mergesort(a,i,m)

mergesort(a,m 1,j) // merge the two sorted

halves merge(a,i,m,j)

Algorithm 5.3.2 Finding the Distance Between a

Closest Pair of Points

This algorithm finds the distance between a

closest pair of points. The input is an array

p1, ... , pn of n 2 points. If p is a

point, p.x is the x- coordinate of p, and p.y

is the y-coordinate of p. The function merge is

Algorithm 5.2.2 and mergesort is Algorithm 5.2.3.

The function merge uses as the key the

y-coordinate of the point. The function mergesort

uses as the key either the x- or y-coordinate of

the point the comments indicate which. The

function dist(p,q) returns the Euclidean distance

between points p and q.

Input Parameters p Output Parameter

None closest_pair(p) n p.last

mergesort(p,1,n) // sort by x-coordinate

return rec_cl_pair(p,1,n) // rec_cl_pair

assumes that input is sorted by x-coordinate. //

At termination, the input is sorted by

y-coordinate. rec_cl_pair(p,i,j) if (j - i lt

3) mergesort(p,i,j) // sort by y-coordinate

// find the distance delta between a closest

pair delta dist(pi,pi 1) if (j

- i 1) // two points return delta

// three points if (dist(pi 1,pi 2)

lt delta) delta dist(pi 1,pi 2)

if (dist(pi,pi 2) lt delta) delta

dist(pi,pi 2) return delta

...

... k (i j)/ 2 l pk.x deltaL

rec_cl_pair(p,i,k) deltaR rec_cl_pair(p,k

1,j) delta min(deltaL,deltaR) // pi,

... , pk is now sorted by y-coordinate, and

// pk 1, ... , pj is now sorted by

y-coordinate. merge(p,i,k,j) // pi, ... ,

pj is now sorted by y-coordinate. // store

points in the vertical strip in v. t 0

for k i to j if (pk.x gt l - delta

pk.x lt l delta) t t 1

vt pk // look for closer pairs

in the strip by comparing // each point in the

strip to the next 7 points. for k 1 to t -

1 for s k 1 to min(t,k 7) delta

min(delta,dist(vk,vs)) return delta

Algorithm 5.4.1 Matrix Product

This algorithm computes the product C of the nn

matrices A and B directly from the definition of

the matrix product.

Input Parameters A,B Output Parameter

C matrix_product(A,B,C) n A.last for i

1 to n for j 1 to n Cij 0

for k 1 to n Cij Cij

Aik Bkj

About PowerShow.com

PowerShow.com is a leading presentation/slideshow sharing website. Whether your application is business, how-to, education, medicine, school, church, sales, marketing, online training or just for fun, PowerShow.com is a great resource. And, best of all, most of its cool features are free and easy to use.

You can use PowerShow.com to find and download example online PowerPoint ppt presentations on just about any topic you can imagine so you can learn how to improve your own slides and presentations for free. Or use it to find and download high-quality how-to PowerPoint ppt presentations with illustrated or animated slides that will teach you how to do something new, also for free. Or use it to upload your own PowerPoint slides so you can share them with your teachers, class, students, bosses, employees, customers, potential investors or the world. Or use it to create really cool photo slideshows - with 2D and 3D transitions, animation, and your choice of music - that you can share with your Facebook friends or Google+ circles. That's all free as well!

For a small fee you can get the industry's best online privacy or publicly promote your presentations and slide shows with top rankings. But aside from that it's free. We'll even convert your presentations and slide shows into the universal Flash format with all their original multimedia glory, including animation, 2D and 3D transition effects, embedded music or other audio, or even video embedded in slides. All for free. Most of the presentations and slideshows on PowerShow.com are free to view, many are even free to download. (You can choose whether to allow people to download your original PowerPoint presentations and photo slideshows for a fee or free or not at all.) Check out PowerShow.com today - for FREE. There is truly something for everyone!

You can use PowerShow.com to find and download example online PowerPoint ppt presentations on just about any topic you can imagine so you can learn how to improve your own slides and presentations for free. Or use it to find and download high-quality how-to PowerPoint ppt presentations with illustrated or animated slides that will teach you how to do something new, also for free. Or use it to upload your own PowerPoint slides so you can share them with your teachers, class, students, bosses, employees, customers, potential investors or the world. Or use it to create really cool photo slideshows - with 2D and 3D transitions, animation, and your choice of music - that you can share with your Facebook friends or Google+ circles. That's all free as well!

For a small fee you can get the industry's best online privacy or publicly promote your presentations and slide shows with top rankings. But aside from that it's free. We'll even convert your presentations and slide shows into the universal Flash format with all their original multimedia glory, including animation, 2D and 3D transition effects, embedded music or other audio, or even video embedded in slides. All for free. Most of the presentations and slideshows on PowerShow.com are free to view, many are even free to download. (You can choose whether to allow people to download your original PowerPoint presentations and photo slideshows for a fee or free or not at all.) Check out PowerShow.com today - for FREE. There is truly something for everyone!

presentations for free. Or use it to find and download high-quality how-to PowerPoint ppt presentations with illustrated or animated slides that will teach you how to do something new, also for free. Or use it to upload your own PowerPoint slides so you can share them with your teachers, class, students, bosses, employees, customers, potential investors or the world. Or use it to create really cool photo slideshows - with 2D and 3D transitions, animation, and your choice of music - that you can share with your Facebook friends or Google+ circles. That's all free as well!

For a small fee you can get the industry's best online privacy or publicly promote your presentations and slide shows with top rankings. But aside from that it's free. We'll even convert your presentations and slide shows into the universal Flash format with all their original multimedia glory, including animation, 2D and 3D transition effects, embedded music or other audio, or even video embedded in slides. All for free. Most of the presentations and slideshows on PowerShow.com are free to view, many are even free to download. (You can choose whether to allow people to download your original PowerPoint presentations and photo slideshows for a fee or free or not at all.) Check out PowerShow.com today - for FREE. There is truly something for everyone!

For a small fee you can get the industry's best online privacy or publicly promote your presentations and slide shows with top rankings. But aside from that it's free. We'll even convert your presentations and slide shows into the universal Flash format with all their original multimedia glory, including animation, 2D and 3D transition effects, embedded music or other audio, or even video embedded in slides. All for free. Most of the presentations and slideshows on PowerShow.com are free to view, many are even free to download. (You can choose whether to allow people to download your original PowerPoint presentations and photo slideshows for a fee or free or not at all.) Check out PowerShow.com today - for FREE. There is truly something for everyone!

Recommended

«

/ »

Page of

«

/ »

Promoted Presentations

Related Presentations

Page of

Page of

CrystalGraphics Sales Tel: (800) 394-0700 x 1 or Send an email

Home About Us Terms and Conditions Privacy Policy Contact Us Send Us Feedback

Copyright 2015 CrystalGraphics, Inc. — All rights Reserved. PowerShow.com is a trademark of CrystalGraphics, Inc.

Copyright 2015 CrystalGraphics, Inc. — All rights Reserved. PowerShow.com is a trademark of CrystalGraphics, Inc.

The PowerPoint PPT presentation: "Divide and Conquer" is the property of its rightful owner.

Do you have PowerPoint slides to share? If so, share your PPT presentation slides online with PowerShow.com. It's FREE!

Committed to assisting Depaul University and other schools with their online training by sharing educational presentations for free