1. (3 points) – Write a page paper – Describe using pseudocode as described in class an algorithm that takes a list of n integers a1, a2, …, an, and finds the average of all negative integers in the list. Be sure to initialize the variables.

2. (4 points) – The bubble sort algorithm discussed in class is used to sort the following sequence of integers: 3 22 14 21 70 79

• How many passes must the algorithm perform to guarantee the entire sequence is sorted?
• What is the list obtained after the first pass?
• What is the list obtained after the third pass?
• What is the list obtained after the final pass?

3. (3 points) – Show how the binary search algorithm discussed in class searches for 48 in the sorted list below: 8 25 31 32 39 45 54 63 67 71 88 94

Published by
Ace Tutors
View all posts