This preview shows page 1. Sign up to view the full content.
CS432, Algorithms
Names:
Some problems for Chap. 2 lectures
Answer the questions below before the end of class and turn it in. The results you give will not
count toward your grade in the class. The purpose of this test is for me to get a feel for how
well the class overall understands this material,
and
for
you
to see how well you understand
this material.
1) Set up the formula for calculating the average case complexity for Sequential Search
(AKA Linear Search) on an unsorted array.
Assume that the "target" element is
definitely in the array, but that there is a 50% chance it is in the first position (and
equally likely in all other positions).
Just set up the formula  you don't have to solve it.
For position 1, we do one comparison so T(I) = 1.
P(I) = 0.5.
For each position i
from 2 to n, we T(I) = i
and P(I) is 0.5/(n1).
A
(
n
)
=
1
"
0.5
+
(0.5
"
i
(
n
#
1))
i
=
2
n
$
2) Argue that one cannot find the minimum element in an unsorted array of size n without
doing at least n1 comparisons.
This is the end of the preview. Sign up
to
access the rest of the document.
This note was uploaded on 03/21/2010 for the course CS 4102 taught by Professor Horton during the Spring '10 term at UVA.
 Spring '10
 HORTON
 Algorithms

Click to edit the document details