If you post ore than 1 question, then as HOMEWORKLIB RULES guidelines I just have to answer one question.
1.
function Fibonnaci(n):
{
// first term of series
if n == 0
return 1
if n == 1
return 2
a = 1
b = 2
for i <- 2 to n
{
c = a + b
a = b
b = c
}
return b
}
The above function computes n th fibonnaci number in
O(n) Time Complexity
and O(1) Space Complexity
It is so because the above function checks the two conditions for n == 0 and n == 1 in O(1) time.
The for loop runs for n - 2 times.
Hence, Time Complexity = O(1) + O(1) + O(n - 2)
= O(n - 2) (as O(1) is negligible)
= O(n) (as (n - 2) = n if n is very large)
1. (10 points) Write an efficient iterative (i.e., loop-based) function Fibonnaci(n) that returns the nth Fibonnaci...
Subject: Algorithm
solve only part 4 and 5 please.
need urgent.
1 Part I Mathematical Tools and Definitions- 20 points, 4 points each 1. Compare f(n) 4n log n + n and g(n)-n-n. Is f E Ω(g),fe 0(g), or f E (9)? Prove your answer. 2. Draw the first 3 levels of a recursion tree for the recurrence T(n) 4T(+ n. How many levels does it have? Find a summation for the running time. (Extra Credit: Solve it) 3. Use...
1. Order following function by growth rate: N, √N, N1.5, N log (N), log (log (N)), log (N) log (N), N2, 2N, 200, NN 2. Give a useful Θ (big Theta) estimation for each of following function t(n). a. t(n) = 122 * 212 b. t(n) = 2log2(n2) + log4(n ) + (log2 n) 2 + (log2 (202)) 2 c. t(n) = 3t(n/2) + n d. t(n) = 3t(n/2) + (n+1)(n-1) e. t(n) = 4t(n/2) + (n2 + n-1) f....
3- What is the growth of the below function: (What is the most accurate answer?) ?(?) = 2^(????^3) + ?√? + 7???^6 ? + ?^2???? options: a) Θ(n) b) Θ (n3) c) Θ (n2logn) d) Θ (n√?) e) Θ (log6n) What is the growth of the below function: (What is the most accurate answer?) ?(?) = ??????? + 4???^2? + ????^2 options: a) O (logn) b) O (loglogn) c) O (log2n) d) O(logn2) e) Neither 5- Assume you want to...
Consider the function FINDDUPLICATES(A[0. 1) that returns a list of all duplicate items in the unsorted integer array A of size n. For example, given the array |3, 2, 4, 3], the function should return the value 3. For the array 11 2,3 5,5,5,66,81, the function should return an array (or list) 5,6 In this task, you will develop two alternative solutions for the FINDDUPLICATES(Ao..n 1 func- tion. In your implementations, you may call any of the algorithms introduced in...
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....
6. Consider the following basic problem. You're given an array A consisting of n integers A[1], A[2], , Aln]. You'd like to output a two-dimensional n-by-n array B in which B[i, j] (for i <j) contains the sum of array entries Ali] through Aj]-that is, the sum A[i] Ai 1]+ .. +Alj]. (The value of array entry B[i. Λ is left unspecified whenever i >j, so it doesn't matter what is output for these values.) Here's a simple algorithm to...
Need help with 1,2,3 thank you.
1. Order of growth (20 points) Order the following functions according to their order of growth from the lowest to the highest. If you think that two functions are of the same order (Le f(n) E Θ(g(n))), put then in the same group. log(n!), n., log log n, logn, n log(n), n2 V, (1)!, 2", n!, 3", 21 2. Asymptotic Notation (20 points) For each pair of functions in the table below, deternme whether...
Question 13 pts (TCO 4) Which of the following functions grows at a slower rate than the rest? n2 n log n n3 Flag this Question Question 23 pts (TCO 4) Algorithms can be described using pseudo-code. assignment and arithmetic operations. loops and decision statements. All of the above Flag this Question Question 33 pts (TCO 4) The running time of an algorithm is the time, in milliseconds, it takes to complete its execution. the running time of its implementation....
Question2 0/5 pts If exact running time of an algorithm is T(n)-5n3+ n2 + 3n -5 where n is the input size, then which of the following is true? T(n)- O(n) RCOECEQuestion 3 0/5 pts Which of the following is the correct ranking of the functions listed below: logn. n2 n2n, 2. 1500. nlogn, 5 Question 4 5/5 pts to search
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...