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

1)Describe using pseudocode an algorithm that takes a list of n integers a1,a2,…

ID: 3196383 • Letter: 1

Question

1)Describe using pseudocode an algorithm that takes a list of n integers a1,a2,…,an and finds the sum of all positive integers in the list

2)The bubble sort algorithm discussed in class is used to sort the following sequence of integers 74 21 57 86 51 85

* how many passes will the algorithm perform to garantee the entire sequence is sorted?

* what is the listed optained after the first pass?

* what is the listed optained after the third pass?

* what is the listed optained after the final pass?

3) show how the binaty search algorithm discussed in class searches for 12 in the sorted list below;

1 8 21 25 31 36 39 40 49 69 92 99

Please help.

Explanation / Answer

As per Chegg rules, you can get answers to just 1 question in one post. Please post the other questions in a separate post.Please upvote the answer.

1) Describe using pseudocode an algorithm that takes a list of n integers a1,a2,…,an and finds the sum of all positive integers in the list.

The method is to traverse along the list and check if the integer is positive, then add it to a temporary variable, else drop it.

sum_p = 0 \initiate a temp variable which will store the sum upto the traverse point

i = 1 \initiate the variable to traverse the list

while (i <= n)

{

if list[i] > 0, then sum_p = sum_p + list [i]

i = i + 1

}

print (sum_p)