1) The element being searched for is not in an array of 100 elements.
What is the average number of comparisons needed in a sequential search
to determine that the element is not there.
a) the elements are completely unordered.
b) the elements are ordered from smallest to largest.
c) the elements are ordered from largest to smallest.
2) The element being searched for is not in an array of 100 elements.
What is the average number of comparisons needed in a sequential search
to determine the position of the if the elements are completely unordered.
以下是变化题
3) The element being searched for is not in an array of 100 elements.
What is the maximun number of comparisons needed in a sequential search
to determine that the element is not there.
a) the elements are completely unordered.
b) the elements are ordered from smallest to largest.
c) the elements are ordered from largest to smallest.
4) The element being searched for is in an array of 100 elements.
What is the average number of comparisons needed in a sequential search to
determine that the position of the element?
a) the elements are completely unordered.
b) the elements are ordered from smallest to largest.
c) the elements are ordered from largest to smallest.
我在想有没有在array中的差别应该是能不能指定要看在特定位置上的元素,
所以在4)array中有排序的话应该可以用binary search之类的搜寻方法,
1)的a 因为没有排序只能一个个全部找过一遍,所以是100,
1)的b c 因为有依大小排,可以隔一格取,看两边边界就可以知道包含的范围,所以我想
可以只找一半的elements,所以是50
2) 的部分就有点不确定了,我看到的答案上是写 75,不过不知道是用什么方法
3)的部分 a)一定是100 b跟c我想不太到 maximum 跟 average 的差别,
应该都是要找50次吧