Concept explainers
(a)
To describe how the function reverses that run in
(a)
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
(b)
To describe an implementation of the BIT-REVERSED-INCREMENT procedure that allows the bit-reversal permutation on an n -element to perform in
(b)
Explanation of Solution
The pseudo-code of the BIT-REVERSED-INCREMENT implementation is given below:
REVERSED-INCREMENT( a )
Set
while m bitwise-AND
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)
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)
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?
- Consider the following functions which both take as arguments three n-element arrays A, B, and C: СОMPARE-1(A, В, С) For i =1 to n For j= 1 to n If A(i] + C[i] > B[j] Return FALSE Return TRUE СOMPARE-2(A, В, С) aux := A[1] + C[1] For i = 2 to n If A[i] + C[i] > aux Then aux := A[i] + C[i] For j = 1 to n If aux > B[j] Return FALSE Return TRUE (a) When do these two functions return TRUE? (b) What is the worst-case running time for each function?arrow_forwardBitwise swaps Protiem Code ITWAPS Given an array A consisting of N integers A1, A2,..., AN, determine if you can sort this array by applying the following operation several times (possibly, zero): • Pick a pair of indices (i, j) with i jand A, & A, # 0, and swap the values of A, and Aj. Here, & denotes the bitwise AND operation For example, if A = [6, 4, 2], the two possible operations are (1,2) and (1, 3). (2, 3) cannot be performed because A2 & Az = 4 & 2 = 0. Input Format • The first line of input contains a single integer T, denoting the number of test cases, The description of T test cases follows. • The first line of each test case contains a single integer N. • The second line contains N space-separated integers A1, A2,..., AN Output Format For each test case, output the answer on a new line - YES if the given array can be sorted by repeatedly applying the given operation, and NO otherwise. You may print each character of the answer string in either uppercase or lowercase (for…arrow_forwardFor each position I between I and N-I: 1. Call the function FINDSMALLEST to determine the position of the smallest element in A in the index number to S. 2. Swap the values in A[I] and A[S]. also Explain algorithmarrow_forward
- Pseudo code for a radix 4 DIF FFT on the array a[], the data length n must be a power of 2, is must be +1 or -1:arrow_forward) Consider an n x n array ARR stored in memory consisting of 0’s and 1’s such that, in a row of ARR, all 0’s comes before any of 1’s in the row. Write an algorithm having complexity O(n), if exists, that finds the row that contains the most 0’s. Step by step explain r algorithm with an illustrative example. 6arrow_forwardApply Insertion Sort for the Following -2.5,-5.2,-7.8,-4.5,-6,-9,-10,-8,-3arrow_forward
- Suppose that two n x n matrices A and B are stored on a mesh of n2 processors such that Pi;j holds A[i; j] and B[j; i]. Write pseudocode for an asynchronous algorithm that computes the product of A and B in O(n).arrow_forwardQuestion 1 The power set P((A x B) u (B x A)) has the same number of elements as the power set P((A x B) u (A x B)) if and only if: O Ae or B e or A B O Bo or A-B O Ao or Beo ABarrow_forwardFind a (generating matrix) for the following code and find the parameters [n, k, d], code. C = {10101010, 1100, 11110000,01100110,00111100}arrow_forward
- Find the complexity of the function used to find the k th the smallest integer in an unordered array of integerarrow_forwardUsing Java Modify the program 1 to compute the multiplication of two vectors with the sizes mx1 and 1xn. The result is a matrix mxn computed as follows: the element on the position r and c in the product will be equal with m1[r][0]*m2[0][c].arrow_forwardWhat are the space requirements of an array of n integers assuming each requires c bytes?arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education