Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1.) Write an algorithm that takes as input a list of integers and returns True i

ID: 3146080 • Letter: 1

Question

1.) Write an algorithm that takes as input a list of integers and returns True if there are more positive inters than negative integers in the list and returns False otherwise. (write steps only)

2.) Write an algorithm that takes as input a list of integers and returns the largest number obtained by subtracting an integer in the list from the integer that follows. (write steps only)

3.) Trace the steps used to search for 7 in a list 1, 2, 3, 5, 6, 7, 8, 9, 11 using • linear search

• binary search

Explanation / Answer

I will answer only the first question as per chegg policy, please post rest of the question separately.

Let the array in which the integers are stored is A.

Let A has n elements.

Step 1 : initiate 2 counters f_pos and f_neg as 0.

\f_pos is the counter for counting positive integers in the array, similarly f_neg is for counting negative numbers\

Step 2: start the loop from i = 1 to n

Step 3: within loop check

if A[i] > 0, then f_pos = f_pos + 1,

if A[i] < 0, then f_neg = f_neg + 1,

Step 4: i = i+1 {increase i by 1}

Step 5: once the loop is done, check

if (f_pos > f_neg) return (TRUE)

else return (FALSE)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote