Design a binary search based algorithm

Assignment Help Data Structure & Algorithms
Reference no: EM132094104

Please answer all parts of the following in a detailed and easy to read manner.

Original array: 2, 3, 5, 8, 9, 10, 14, 18, 28, 30

Sorted, but rotated array: 8, 9, 10, 14, 18, 28, 30, 2, 3, 5

All the elements (except an element called the pivot at index p) of the sorted, but rotated array of integers have a property that they are less than the element fo the right of them.

Only the pivot element is greater than the element to the right of it.

In the above sorted, but rotated array of integers, the pivot is the integer 30 at index 66. Incidentally, the pivot also happens to be the largest element in the array and is the lasat element in the original sorted array (before the rotation).

In the above example, the pivot element 30 is the largest element of the array and is also the last element of the original sorted array (before the rotation).

a) Design a binary search based algorithm to identify the pivot in a sorted, but rotated array of integers

b) Extend the algorithm of (a) to do a successful search for a key that is present in the sorted, but rotated array.

c) Extend the algorithm of (a) to do an unsuccessful search for a key that is not present in the sorted, but rotated array.

d) For each of the algorithms in (a), (b), and (c), illustrate the execution of the algorithm for the array given in the problem statement.

e) Analyze the time complexity of the algorithms of (a), (b), and (c).

Note: In addition to describing the working of your algorithms, you should write the pseudo code for your algorithms of (a), (b), and (c)

Reference no: EM132094104

Questions Cloud

How would you represent this query as map : How would you represent this query as map() and reduce() functions in MapReduce where dog is the table?:
Watch the video and answer the following questions : Please watch the video and answer the following questions below.
What guidelines are needed when life safety is not concern : Life safety must be of paramount concern in almost all settings (except perhaps a few national security areas).
Efficiency of the production operation : Efficiency of the Production Operation Research the process of producing an expensive product (assume that it is something that must cost at least $1,000).
Design a binary search based algorithm : All the elements (except an element called the pivot at index p) of the sorted, but rotated array of integers have a property that they are less.
Write a two-paragraph submission about the lecture : Film critic Robert Horton's was on campus for a lecture a couple of years ago, and that lecture is available on YouTube.
What it takes to enter new markets : You are in a meeting to try to understand what it takes to enter new markets. What lessons can be learned from Walmart's experience in Mexico
Discuss how the definition of privacy that is commonly used : Discuss how the definition of privacy that is commonly used (freedom from observation) may differ from the definition of privacy.
Identify the problems on various carnival cruise lines : 1. Identify the problems on various Carnival Cruise Lines as included in the article. 2. What is the root cause of the problems?

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Perform the acyclic-topological sort algorithm

Perform the acyclic-topological sort algorithm on the directed graph having vertex set a-k and edges {(j; a);(j; g);(a; b);(a; e);(b; c);(c; k);(d; e);(e; c);(e; f);(e; i);(f; k); (g; d);(g; e);(g; h);(h; e);(h; i);(i; f);(i; k)} Show the state of th..

  Write and test a function for the vertex-deletion algorithm

Write and test a function for the vertex-deletion algorithm in Exercise.Delete a vertex containing a given data item and all edges incident to it.

  Writing algorithm which ?nds xbest

Provide an O(n) algorithm which ?nds xbest such that distbest:= ∑i=1 to n|xbest - xi| is as small as possible.

  Discuss trade-offs between dynamic and static data structure

CSC310 assignment- Discuss the trade-offs between dynamic and static data structures. What are advantages of and differences between ArrayList, LinkedList, and Vector? Provide examples of how to best implement each of these data structures.

  Define the type of graph known as a mesh of trees

Define the type of graph known as a mesh of trees. Explain how this graph is used in applications to very large system integration and parallel computing.

  Which algorithm should be most efficient

the test conditions are equal for both algorithms, which algorithm should be most efficient when N is arbitrarily large (i.e., you can select N to be as large as you want it to be)?

  What is the relationship of object model to data structure

What are the reasons for object orientation? What is the relationship of the object model to the data structure

  What step in the proof fails if messages can be duplicated

Show that the relationship in Lemma 6. 19 also holds if mes­ sages can get lost in the channel pq, but not if messages can be duplicated. What step in the proof fails if messages can be duplicated?

  Develop the flow diagram of the information

Develop the flow diagram of the information and any control elements needed to ensure proper access for the information. A diagram of the information flow and any elements controlling proper access to the information it uses

  Describe inference controls and crypto dilemma

For a public-key encryption system, list reasons - Describe inference controls - Describe the crypto dilemma - What piece of legislation allows computer

  Show the various splitting merging stages of binary merge

Use diagrams like those in the text to show the various splitting merging stages of binary merge sort for the following lists of numbers.

  Edge connectivity of undirected graph-running maximum-flow

Illustrate how edge connectivity of undirected graph G = (V, E) can be determined by running maximum-flow algorithm on at most |V| flow networks, each having O(V) vertices and O(E) edges.

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