Analyze the operation performed by the given piece of pseudocode
and write a function that describes the number of steps required.
Give the -class of the
function
Assume that N is a power of 2.
1.
2.
3.
a.
b.
We are given that N is power of 2 and in while loop each time we are dividing K=K/2, in this way for any value of N while loop will be executed by Sqrt(N) +1 number of times. For example,
N = 16
1. After first iteration K = 16/2 = 8
2. After second iteration K = 8/2 = 4
3. After third iteration K = 4/2 =2
4. After fourth iteration k = 2/2 =1, now this will be the last iteration beacuse now K is 1.
So loop will be executed 5 times = 4 ( because 16 is 4th power of 2 ) +1
Running time =
Analyze the operation performed by the given piece of pseudocode and write a function that describes...
Write a pseudocode that has function power which takes two integer numbers as input and return an integer number according to the following: Power (2 , 3) = 8
a. Write a pseudocode for computing for any positive integer n Besides assignment and comparison, your algorithm may only use the four basic arithmetical operations. What is the time efficiency of your algorithm for the worst and best cases? Justify your answer. (The basic operation must be identified explicitly). Give one instance for the worst case and one instance for the best case respectively if there is any difference between the worst case and best case. Otherwise please indicate that...
1.Write in pseudocode a recursive algorithm for the operation deleteHighest (t), where t is the root of the BST, to delete the largest element in a BST 2.Fill in the following table, giving the “worstcase”time complexity for each operation, ineach of the two implementations, assumingthe PQ contains n elements. insert deleteHighest Worst case time compexity Heap BST
Analyze the following circuit. 1. (a) Write down the exeitation and output funetions (b) Form the excitation and state tables (c Give a word description of the circuit operation
Analyze the following circuit. 1. (a) Write down the exeitation and output funetions (b) Form the excitation and state tables (c Give a word description of the circuit operation
The graph of a piecewise-defined function is given. Write a definition for the function that best describes this graph. (1,3) 3 (-2,1) X -3 (0,0) 3 f(x) = if Isxs (Type the left piece of the function.)
Write pseudocode to solve the following problem: You are given an array A[1...n] whose each element is a point of the plane (x,y). You need to sort the array so that points with lower x-coordinates come earlier, but among points with the same x-coordinate, the ones with larger y-coordinate come earlier. So, for example, if the array contains: (1,2), (1,4), (7,10), (11,3), (14,1), (7,2) The output, in this case, should be: (1,4), (1,2), (7,10), (7,2), (11,3), (14,1) Analyze the running...
Write a java calculator program that perform the following operations: 1. function to Addition of two numbers 2. function to Subtraction of two numbers 3. function to Multiplication of two numbers 4. function to Division of two numbers 5. function to Modulus (a % b) 6. function to Power (a b ) 7. function to Square root of () 8. function to Factorial of a number (n!) 9. function to Log(n) 10. function to Sin(x) 11. function to Absolute value...
Please answer this in python
pseudocode. It's an algorithm question.
1. [10 marks] Consider the function SumKSmallest(A[0..n – 1), k) that returns the sum of the k smallest elements in an unsorted integer array A of size n. For example, given the array A=[6,-6,3,2,1,2,0,4,3,5] and k=3, the function should return -5. a. [3 marks) Write an algorithm in pseudocode for SumKSmallest using the brute force paradigm. Indicate and justify (within a few sentences) the time complexity of your algorithm. b....
Part I Short Answer (50 points) 1. Write a pseudocode declaration for a String array initialized with the following strings: “Einstein”, “Newton”, “Copernicus”, and “Kepler”. 2. Assume names in an Integer array with 20 elements. Write a pseudocode algorithm a For Loop that displays each element of the array. 3. Assume the arrays numberArray1 and numberArray2 each have 100 elements. Write a pseudocode algorithm that copies the values in numberArray1 to numberArray2 . 4. Write a pseudocode algorithm for a...
pleas answer asap
3. (20 points) Algorithm Analysis and Recurrence There is a mystery function called Mystery(n) and the pseudocode of the algorithm own as below. Assume that n 3* for some positive integer k21. Mystery (n) if n<4 3 for i1 to 9 5 for i-1 to n 2 return 1 Mystery (n/3) Print "hello" 6 (1) (5 points) Please analyze the worst-case asymptotic execution time of this algorithm. Express the execution time as a function of the input...