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

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

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