回分類題庫
d164: OOP Lab Exercise: Binary Search Recursive Version
出處:

Difficulity : 4
Accepted : 71 Times | Submit :114 Times | Clicks : 1858
Accepted : 63 Users | Submit : 63 Users | Accepted rate : 100%
Time Limit :10000 ms | Memory Limit : 64000 KBytes
題目加入時間 : 2010-03-30 02:25

Content :

You are asked to write a binary search program but modifying the following code. Do not use google to look for the solution. In order to pass this exercise you have to:

1.  Implement in C++.

2.  Implement the blank function of binary search in recursive function using binary search algorithm.

3.  Include std_lib_facilities.h

4.  Submit with your OOP Lab account.

Download here: http://www.cs.nccu.edu.tw/~g9803/oop/bi_search_rec.cpp

Notice that you can feel free to use the code above. This code has already finished handling input and output issues which you can concentrate on your recursive function.

 

Input :

Input start with several numbers as the list for searching. Ended with -999999.
(-999999 does not belongs to the list.)
Notice that this list is not sorted.

The following integer are the numbers we wish to search. Each integer is a query.

Output :

For each query, you have to out put a line:

1.  If found :
    Output:  Found, index: N
    (N means the query's index of the sorted list)

2.  If not found:
    Output:  Not Found.

Sample Input :

1
2
3
-999999
2
5

Sample Output :

Found, index: 1
Not Found.

Hint :


  

Author :


  Solve it!   Status Forum (0)

C++
C
JAVA
19220. oop98703015 (10 ms , 517KB)
19203. oop98703018 (10 ms , 514KB)
19180. oop98703033 (10 ms , 510KB)
19122. oop98703054 (10 ms , 520KB)
19113. oop98703028 (10 ms , 517KB)
沒有解題記錄 55856. nwgs524513cja (449 ms , 3813KB)
55897. nwgs524513cja (462 ms , 3548KB)
56036. nwgs524513cja (465 ms , 3528KB)
58786. nwgs524513cja (473 ms , 3400KB)
55857. nwgs524513cja (481 ms , 3497KB)

執行時間會受很多因素影響因此僅供參考,主機等級請看這裡