Circle a languages; C++ or Java Write the function/method findKey(), with three
ID: 3637986 • Letter: C
Question
Circle a languages; C++ or Java Write the function/method findKey(), with three arguments: data[] an array of integers (input) key an integer; the number to search for (input) size an integer; number of elements in data[] (input) k[] an array of integers (output) k[] starts out with zero elements. (For Java programmers, you can assume that data[] and k[ ] have been allocated more apace than you need, i.e., data.length and k.length are very large.) findKeys() searches for elements of data[] that match the integer key, copies the index of each matching element in data[ ] to k[], in order, and returns the number of matching elements. For example, if data[] - {1, 2, 2, -2, 2), key = 2, and size = 5, when findZeros() returns, k[ ] will contain {1. 2, 4}, and a 3 will be returned. write the code for findKeys(). Show the prototype for findKeys( ) clearly. You don't have to write again program.Explanation / Answer
In Java, assuming k is a global variable. public int findKeys(int[] data, int key, int size) { int index = 0; int matchCount = 0; while (indexRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.