Assignment 6 (DS)

# Assignment 6 (DS) - Because firstOutOf Order> info is...

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

CS 270 Assignment 6 # 61313 Chapter 9 4. Consider the list: 2,10,17,45,49,55,68,85,92,98,110 : How many comparisons are required to find whether the following items are in the list? Show values of first, last and mid and the number of comparisons after each iteration of the loop. a. 15 b. 49 c. 98 d. 99 ANSWERS: See excel attachment for breakout Chapter 10 14. Starting at firstOutOf Order = n, the for loop executes (1/2)(n^2-n) times.
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Because firstOutOf Order-> info is greater than first ->info, we search the list to find the place where firstOutOf Order is to be moved. You use the pointer trailCurrent and current to traverse the list. This repeats until numbers are in correct order leaving you with number of assignments (1/2) (n^2 + 3n)-2...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online