6. (13 pts) Let X
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
6. (13 pts) Let X
6. (13 pts) Let X<X2 < ... <X, be an array of integers in increasing order. We need to determine if any X; = i, finding such a value of i if one exists. (Return any i if one or more exists, otherwise return 0) (a) (2 pts) What is the answer for the following input instance? X X2 X3 X4 X5 X X -4 -1 1 3 4 5 12 (b) (2 pts) What is the answer for the following input instance? X1 X2 X3 X4 X5 X6 -4 -2 0 3 5 7 (c) (7 pts) Give the best (with the lowest worst-case complexity) algorithm that you can think of for this problem. Justify the correctness.