Write recursive Dr Racket functions to do the following. The functions should wo
ID: 3822616 • Letter: W
Question
Write recursive Dr Racket functions to do the following. The functions should work on all types of lists( not just simple lists of atoms). Document (via direct Dr Racket screens/outputs) both your code and the results of running the test cases.
a) Count how many times an item (atom) appears on a list.
Minimum test cases:
(count 3 '(1 5 6 7 8 3 2 3 )) returns 2
(count dog '(cat bird cat dog frog)) returns 1
(count a '(a(a b ) (c (b c)) ((a))b)) returns 3
(count 3 '(1)) returns 0
(count none '()) returns 0
Explanation / Answer
public static int binSearch(int[] a, int key) { return binSearch0(a, key, 0, a.length - 1); } public static int binSearch0(int[] a, int key, int from, int to) { public static int binSearch(int[] a, int key) { return binSearch0(a, key, 0, a.length - 1); } public static int binSearch0(int[] a, int key, int from, int to) { if (from > to) return -1; int mid = from + (to - from) / 2; if (keyRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.