Discrete Mathematics with Graph Theory (3rd Edition) 221

# Discrete Mathematics with Graph Theory (3rd Edition) 221 -...

This preview shows page 1. Sign up to view the full content.

Section 8.1 219 V153 ~ 12.3693 as shown. 12. 3 3 1 153. 0 0 0 0 12 144 243 9 0 0 7 2 9 2466 1 7 1 0 0 1 4 7 9 6 24729 2 3 0 4 0 0 2 2 2 5 6 1 247383 7 8 3 9 0 0 7 4 2 1 4 9 2473861 4 1 7 5 1 0 0 2 4 7 3 8 7 1 1 7 0 1 2 3 9 8. [BB] We find the sum of the numbers and divide by n. Thus, to find the average of n numbers Step 1: set S = 0; Step 2: for i = 1 to n, replace S by S + ai; Step 3: output *. 9. [BB] To find the maximum of n numbers alo a2, ... , an, Step 1: let M = al; Step 2: for i = 2 to n, if ai > M, replace M by ai; Step 3: output M. The value of M output in Step 3 is the maximum of the ai. 10. We establish a counter, T, which is initially set to 0 and is increased by 1 each time an occurrence of x is found in the list. To determine how many times the element
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: x appears in the list aI, a2, ... , an, Step 1: set T = 0; Step 2: for i = 1 to n, if ai = x, replace T by T + 1; Step 3: output T. The output value of T is the number of times x appears in the list. 11. To determine how many elements from among aI, a2, ... ,an lie in the range 85 ::; x ::; 90, Step 1: set t = 0; Step 2: for i = 1 to n, if ai ~ 85 and ai ::; 90, replace t by t + 1; Step 3: output t. The value of t output in Step 3 is the desired number. 12. [BB] If x::; aI, we wish to output x, aI, a2, ... ,an. If al < x ::; a2, we wish to output al, x, a2,·· . ,an, and so on. If x ~ an, we wish to output al, a2, ... ,an, x. Here is one suitable algorithm. To insert x into its correct position in the ordered list al ::; a2 ::; ... ::; an,...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern