Method and system for binary search
The present invention provides a method and system for binary search. The method comprises providing a memory device with M entries, each entry storing a value; providing an index register including N register blocks, wherein the N register blocks partition the memory device into N−1, N or N+1 search areas; wherein M and N are integers and N<M; wherein when a target value is being searched in the memory device, the target value is determined to be fall between two adjacent register blocks, and only the addresses of the memory device in between the two register blocks are left for search.
1. A method for binary search, comprising:
providing a memory device with M entries, each entry storing a value; and
providing an index register including N register blocks, wherein the N register blocks partition the memory device into N−1, N or N+1 search areas;
wherein M and N are integers and N<M;
wherein when a target value is being searched in the memory device, the target value is determined to be fall between two adjacent register blocks, and only the addresses of the memory device in between the two register blocks are left for search.
2. The method for performing a binary search according to claim 1 , wherein the register blocks are extracted from the M entries of the memory device.
3. The method for performing a binary search according to claim 1 , wherein the values stored in the memory device are sorted in order from small to large.
4. The method for performing a binary search according to claim 1 , wherein the values stored in the memory device are sorted in order from large to small.
5. The method for performing a binary search according to claim 2 , wherein the sorting is performed by a software.
6. A system for performing a binary search, comprising:
a memory device, the memory device includes M entries, and each entry stores a value; and
an index register, the index register includes N register blocks, and the N register blocks partition the memory device into N−1, N or N+1 search areas;
wherein M and N are integers and N<M;
wherein when a target value is being searched in the memory, the target value is determined to be fall between two adjacent register blocks, and only the addresses of the memory in between the two register blocks are left for search.
7. The system for performing a binary search according to claim 6 , wherein the register blocks are extracted from the M entries of the memory device.
8. The system for performing a binary search according to claim 6 , wherein the values stored in the memory device are sorted in order from small to large.
9. The system for performing a binary search according to claim 6 , wherein the values stored in the memory device are sorted in order from large to small.
10. The system for performing a binary search according to claim 7 , wherein the sorting is performed by a software.