Find method searches the haystack array

Assignment Help Data Structure & Algorithms
Reference no: EM13698092

Program: Write a class, ArraySearch<E> that has two methods:

1. static int find (E [] haystack, E needle);

2. static int first_duplicate (E [] data);

The find method searches the haystack array to see if the elements within are the same, which is determined by the equals method, as the needle.

If the search finds a match, find returns the index that belongs to the first match. If not, find throws the exception java.util.MissingResourceException.

The method first_duplicate searches the data array to see if any two different elements of the array are the same evaluated by the equals method. The return value is the index of the first duplicate found, or -1 if each of the elements of the array is unique,

**no element of the array is equal to any other element of the array**

There should be code to test this ArraySearch class and be sure to include comments. The comment should describe the purpose of the program and the data to be entered.

Reference no: EM13698092

Questions Cloud

Describe the two-wire and four-wire circuits : What is a circuit?  Describe the two-wire and four-wire circuits.  What device boosts a weak signal (analog/digital) and What is a channel?
Matlab program to add all the elements of a matrix : Create a new vector, named vector2, containing only the elements in the even numbered positions from vector1. For example, if vector1 is [0 1 2 3 4 5 6], vector2 should be [1 3 5].
Create a function that subtracts two vectors : Create a function in C++ that subtracts two vectors - prepare a program to subtract two vectors and provide all the code.
Write a code that finds the average of all the elements : An array of double-precision (64-bit) floating-point numbers is located in the memory starting at address 1000. It contains 40 elements.
Find method searches the haystack array : Write a class, ArraySearch that has two methods - The find method searches the haystack array to see if the elements within are the same, which is determined by the equals method, as the needle.
Define predicate combinations : Define predicate combinations which find the number of combinations K of up to N numbers. Validate your predicate with the subsequent test:
Write the predicate logic : Write the predicate singleChild(Name) which finds the name of single children - For this problem single children means no other child has the same father and mother.
Why is rarp used in one case versus arp : Why is RARP used in one case versus ARP? This one is complex and I don't know how to do it
Create a console-based application named multiplication : Create a console-based application named Multiplication whose main() method asks the user to input and then calls a method named MultiplicationTable(), which displays the results of multiplying the integers by each of the number 2 through 10

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Data structures assignment requiring c++ program

You should build enough new roads such that if City A was reachable from City B via some old roads, City A must be reachable from City B via some new roads.

  Write down a 3-4 page apa formatted paper describing

write 3-4 page apa formatted paper discussing whether in the next few years rdbms will be replaced completely partially

  How the regular tree walk algorithm works

We know how the regular tree walk algorithm works. If you have some values in the tree then the tree walk algorithm prints everything in order

  Finding approximation algorithm and ratio of the algorithm

finding approximation algorithm and the ratio of the algoirthm.

  Write a method that uses the bst to output

Write a method that uses the BST to output to the screen the list of entries in alphabetical order. Each entry is displayed on a new line.

  Using quicksort with median-of-three

Show the steps in details of sorting {3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5} using quicksort with median-of-three partitioning and a cutoff 3 (if the elements are less than 3, using insertion sort).

  Design a divide-and-conquer algorithm

Design a divide-and-conquer algorithm for the Motif Finding problem and estimate its running time. Have you improved the running time of the exhaustive search algorithm?

  Determine the branching factor

Expalin the search algorithm that results from each of the following special cases. How does it relate to other algorithms we have discussed.

  Returns true if a string contains properly nested

Give an algorithm that returns true if a string contains properly nested and balanced parentheses, and false if otherwise. Hint: At no time while scanning a legal string from left to right will you have encountered more right parentheses than left..

  Write a program that implements the linked list

Write a program that implements the linked list Include the Node struct, the typedef NodePtr statement, and the head_insert() function Then write a main() that does these steps: creates a head for the list.

  Uml graphical notation to define the object classes

Use UML graphical notation, construct the design for the system to define the object classes and show the interaction of the data collection sub systems.

  Creating a random file of the signs

Create a random file of the signs of all angles from zero degrees to ninety degrees. Make every entry accurate to three places. Write a program that will show the sign of any angle typed on the keyboard.

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