Question

Problem 2 For each problems segment given below, do the following: 1. Create an algorithm to solve the problem 2. Identify the factors that would influence the running time, and which can be known before the algorithm or code is executed. Assign names (such as n to each factor. 3. Identify the operations that must be counted. You need not count every statement separately. If a group of statements always executes together, treat the group as a single unit. If a method is called, and you do not know the running time of that method, count it as a single operation. 4. Count the operations performed by the algorithm or code. Express the count as a function of the factors you identified in Step 2 f the count cannot be expressed as a simple function of those factors, define the bounds that can be placed on the count: the best case (lower bound) and worst case (upper bound). 5. Determine what the Best Case Inputs are, and the Worst Case Inputs are, and the efficiency of your implementation 6. Transform your count formula into big-O notation by: o Taking the efficiency with worst case input, o Dropping insignificant terms. o Dropping constant coefficients. a. Determine if 2 arrays contain the none of the same elements elements (assume all elements are distinct) b. Counting total number characters that have a duplicate within a string (i.e. gigi the gato would result in 7 (g x3+ ix2+tx2) c. Finding a row where every entry is a in a 2-D array.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

6on. 1. Flag-trete 10- return fal the in lheCount- zadu nt fol t-ton y, two anays with@p.でnht or. Ekonard.肖he Bot timeAlgäthm coun Duplkcalex shl counl-oCourding opeuaione Mtl ap_crurt-o qualy oi to n- Yu m- m-3 ton Countin กา+1 lag-fel fei-ton ntt mtn a (a tals etuan true

Add a comment
Know the answer?
Add Answer to:
For each problems segment given below, do the following: Create an algorithm to solve the problem...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Answer B java Problem 2 For each problem given below, do the following: 1. Create an...

    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...

  • Searching/sorting tasks and efficiency analysis - Big-oh For each problem given below, do the following: 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...

  • S19-A6.pdf 2/5 Rutgers University CS111 - Inlroduction to Computer Science Spring 2019 Problem 5 Big-oh For...

    S19-A6.pdf 2/5 Rutgers University CS111 - Inlroduction to Computer Science Spring 2019 Problem 5 Big-oh For cach problen given below, do lhe following 1. Creste a algrithm in psudood to solve the proble 2. Identify the factors that would influence the running time of your algorithm. For exarple, if your alorithm ia to search an array th fator that influeuxs the runnin time is the array size. Assign names (such as n) to each factor. 3. Count the operations performed...

  • 1. Suppose you are given 3 algorithms A1, A2 and A3 solving the same problem. You...

    1. Suppose you are given 3 algorithms A1, A2 and A3 solving the same problem. You know that in the worst case the running times are Ti(n) = 101#nº + n, Ta(n) = 10”, TS(n) = 101 nº logo n10 (a) Which algorithm is the fastest for very large inputs? Which algorithm is the slowest for very large inputs? (Justify your answer.) (b) For which problem sizes is Al the best algorithm to use (out of the three)? Answer the...

  • problem 2 can use Det-Selection(A, p, q, r) as a sub-routine (i.e, you don't need to...

    problem 2 can use Det-Selection(A, p, q, r) as a sub-routine (i.e, you don't need to write its pseudo-code). To sort an array A, you will then call Det-QuickSort(A, 1, n). You also need to provide the worst case time complexity analysis of your algorithm. 2. (20 points) Given a set of n distinct numbers, we wish to find the k largest in sorted order using a comparison-based algorithm. Give an algorithm that implements each of the following methods, and...

  • Exercise 1 Use Top-Down Design to “design” a set of instructions to write an algorithm for...

    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....

  • 1. Please write a Divide-and-Conquer Java algorithm solving the following problem: Given an "almost sorted" array...

    1. Please write a Divide-and-Conquer Java algorithm solving the following problem: Given an "almost sorted" array of distinct integers, and an integer x, return the index of x in the array. If the element x is not present in the array, return -1. "Almost sorted" means the following. Assume you had a sorted array A[0…N], and then split it into two pieces A[0…M] and A[M+1…N], and move the second piece upfront to get the following: A[M+1]…A[N]A[0]…A[M]. Thus, the "almost sorted"...

  • [Recursive Cost] [ALGORITHM] Improving Efficiency PLEASE explain in DETAIL the following question in detail. The algorithm...

    [Recursive Cost] [ALGORITHM] Improving Efficiency PLEASE explain in DETAIL the following question in detail. The algorithm is also given below. Thank You! 1.a) Define recursively the worst case cost Kn of the Knapsack function for n items. Remember that you need to provide both the base case and the recurrence relation. Also do not forget to include the cost of the function Worth in your cost. Justify your answer (i.e. explain what each component of the formula represents). [5points] 1.b)  Use...

  • This is an assignment for my algorithm class which I have written the code partially and...

    This is an assignment for my algorithm class which I have written the code partially and only need to complete it by adding a time function that calculates the average running time. We could use any programming language we want so I am using C++. I am including the instruction and my partial code below. Thank you! Implement linearSearch(a,key) and binarySearch( a,key)functions. Part A.In this part we will calculate theaverage-case running time of each function.1.Request the user to enter a...

  • JAVA 3 PLEASE ANSWER AS MANY QUESTIONS AS POSSIBLE! ONLY 2 QUESTIONS LEFT THIS MONTH!!! Question...

    JAVA 3 PLEASE ANSWER AS MANY QUESTIONS AS POSSIBLE! ONLY 2 QUESTIONS LEFT THIS MONTH!!! Question 12 pts Which is a valid constructor for Thread? Thread ( Runnable r, int priority ); Thread ( Runnable r, String name ); Thread ( int priority ); Thread ( Runnable r, ThreadGroup g ); Flag this Question Question 22 pts What method in the Thread class is responsible for pausing a thread for a specific amount of milliseconds? pause(). sleep(). hang(). kill(). Flag...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT