Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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 xn 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. 1 AB CD 5 blits CA DB recurse 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? (a) What is your algorithm's running time if a k x k blit takes (km)time? (e) What if a k xk blit takes only O(k) time? 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 xn 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. 1 AB CD 5 blits CA DB recurse 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? (a) What is your algorithm's running time if a k x k blit takes (km)time? (e) What if a k xk blit takes only O(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

Expert Performance Indexing In SQL Server

Authors: Jason Strate, Grant Fritchey

2nd Edition

1484211189, 9781484211182

More Books

Students also viewed these Databases questions