What is the recurrence for the worst-case runtime

Assignment Help Data Structure & Algorithms
Reference no: EM132095289

Please explain how to find the recurrence of the following code. Why is the answer T(6n/7) + O(1) and how I can solve a similar question?

What is the recurrence for the worst-case runtime of the algorithm below?

The following algorithm takes as input a sorted array of integers A.

left and right represent the left and right indicies of the array that is being searched. The parameter x represents an integer.

The algorithm Search searches whether or not x is in the array A. If x is in the array, it returns the index of x. If x is not in the array, it returns -1. The function floor(a) returns the integer part of a. The initial call to Search is Search( A, 1, n, x ).

int Search(A,left,right,x) { numelements = right - left + 1;

if (numelements < 20) {

for (i = 0; i < numelements; i++){

if (A[left + i] == x) return (left + i);

}

return (-1);

} else {

split = floor(numelements * 1/7) + left;

if (A[split] == x) return(split);

if (A[split] > x) return(Search(A,left,split-1,x));

if (A[split] < x) return(Search(A,split,right,x)); } }

Reference no: EM132095289

Questions Cloud

Find the mean and standard deviation of a number of data : Write a program, using C#, that will find the mean and standard deviation of a number of data points.
Develop the code in a step-by-step manner : You may add other methods if needed, however, all the methods and the variables indicated in the UML diagram must be implemented.
Discuss about the penetration testing : In information security, penetration testing may be wrongly perceived as being a "hacker-like" activity.
Find the comments against each line for the description : Modify the program above program so that it contains a class related to the Leibniz formula. Add additional methods to the class .
What is the recurrence for the worst-case runtime : What is the recurrence for the worst-case runtime of the algorithm below?
Design the circuit using one rotate-right circuit : Design the circuit using one rotate-right circuit, one rotate-left circuit, and one 2-to-1 multiplexer to select the desired result. Derive the code.
Discuss ipv4 and ipv6 according to its capabilities : Discuss IPv4 and IPv6 according to its capabilities to address a single device on any network in the world and how it correlates to the Internet of Things.
Explain with risk management is it appropriate to know : What if you move forward with a risk you think is manageable but not mitigate it?
The difference between while loop and for loop in c language : Please explain the difference between while loop and for loop in C language with examples.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Create algorithm-smallest element-set of combined elements

Assume that X and Y are two sorted sequences, comprising m and n elements respectively. Create the algorithm to nd kth smallest element in set of m + n combined elements.

  Stack to check for balanced braces

In a program that uses a stack to check for balanced braces in an string, what condition indicates that the braces are balanced when the end of the string is reached

  Designing a visual c-sharp program

Design a Visual C-Sharp program for an Ice Cream Shop. The program will store information about ice cream cones and customers.

  Write a recursive version of the linked-list-based search

Write a recursive version of the linked-list-based linear search algorithm.

  Big-oh characterization

Give a Big-Oh characterization, in terms of n, of the running firm of the following algorithm. A is an array of integer values.

  Design a flowchart using visual logic

Fran's Virtual Fruit Stand is an online store that sells several types of dried fruit. Based on the needs of Fran's Virtual Fruit stand, you must design a flowchart using Visual Logic. Continually accept data regarding the purchase of fruit until a..

  Implement the priorityq class using a heap instead

Implement the PriorityQ class using a heap instead of an array

  Write program that determine each customers priority number

write a program that reads the file and determines each customer's priority number. The program then builds a priority queue using the priority number and prints a list of waiting customers in priority sequence.

  What is the running time of shortest-path algorithm

Pick any vertex S. Show that, if the graph is strongly connected, a shortest-path algorithm will declare that all nodes are reachable from S.

  Description a long time ago in a galaxy far far away the

description a long time ago in a galaxy far far away the country mafghanistan had n cities and m old roads where each

  Design an application that has an array of twenty integers

Design an application that has an array of at least 20 integers. It should call a module that uses the sequential search algorithm to locate one of the values.

  Create a program could perform over an array of items

Create a program could perform over an array of items that would be used by a small business. Your task must include the following: Declaring array, Populating the array and Processing the items in the array.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd