Exam 3- 2012

Cs 115 exam 3 fall 2012 page 4 of 9 a fill out

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: middle – 1 else: first = middle + 1 return None You may want to label the elements of L with their numeric index values before proceeding. Answer the questions on the next page. CS 115 Exam 3, Fall 2012 Page 4 of 9 (a) Fill out the following table tracing a binary search for CA in this list. You should fill out one row per iteration of the loop. If there are more rows than iterations, leave the extra rows blank. Iteration Value of first Value of last Value of middle Value of L[middle] 1 2 3 4 5 (b) Fill out the following table tracing a binary search for NJ in this list. Iteration Value of Value of Value of middle Value of L[middle] first last 1 2 3 4 5 CS 115 Exam 3, Fall 2012 Page 5 of 9 Problem 3: 30 points. Define functions to perform the following tasks. Keep in mind the following: • Your functions should NOT ask the user for input. • Your functions should NOT print anything. • Your functions should NOT call sys.exit() to terminate the program. (a) Define a function called wordcount that… * has one input parameter: a string * returns the number of words in the string (b) Define a function called list_letters that… * has two input parameters: a list of strings, and a number N * returns the number of elements of the list that...
View Full Document

This note was uploaded on 02/08/2014 for the course CS 115 taught by Professor Staff during the Fall '08 term at Sonoma.

Ask a homework question - tutors are online