Implement the sequential search algorithm

Assignment Help Data Structure & Algorithms
Reference no: EM131503408

Data Structures Assignment: Searching Lists: Sequential, Binary, and Fibonacci Searches

In this assignment, you will implement three search algorithms: sequential, binary, and Fibonacci.

Please download the starter files for this assignment from the Files tab. For each algorithm, provide an explanation of its time complexity.  Do not alter the function definition or driver code in any way. Programs that crash are subject to a 50% penalty. PLEASE NOTE: You may not use any Standard Template Library (STL) classes for this assignment.

1. Implement the Sequential Search Algorithm

template<class T>

int sequential_search (T array[], int size, T value); 

The sequential search algorithm finds the location of an item in an array, sorted or unsorted. 

2. Implement the Recursive and Non-Recursive Binary Search Algorithms

template<class T>

int binary_searchR(T array[], int first, int last, T value);

template<class T>

int binary_searchNR(T array[], int first, int last, T value); 

The binary search algorithm finds the location of an item in a sorted array.  The binary search algorithm compares a search key to the middle element in a sorted array.

1. If the search key equals the middle element, return the index of the element.

2. If the search key is greater than the middle element, continue searching in the right half of the array.

3. If the search key is less than the middle element, continue searching in the left half of the array.

4. If the search key is not found (first > last), return -1.

3. Implement the Fibonacci Search Algorithm

template<class T>

int fibonacci_search (T array[], int size, T value);

Let k be defined as an element in F, the array of Fibonacci numbers. n = Fm is the array size. If the array size is not a Fibonacci number, let Fm be the smallest number in F that is greater than n.

The array of Fibonacci numbers is defined where Fk+2 = Fk+1 + Fk, when k ≥ 0, F1 = 1, and F0 = 0.

To test whether an item is in the list of ordered numbers, follow these steps:

1. Set k = m.

2. If k = 0, stop. There is no match; the item is not in the array.

3. Compare the item against element in Fk-1.

4. If the item matches, stop.

5. If the item is less than entry Fk-1, discard the elements from positions Fk-1 + 1 to n. Set k = k - 1 and return to step 2.

6. If the item is greater than entry Fk-1, discard the elements from positions 1 to Fk-1. Renumber the remaining elements from 1 to Fk-2, set k = k - 2, and return to step 2.

Attachment:- Assignment File.zip

Reference no: EM131503408

Questions Cloud

Review of a current debate in project management literature : Critical review of a current debate in project management literature - How the tools you selected might aid your understanding and experiences with managing projects.
Create a gantt chart for your project : Create a Gantt chart for your project. Take a screenshot of the Gantt chart which can later be inserted into your written paper.
Uses the proceeds to repurchase shares : Meyer & Co. expects its EBIT to be $91,000 every year forever. What will the value be if the company borrows $136,000 and uses the proceeds to repurchase shares
Calculate the value of the investment today : Calculate the value of the investment today. What will be its value if the payments occurred at the beginning of each year?
Implement the sequential search algorithm : CS 20A: C++ Data Structures Assignment: In this assignment, you will implement three search algorithms: sequential, binary, and Fibonacci
Hazardous materials incident on us roadways : Research a recent (within the last three years) hazardous materials incident on U.S. roadways involving trucking and describe what happened.
Develop a general overview of the company : Develop a general overview of the company and its external environment.Begin a list of the possible strategic factors facing the company at this time.
What is the smallest number of assets that his portfolio : What is the smallest number of assets that his portfolio should contain?
Event budget can be managed for a project : Explain some ways that an event budget can be managed for a project. Think about a small event with a small budget versus a large event with a large budget

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Compute result for receiver after error detection algorithm

If receiver A receives 101010010011100100011101 and another receiver, B, receives 101011111111100100011101 compute the result for each receiver after error detection algorithm is run?

  Define how to building a binary search tree

Three of these operations (all but add) must visit every node in the tree. One of these must use preorder traversal, one must use inorder traversal, and one must use postorder traversal.

  Analyze the worst-case runtime of the new merge sort

Analyze the worst-case runtime of the new merge sort and compare the complexity of the original merge sort with the complexity of the new merge sort.

  Input a list of employee names and salaries and determine

input a list of employee names and salaries and determine the meanaverage salary as well as the number of salaries

  Explaining augmented red-black tree

Consider T be augmented red-black tree, where each node x has attribute x.size, which is number of internal nodes in subtree rooted at x. Given such augmented red-black tree T.

  Describe sorting algorithms and how they work

Describe sorting algorithms and how they work

  A local company owns three 3d printers

A local company owns three 3D printers installed in its three different branches. Clients can call the company and reserve the use of one printer for some hours.

  Implement a hash structure for the contributor data

At this point, you decide to implement a Hash structure for the contributor data to prepare for searches. You will read the contributor information from a file provided; it is a comma delimited (CSV) file. As each record is read, create a Hash tab..

  Create an application to implement apriori algorithm

Create an application to implement Apriori Algorithm and demonstrate the two main phases in it, which are i) Generation of frequent itemsets; ii) Generation of association rules.

  Prepare the algorithm to solve the puzzle

Alternating disks you have a row of 2n disks of two colors, n dark and n light.

  Devise a linear-time algorithm to count the parallel edges

Devise a linear-time algorithm to count the parallel edges in a graph. Write the algorithm in pseudocode.

  Dependency diagram reflects a table that is in

dependency diagram reflects a table that is in

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