Introduction to Algorithms
Introduction to Algorithms
3rd Edition
ISBN: 9780262033848
Author: Thomas H. Cormen, Ronald L. Rivest, Charles E. Leiserson, Clifford Stein
Publisher: MIT Press
bartleby

Concept explainers

Question
Book Icon
Chapter 17, Problem 1P

(a)

Program Plan Intro

To describe how the function reverses that run in θ(k) time can runs in O(nk) if the length is n=2k .

(a)

Expert Solution
Check Mark

Explanation of Solution

The reverse operation is performed by using two arrays. Consider another array and copy the elements in the reverse order to the new array from the original array. The operation is performed as swapping the values with the same index in the both array.

After swapping the element to current index it required to set the entry in the second array corresponding to the bit-reverses.

Since the swapping of the element time is depends upon the number of element so suppose there are n -elements in the function of k bit reversed algorithm then the running time is equal to the product of n and k .

(b)

Program Plan Intro

To describe an implementation of the BIT-REVERSED-INCREMENT procedure that allows the bit-reversal permutation on an n -element to perform in O(n) time.

(b)

Expert Solution
Check Mark

Explanation of Solution

The pseudo-code of the BIT-REVERSED-INCREMENT implementation is given below:

REVERSED-INCREMENT( a )

Set m=1 followed by k zeroes.

while m bitwise-AND ais not zero do

  a=abitwiseXOR m .

shift m right by 1.

end while.

return m bitwise-OR a.

end

The algorithm swaps the value of binary counter and reversed counter so it updates the values by incrementing the counter variable.

The operation is performed is carried out bit by bit so it consider one bit at the time to compared and reversed the values.

The BIT-REVERSED-INCREMENT operation will take constant amortized time and to perform the bit-reversed permutation requires a normal binary counter and a reversed counter.

(c)

Program Plan Intro

To explain how shifting any word shift left or right by one bit in unit time without changing the run time of the implementation.

(c)

Expert Solution
Check Mark

Explanation of Solution

The procedure uses single shift so the complexity of the procedure is not changed as any words shift left with unit time.

The procedural is based on the number of bit swapped not on the operation therefore any change in the operation such as type of shift does not affect the time complexity of the procedure.

Since, the operation time is depends upon the number of element so the running time is equal to the product of n and k , where n is the size and k is shift bit.

Hence, there is no change in the running time of implementation.

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
Consider the binary linear codeC 5 {00000, 10011, 01010, 11001, 00101, 10110, 01111, 11100}.Construct a standard array for C. Use nearest-neighbor decoding todecode 11101 and 01100. If the received word 11101 has exactlyone error, can we determine the intended code word? If the receivedword 01100 has exactly one error, can we determine the intendedcode word?
MPI Programming: Write a MPI program in C/C++ to multiply two n-by-n matrices using p processors organized ina ring network with 1 ≤ p ≤ 12. Use the algorithm laid out here: P0 will generate and send ith row-band of Aand ith row-band of BT (the transpose of matrix B) to Pi, 1 ≤ i ≤ p − 1 (thus, space allocated should only be toaccommodate row-bands of A, BT and C). To compute their row-bands of product matrix C, the processors willuse p steps of computation (multiplying row-bands of A and BT producing a block of row-band of C) and (p-1)steps of communication (sending the row-band of BT to the right neighbor and receiving from the left neighbor).You must only use send/receive primitives. P0 finally receives the ith row-bands of product matrix C from Pi,1 ≤ i ≤ p − 1, and prints it out.
twosComplementBinaryToDecimal functionThis function takes a static array and bit pattern length as its arguments. The function must return the decimal (integer) value computed from the two's complement binary representation given in the array argument in the given bit pattern length. Assume the array is populated with binary bits in the given bit pattern length and that it is a two's complement representation.
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education