Chap03 Problems
Chap03 Problems
Class: 22CLC01/22CLC07
CHAPTER 3 – PROBLEMS
Problem 1. Given an array A as follow:
𝐴 =< −9, −9, −5, −2, 0, 3, 7, 7, 10, 15 >
a. Calculate the number of comparison operations to find 𝑥 = −9 using two
algorithms: sequential search and binary search (only count the comparison
between the search key and array’s elements). Give your comments about the
results.
b. In case of using binary search, which value is returned (0 or 1)?
Problem 4. Cutting sticks. A stick n meters long needs to be cut into n 1-m pieces.
Outline an algorithm that performs this task with the minimum number of cuts if several
pieces of the stick can be cut at the same time. Also give a formula for the minimum
number of cuts.
Problem 5. The time efficiency of sequential search does not depend on whether a list
is implemented as an array or as a linked list. Is it also true for searching a sorted list by
binary search?