Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

P2 (15pt): Most graphics hardware includes support for a low-level operation called blit, or block transfer, which quickly copies a rectangular chunk of a pixel

image text in transcribed

P2 (15pt): Most graphics hardware includes support for a low-level operation called blit, or block transfer, which quickly copies a rectangular chunk of a pixel map (a two-dimensional array of pixel values) from one location to another. This is a two-dimensional version of the standard C library function memcpy(). Suppose we want to rotate an n x n pixel map 90 clockwise. One way to do this, at least when n is a power of two, is to split the pixel map into four xblocks, move each block to its proper position using a sequence of five blits, and then recursively rotate each block. (Why five? For the same reason the Tower of Hanoi puzzle needs a third peg.) Alternately, we could first recursive rotate the blocks and then blit them into place. | AB CD 5 blits | | recurse DB AB CD recurse 5 blits Figure 1. Two algorithms to rotate pixel map. (a) Prove that both versions of the algorithm are correct when n is a power of 2. (b) Exactly how many blits does the algorithm perform when n is a power of 2? (c) Describe how to modify the algorithm so that it works for arbitrary n, not just powers of 2. How many blits does your modified algorithm perform? (d) What is your algorithm's running time if a k x k blit takes (ka)time? (e) What if a k x k blit takes only (k) time? P2 (15pt): Most graphics hardware includes support for a low-level operation called blit, or block transfer, which quickly copies a rectangular chunk of a pixel map (a two-dimensional array of pixel values) from one location to another. This is a two-dimensional version of the standard C library function memcpy(). Suppose we want to rotate an n x n pixel map 90 clockwise. One way to do this, at least when n is a power of two, is to split the pixel map into four xblocks, move each block to its proper position using a sequence of five blits, and then recursively rotate each block. (Why five? For the same reason the Tower of Hanoi puzzle needs a third peg.) Alternately, we could first recursive rotate the blocks and then blit them into place. | AB CD 5 blits | | recurse DB AB CD recurse 5 blits Figure 1. Two algorithms to rotate pixel map. (a) Prove that both versions of the algorithm are correct when n is a power of 2. (b) Exactly how many blits does the algorithm perform when n is a power of 2? (c) Describe how to modify the algorithm so that it works for arbitrary n, not just powers of 2. How many blits does your modified algorithm perform? (d) What is your algorithm's running time if a k x k blit takes (ka)time? (e) What if a k x k blit takes only (k) time

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions

Question

What are the classifications of Bank?

Answered: 1 week ago