Question: Write the following recursive method int count negative (int[] list, int n) that returns the number of negative integers in an integer array. 1. Base

 Write the following recursive method int count negative (int[] list, int

Write the following recursive method int count negative (int[] list, int n) that returns the number of negative integers in an integer array. 1. Base case n==0: return list[0]>0 ? 1:0 2. Recursive case n>0: return (list[n]>0 ? 1 : 0) + count negative (list, n-1) Use the following class to test the method public class HW2 { public static void main(String[] args) { // initial data set, add a few more members int[] data { -1, 2, -43, 14, -5}; // replace ??? with appropriate call System.out.println("Count = " + ??? ); } = public static int count negative (int[] list, int n) { int result; if (n==0) { // your code } else { // your code } return result; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!