Computing Science Exam Worksheet With Answers - Simon Fraser University Page 8

ADVERTISEMENT

40) The Shell sort algorithm, which compares distant items first and works its way down to nearby
40)
items, is more efficient than the bubble sort algorithm.
Answer:
True
False
41) The bubble sort is usually faster than the Shell sort.
41)
Answer:
True
False
42) A binary search that begins in the middle of a list does not require the data to be in any order.
42)
Answer:
True
False
43) Although three assignment statements can be used to swap a pair of array elements, three
43)
assignment statements alone cannot swap all the items in one array with all of the items in another
array.
Answer:
True
False
SHORT ANSWER. Write the word or phrase that best completes each statement or answers the question.
44) Use the following array, age(), and assume the bubble sort is used to sort the array from
44)
smallest to largest: age(0)=16, age(1)=3, age(2)=21, age(3)=43,age(4)=2, age(5)=16,
age(6)=32.
(a) What is the contents of the array after one pass?
(b) What is the contents of the array after two passes?
(c) What is the contents of the array after three passes?
Answer: (a)3, 16, 21, 2, 16, 32, 43
(b)3, 16, 2, 16, 21, 32, 43
(c)3, 2, 16, 16, 21, 32, 43
45) Given an array of size 10 with the following ten values stored in order 1.8, 2.9, 4.7, 9.3,
45)
10.1, 13.6, 17.4, 19.2, 21.5, 23.3 you want to perform a binary search for the value 4.7. What
are the successive values of First, Last, and Middle as determined when performing this
search? (Fill in the table below until the search is completed.)
First
Middle
Last
0
9
Answer: First
Middle
Last
0
4
9
0
1
3
2
2
3
8

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education