tutorbin

design and analysis of algorithms homework help

Boost your journey with 24/7 access to skilled experts, offering unmatched design and analysis of algorithms homework help

tutorbin

Trusted by 1.1 M+ Happy Students

Recently Asked design and analysis of algorithms Questions

Expert help when you need it
  • Q1:# Project 3: Griefer list ## Introduction Your job working at the MMORPG is going great. After a recent promotion, you've been assigned a more challenging task. The game has become popular enough to attract large numbers of griefers, which use trial accounts to troll and harass your paying customers. Given that the rules are different on different servers, each server maintains its own ban list. To help server admins out, you want to build a tool that lets them quickly lookup whether a player has been banned and when the most recent ban was. You already have a tool that concatenates all the banlists together and consists of lines with the following format: [USERNAME] [SERVERID] [UNIX_TIME_OF_BAN] Example line: bmrlpmyzybrb 819 1636184756 (the trolls seem to like to use randomly generated names) Your tool will read a single input file consisting of a number of lines like the one above, and will insert the players into a self-balancing tree data structure, organized by user name. Along with the above data (which is stored in a file), your tool will also read a list of names from standard input. For each name, it will print a prepared statement (see sample) that contains the name, the number of servers they've been banned on, and the most recent ban they received. You know that a tree is appropriate for this task as there might be duplicate data, and you want to be able to find spans of names in sorted order later. However, you aren't sure which tree to use. You know that given the large number of inserts into the data structure that a scapegoat tree would be appropriate. However, you want to compare it with at least one of these trees: * AVL tree * Red black tree * B-treeSee Answer
  • Q2:3. Consider the following recursive algorithm, where array is an array of integers. You can assume that the length of array is a power of two, so len(array) is n = 2m for some m ≥ 0. (a) (1 marks) How many array accesses are made in total by calling squoogle (array)? An array access means that you evaulate array[i] for some i. Write your answer as a recursive formula in terms of m. You can treat the arguments to the recursive calls as if they do not require array accesses to compute. (b) (2 marks) Give a closed-form expression for your formula from part a) in terms of m. Prove your answer is correct using induction. (c) (0.5 marks) What is your closed-form expression from part b) in terms of n, the number of elements in the array?See Answer
  • Q3:3. Recall that as we discussed in class, there is no known fast algorithm for graph isomorphism, and it is believed that no such algorithm exists. However, it is often possible to solve graph isomorphism quickly if there are restrictions on the types of graphs allowed as input. Your best friend Fred has a proposal for an alternative graph isomorphism algorithm when the input graphs are restricted to be trees. He suggests the following: 1) For each vertex v in G₁, compute deg(v) and append this value to a list L₁. 2) For each vertex v in G₂, compute deg(v) and append this value to a list L2. 3) Sort the lists L₁ and L2 in increasing order. 4) If L₁ and L₂ are the same, reutrn "yes", otherwise return "no”. Does Fred's algorithm work on all possible inputs? You can assume the input graphs are both trees. Prove your answer is correct.See Answer
  • Q4:4. Give the binary representation for the following tree, showing your intermediate work. Answers consisting of only a binary string will not be marked.See Answer
  • Q5: Prove, by induction on k, that level k of a binary tree has less than or equal to 2* nodes (root level has k=0).See Answer
  • Q6:5a) Demonstrate the execution, show the output, and explain what the program accomplishes. 5b) Give a recurrence equation describing the worst-case behavior of the program. 5c) Solve the recurrence equation.See Answer
  • Q7:Let A[1 .. n] be an array of n distinct numbers. If i<j and A[i]>A[j], then the pair (i, j) is called an inversion of A. 6a) List the five inversions of the array <2, 3, 8, 6, 1>. 6b) What array with elements from the set {1, 2,..., n} has the most inversions? How many does it have? 6c) What is the relationship between the running time of insertion sort and the number of inversions in the input array? Justify your answer. 6d) Give an algorithm that determines the number of inversions in any permutation on n elements in O(n lg n) worst-case time. (Hint: Modify merge sort.)See Answer
  • Q8:Give big-O bounds for T(n) in each of the following recurrences. (Substitution or Recursion Tree) 7a) T(n) = T(n-1) + n 7 b) T(n)= T(n/4) + T(n/2) + n^2See Answer
  • Q9:Problem 1 Recurrence Define T(n) for n € Z+ by the recurr T(n) = recurrence for n = 1 {7 (41) +1 T (1) + 1 for n ≥ 2 log(n) for all n ≥ 1, and hence, T(n) = N(log(n)). Prove that T(n) (1)See Answer
  • Q10:Problem 2 Substitution method Use the substitution method to show that the solution to - {³s (121) +1 s(n) = if n = 1,2 98 () +1 if n ≥ 3 satisfies S(n) = O(n²). (2)See Answer
  • Q11:Problem 3 Define T(n) by the recurrence (21 T(n) = if 1 ≤ n < 15 [T([7])+6 if n ≥ 15 Use the iteration method to find the exact solution to this recurrence, and then determine an asymptotic solution.See Answer
  • Q12:Problem 4 Iteration method Consider the following recurrence relation: T(n) = 8T T (177) + ₂ 3 Apply the Master Theorem to find the tight asymptotic bounds for T(n).See Answer
  • Q13:Problem 5 Recursive algorithm Design a recursive algorithm called exterma(A, p, r) that finds and returns the ordered pair (min(A[p..r]), max(A[p..r])). Your algorithm should perform exactly []-2 array comparisons on an input array of length n. Problem 5 [Recursive algorithm] continued on next page... Algorithms CS 460: Assignment 2 Page 2 of 3 Problem 5 1) Write your algorithm in pseudocode. 2) Prove the correctness of your algorithm by induction on m=r-p+1, the length of the subarray A[p..r]. 3) Write a recurrence for the number of comparisons performed on A[1,..n] and show that T(n) = [1-2 is the solution.See Answer
  • Q14:1. [15pts] Suppose you are given N numbers to sort. The N numbers are not known to be in a bounded range. You do, however, know that many of the N numbers are duplicates. Furthermore, the number of distinct values is "small". "Small" is defined by the property that M² « N where M is the number of distinct values. Give an algorithm that has expected time O(N) to sort the items under the given constraints. Your algorithm must use O(N+ M) space. Hint: What techniques do you know that make good use of expected-time behavior?See Answer
  • Q15:2. [5pts] Give a trace for the LSB sort applied to the following strings: no is th ti fo al go pe to co to th ai of th paSee Answer
  • Q16:1. Compute the following sums. a. 1+3+5+7+ +999 b. 2+4+8+16+...+1024 c Σ+1 d. Σ"}; 1. Σ–13+1g. Σ Σ - e Σ"di( + 1) Ξ 2. Find the order of growth of the following sums. Use the Θ(g(n)) notation with the simplest function g(n) possible. a. Σ"=(2+1)2 € Σ=1 + 1)2-1 b. Σ={1gi2 d. Σ. Σ( + 3)/n4. Consider the following algorithm. ALGORITHM Mystery (n) //Input: A nonnegative integer n S←0 for i ← 1 to n do S+S+i*i return S a. What does this algorithm compute? b. What is its basic operation? c. How many times is the basic operation executed? d. What is the efficiency class of this algorithm? e. Suggest an improvement, or a better algorithm altogether, and indicate its efficiency class. If you cannot do it, try to prove that, in fact, it cannot be done.See Answer
  • Q17:5. Consider the following algorithm. ALGORITHM Secret(A[0..n-1]) //Input: An array A[0..n-1] of n real numbers minval A[0]; maxval ← A[0] for i 1 to n - 1 do if A[i] < minval minval ← A[i] if A[i]> maxval maxval ← A[i] return maxval - minval Answer questions (a)-(e) of Problem 4 about this algorithm./n4. Consider the following algorithm. ALGORITHM Mystery (n) //Input: A nonnegative integer n S 0 for i ← 1 to n do S+S+i*i return S a. What does this algorithm compute? b. What is its basic operation? c. How many times is the basic operation executed? d. What is the efficiency class of this algorithm? e. Suggest an improvement, or a better algorithm altogether, and indicate its efficiency class. If you cannot do it, try to prove that, in fact, it cannot be done.See Answer
  • Q18:1. Solve the following recurrence relations. a. x(n) = x(n-1) + 5 for n>1, x(1)=0/nb. x(n) = 3x(n-1) for n> 1, x(1) = 4/nd. x(n)= x(n/2) +n for n>1, x(1) = 1 (solve for n = 2k)See Answer
  • Q19:4. Consider the following recursive algorithm. ALGORITHM Q(n) //Input: A positive integer if n = 1 return 1 else return Q(n-1) + 2 *n-1/nb. Set up a recurrence relation for the number of multiplications made by this algorithm and solve it. c. Set up a recurrence relation for the number of additions/subtractions made by this algorithm and solve it./n9. Consider the following recursive algorithm. ALGORITHM Riddle(A[0..n-1]) //Input: An array A[0..n-1] of real numbers if n = 1 return A[0] else temp← Riddle(A[0..n -2]) if temp ≤ A[n 1] return temp else return A[n - 1] a. What does this algorithm compute? b. Set up a recurrence relation for the algorithm's basic operation count and solve it.See Answer
  • Q20:8. Sort the list E, X, A, M, P, L, E in alphabetical order by selection sort./n11. Sort the list E, X, A, M, P, L, E in alphabetical order by bubble sort.See Answer

TutorBin Testimonials

I found TutorBin Design And Analysis Of Algorithms homework help when I was struggling with complex concepts. Experts provided step-wise explanations and examples to help me understand concepts clearly.

Rick Jordon

5

TutorBin experts resolve your doubts without making you wait for long. Their experts are responsive & available 24/7 whenever you need Design And Analysis Of Algorithms subject guidance.

Andrea Jacobs

5

I trust TutorBin for assisting me in completing Design And Analysis Of Algorithms assignments with quality and 100% accuracy. Experts are polite, listen to my problems, and have extensive experience in their domain.

Lilian King

5

I got my Design And Analysis Of Algorithms homework done on time. My assignment is proofread and edited by professionals. Got zero plagiarism as experts developed my assignment from scratch. Feel relieved and super excited.

Joey Dip

5

TutorBin helping students around the globe

TutorBin believes that distance should never be a barrier to learning. Over 500000+ orders and 100000+ happy customers explain TutorBin has become the name that keeps learning fun in the UK, USA, Canada, Australia, Singapore, and UAE.