Will give thumbs up for correct answers to the questions. Also really appreciate
ID: 3902008 • Letter: W
Question
Will give thumbs up for correct answers to the questions. Also really appreciate if brief explanation is also provided as well,Thank you
(All questions are about Java)
5. (4 marks) Write a complete Java method with header shown below. Use a linear search algorithm to count and return the number occurrences of String findMe in the array. Return -1 if findMe is not found in the array. public static void countoccurences (Stringt1 words, Stzing findMe) t 5. Consider the following array of integers: 710 9 3 S 1 2 4 6 8 (4 marks) Show what the array would look like after the second pass of the bubble sort algorithm. Assume the algorithm will sort in ascending order. a. b. 4 marks) Show what the array would look like after the second pass of the selection sort algorithm. Assume the algorithm will sort in ascending order 6. 4 marks) Given the following binary search method public static int binarySearch (intl array, int x int low-0 int high -array.length-1a while (low
Explanation / Answer
If you have any doubts, please give me comment...
5)
public static int countOccurences(String[] words, String findMe){
int count = 0;
for(int i=0; i<words.length; i++){
if(words[i].equals(findMe)){
count++;
}
}
return count==0?-1:count;
}
5)
a) 1 2 9 3 5 7 10 4 6 8
b) 1 2 9 3 5 7 10 4 6 8
6)
mid: 5
mid: 2
mid: 3
Value not found.
Related 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.