a. Write a pseudocode for computing for any positive integer n Besides assignment and comparison, your...
Design an algorithm for computing√nfor any positive integer n. Besides assignment and comparison, your algorithm may only use the four basic arithmetical operations.
URGENT Question 3 25 pts ArrayMystery: Input: n: a positive integer Pseudocode: Let output be an empty array For i = 1 to n j = 1 While ij <= n Addj to the end of output j - j + 1 Return output Answer the following questions about the ArrayMystery algorithm above. a) How many times will the inner while loop iterate? You should express your answer in terms of i and n, using Big-Oh notation. Briefly justify your...
Using the pseudocode answer these questions Algorithm 1 CS317FinalAlgorithm (A[O..n-1]) ito while i<n - 2 do if A[i]A[i+1] > A[i+2) then return i it i+1 return -1 4. Calculate how many times the comparison A[i]A[i+1] > A[i+2] is done for a worst-case input of size n. Show your work. 5. Calculate how many times the comparison A[i]A[i+1] > A[i+2] is done for a best-case input of size n. Show your work.
Using the pseudocode answer these questions Algorithm 1 CS317FinalAlgorithm (A[O..n-1]) ito while i<n - 2 do if A[i]A[i+1] > A[i+2) then return i it i+1 return -1 6. Use limits to show that, for best case inputs, the asymptotic growth of the number of comparisons is (1). Show your work. 7. Use limits to show that, for worst case inputs, the asymptotic growth of the number of comparisons is O(n). Show your work.
urgent L. Consider the following pseudocode for finding binomial coefficients: Binom(n, r) Input: integers n and r Output: n choose r if r-0 or r-n thern return 1 end else return Binom(n-1, r-1) Binom(n-1, r); end running time of this algorithm. Prove your bound for the upper bound. (5 points) Rewrite the above algorithm so that it is efficient. (You have 2 choices!) Analyze the worst case time of your new algorithm. (5 points) Find the edit distance between "SPOKE...
Answer B java Problem 2 For each problem given below, do the following: 1. Create an algorithm in pseudocode to solve the problem. 2.Identify the factors that would influence the running time of your algorithm. For example, if your algorithm is to search an array the factor that influences the running time is the array size. Assign names (such as n) to each factor. 3. Determine the number of operations in each step of the pseudocode. To do that, identify...
Need to find number of elementary expressions in terms of n, not looking for Big O complexity. 4. Work out the number of elementary operations in the worst possible case and the best possible case for the following algorithm (justify your answer): 0: function Nonsense (positive integer n) 1: it1 2: k + 2 while i<n do for j+ 1 to n do if j%5 = 0 then menin else while k <n do constant number C of elementary operations...
Exercise 1 Use Top-Down Design to “design” a set of instructions to write an algorithm for “travel arrangement”. For example, at a high level of abstraction, the algorithm for “travel arrangement” is: book a hotel buy a plane ticket rent a car Using the principle of stepwise refinement, write more detailed pseudocode for each of these three steps at a lower level of abstraction. Exercise 2 Asymptotic Complexity (3 pts) Determine the Big-O notation for the following growth functions: 1....
Searching/sorting tasks and efficiency analysis - Big-oh For each problem given below, do the following: 1. Create an algorithm in pseudocode to solve the problem. 2. Identify the factors that would influence the running time of your algorithm. For example, if your algorithm is to search an array the factor that influences the running time is the array size. Assign names (such as n) to each factor. 3. Count the operations performed by the algorithm. Express the count as a...
1) a) Write MATLAB function that accepts a positive integer parameter n and returns a vector containing the values of the integral (A) for n= 1,2,3,..., n. The function must use the relation (B) and the value of y(1). Your function must preallocate the array that it returns. Use for loop when writing your code. b) Write MATLAB script that uses your function to calculate the values of the integral (A) using the recurrence relation (B), y(n) for n=1,2,... 19...