TWI836239B - Method and system for binary search - Google Patents

Method and system for binary search Download PDF

Info

Publication number
TWI836239B
TWI836239B TW110126500A TW110126500A TWI836239B TW I836239 B TWI836239 B TW I836239B TW 110126500 A TW110126500 A TW 110126500A TW 110126500 A TW110126500 A TW 110126500A TW I836239 B TWI836239 B TW I836239B
Authority
TW
Taiwan
Prior art keywords
binary search
storage device
value
search
entries
Prior art date
Application number
TW110126500A
Other languages
Chinese (zh)
Other versions
TW202305616A (en
Inventor
蕭義龍
周智良
Original Assignee
美商光禾科技股份有限公司
Filing date
Publication date
Application filed by 美商光禾科技股份有限公司 filed Critical 美商光禾科技股份有限公司
Priority to TW110126500A priority Critical patent/TWI836239B/en
Publication of TW202305616A publication Critical patent/TW202305616A/en
Application granted granted Critical
Publication of TWI836239B publication Critical patent/TWI836239B/en

Links

Abstract

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.

Description

用於二分搜尋的方法和系統 Method and system for binary search

本發明涉及一種用於二分搜尋的方法和系統,更具體地,涉及一種用於具有恆定最大響應時間的可擴展硬體二分搜尋設計的方法和系統。 The present invention relates to a method and system for binary search, and more particularly, to a method and system for a scalable hardware binary search design with constant maximum response time.

二分搜尋,也稱為半區間搜尋、對數搜尋或二分截斷演算法。是一種搜尋演算法,其在已排序的數組中找到目標值的位置。二分搜尋將目標值與數組的中間元素進行比較。如果中間元素正好是要搜尋的元素,則搜尋結束。如果搜尋目標值大於或者小於中間元素,則在陣列大於或小於中間元素的那一半區間中搜尋。並繼續搜尋剩餘的一半區間,再次取中間元素與目標值進行比較,並重複此操作直到找到目標值。如果搜尋範圍結束,則目標不在數組中。 Binary search, also known as half-interval search, logarithmic search or binary truncation algorithm. It is a search algorithm that finds the location of a target value in a sorted array. Binary search compares the target value with the middle element of the array. If the middle element is exactly the element to be searched, the search ends. If the search target value is greater than or less than the middle element, search in the half of the array that is greater than or less than the middle element. Continue searching the remaining half of the interval, compare the middle element with the target value again, and repeat this operation until the target value is found. If the search range ends, the target is not in the array.

請同時參考圖1A和圖1B,其說明了傳統的二分搜尋。 Please refer to Figure 1A and Figure 1B together, which illustrate the traditional binary search.

從圖A中可以看出,二分搜尋表存儲在記憶體中,即將進行二分搜尋。記憶體包括幾個位址,從#0、#1到#15。每個位址存儲一個s值。例如,#0存儲值3,#4存儲值20,#13存儲值87。現在請求搜尋查詢。搜尋查詢請求搜尋記憶體中是否存在值75。 As can be seen in Figure A, the binary search table is stored in the memory and is about to be searched. The memory includes several addresses, from #0, #1 to #15. Each address stores an s value. For example, #0 stores the value 3, #4 stores the value 20, and #13 stores the value 87. Now request a search query. The search query requests to search whether the value 75 exists in the memory.

參見圖1A,傳統的二分搜尋方法首先執行步驟1,包括以下子步驟:(1)讀取存儲在#7記憶體位址中的值;(2)#7中找到值47,確定47<75;(3)然後確定目標值沒有在#0~#6的範圍內,不需要進行搜尋,因為值是按順序存儲的,如圖1A所示。 Referring to FIG1A , the traditional binary search method first executes step 1, which includes the following sub-steps: (1) reading the value stored in the memory address #7; (2) finding the value 47 in #7 and determining that 47<75; (3) then determining that the target value is not in the range of #0~#6 and that no search is required because the values are stored in order, as shown in FIG1A .

傳統的二分搜尋進行到步驟2,該步驟還包括以下子步驟:(1)讀取存儲位址#11中存儲的值;(2)#11中找到值72,確定72<75;(3)然後確定沒有搜尋#8~#10的必要,因為值是按順序存儲的。 The traditional binary search proceeds to step 2, which also includes the following sub-steps: (1) Read the value stored in storage address #11; (2) Find the value 72 in #11, and determine that 72<75; (3) Then make sure there is no need to search for #8~#10 because the values are stored in order.

參見圖1B,傳統二分搜尋方法的步驟3,步驟3還執行以下子步驟:(1)讀取存儲在#13記憶體位址中的值;(2)#13中找到值87,確定87>75;(3)然後確定沒有搜尋#14~#15的必要,因為值是按順序存儲的。 See Figure 1B, step 3 of the traditional binary search method. Step 3 also performs the following sub-steps: (1) read the value stored in the memory address #13; (2) find the value 87 in #13 and determine that 87>75; (3) then determine that there is no need to search #14~#15 because the values are stored in order.

傳統的二分搜尋最後進行到步驟4,該步驟還包括以下子步驟:(1)讀取存儲在#12記憶體位址中的值;(2)發現記憶體位址#12中存有值80;(3)可以得出結論,75在記憶體中不存在。 The traditional binary search finally proceeds to step 4, which also includes the following sub-steps: (1) Read the value stored in memory address #12; (2) Find that the value 80 is stored in memory address #12; (3) It can be concluded that 75 does not exist in the memory.

因此,傳統的硬體二分搜尋設計存在一定的缺陷,例如通過硬體對錶項進行排序和插入需要復雜的邏輯電路設計和更多的執行時間。此外,對於一個有M個條目的表,二分搜尋的最大響應時間是log2M。而且,更大的表大小導致更大的最大響應時間。 Therefore, the traditional hardware binary search design has certain flaws. For example, sorting and inserting table items through hardware requires complex logic circuit design and more execution time. Furthermore, for a table with M entries, the maximum response time for a binary search is log 2 M. Also, larger table sizes result in larger maximum response times.

更進一步,對於另一種傳統的BCAM,它提供了更短的搜尋時間,但是需要更大的電路面積,這導致更高的成本。 Furthermore, for another traditional BCAM, it provides a shorter search time but requires a larger circuit area, which leads to higher cost.

本發明涉及一種二分搜尋方法,包括:提供具有M個條目的存儲設備,每個條目存儲一個數組值;提供包括N個暫存器的索引暫存器,其中N個暫存器將存儲設備劃分為N-1、N或N+1個搜尋區域;其中M和N為整數且N<M;其中,當在存儲設備中搜尋目標值時,確定目標值落在相鄰的兩個暫存器之間,只剩下兩個暫存器之間的存儲設備的位址進行搜尋。 The present invention relates to a binary search method, comprising: providing a storage device having M entries, each entry storing an array value; providing an index register comprising N registers, wherein the N registers divide the storage device into N-1, N or N+1 search areas; wherein M and N are integers and N<M; wherein, when searching for a target value in the storage device, it is determined that the target value falls between two adjacent registers, and only the address of the storage device between the two registers is left to search.

較佳地,所述暫存器是從所述存儲設備的M個條目中提取的。 Preferably, the temporary register is extracted from M entries of the storage device.

較佳地,所述存儲設備中存儲的值按從小到大的順序排列。 Preferably, the values stored in the storage device are arranged in order from small to large.

較佳地,所述存儲設備中存儲的值按從大到小的順序排列。 Preferably, the values stored in the storage device are arranged in order from large to small.

較佳地,所述排序由軟體進行。 Preferably, the sorting is performed by software.

本發明涉及一種二分搜尋系統,包括:存儲設備,該存儲設備包括M個條目,每個條目存儲一個值;和索引暫存器,索引暫存器包括N個暫存器,N個暫存器將存儲設備劃分為N-1、N或N+1個搜尋區;其中M和N為整數且N<M;其中,當在記憶體中搜尋目標值時,確定目標值落在相鄰的兩個暫存器之間,只剩下兩個暫存器之間的記憶體位址進行搜尋。 The present invention relates to a binary search system, comprising: a storage device, the storage device comprising M entries, each entry storing a value; and an index register, the index register comprising N registers, the N registers dividing the storage device into N-1, N or N+1 search areas; wherein M and N are integers and N<M; wherein, when searching for a target value in a memory, it is determined that the target value falls between two adjacent registers, leaving only the memory address between the two registers for searching.

較佳地,所述暫存器是從所述存儲設備的M個條目中提取的 Preferably, the temporary register is extracted from M entries of the storage device

較佳地,所述存儲設備中存儲的值按從小到大的順序排列。 Preferably, the values stored in the storage device are arranged in order from small to large.

較佳地,所述存儲設備中存儲的值按從大到小的順序排列。 Preferably, the values stored in the storage device are arranged in order from large to small.

較佳地,所述排序由軟體進行。 Preferably, the sorting is performed by software.

201、301:記憶體 201, 301: Memory

202、302:索引暫存器 202, 302: Index register

圖1A-1B說明了傳統的二分搜尋;圖2A-2C說明了本發明的改進的二分搜尋方法;和 圖3提供了本發明的改進的二分搜尋方法的一般說明。 Figures 1A-1B illustrate a traditional binary search; Figures 2A-2C illustrate the improved binary search method of the present invention; and Figure 3 provides a general illustration of the improved binary search method of the present invention.

除非另外定義,否則本文使用的所有技術和科學術語具有與本公開所屬領域的技術人員通常理解的相同的含義。將進一步理解術語;例如在常用詞典中定義的那些,應被解釋為具有與其在相關技術和本公開的上下文中的含義一致的含義,並且除非明確如此定義,否則不會以理想化或過於正式的含義進行解釋在此處。 Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by a person skilled in the art to which this disclosure belongs. It will be further understood that terms; such as those defined in commonly used dictionaries, should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and this disclosure, and will not be interpreted here in an idealized or overly formal meaning unless expressly so defined.

在整個說明書中對“一個實施例”或“一個實施例”的引用意味著結合該實施例描述的特定特徵、結構或特性被封包括在至少一個實施例中。因此,在本說明書各處出現的短語“在一個實施例中”或“在一個實施例中”不一定都指代相同的實施例。此外,特定特徵、結構或特性可以在一個或多個實施例中以任何合適的方式組合。 References throughout this specification to "one embodiment" or "an embodiment" mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in at least one embodiment. Therefore, the phrases "in one embodiment" or "in an embodiment" appearing throughout this specification do not necessarily all refer to the same embodiment. Furthermore, particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.

請參考圖2A-2C。圖2A-2C為本發明改進後的二分搜尋方法的示意圖。此外,本發明還可以理解為一種改進的二分搜尋,在記憶體和暫存器中具有額外的二分搜尋表。 Please refer to Figures 2A-2C. Figures 2A-2C are schematic diagrams of the improved binary search method of the present invention. In addition, the present invention can also be understood as an improved binary search with additional binary search tables in the memory and register.

如圖2A所示,多個值存儲在記憶體201中。記憶體201包括16個位址,編號從#0到#15。然而,記憶體中的位址數量不受限制。本領域普通技術人員可以將本發明的公開內容應用到具有更多位址的其他記憶體中。 As shown in FIG. 2A , multiple values are stored in memory 201. Memory 201 includes 16 addresses numbered from #0 to #15. However, the number of addresses in the memory is not limited. A person of ordinary skill in the art can apply the disclosure of the present invention to other memories having more addresses.

回到圖2A,記憶體201的每個位址存儲一個值。例如,位址#0存儲值3,位址#6存儲值43,位址#14存儲值94。所描述和如圖所示的值僅用於示例目的,不應限製本發明的範圍發明。 Returning to FIG. 2A , each address of memory 201 stores a value. For example, address #0 stores the value 3, address #6 stores the value 43, and address #14 stores the value 94. The values described and shown in the figure are for exemplary purposes only and should not limit the scope of the present invention.

每個值以從小到大的順序存儲。當這些值進入記憶體201時,可以通過軟體進行排序。但是,排序的方法對於本領域普通技術人員來說是公知的,在此不再贅述。 Each value is stored in order from small to large. When these values enter the memory 201, they can be sorted by software. However, the sorting method is well known to ordinary technicians in this field and will not be described here.

可以相應地修改排序。也就是說,每個值可以按照從大到小的順序排列,本發明仍然可以適用。 The sorting can be modified accordingly. That is to say, each value can be arranged in order from large to small, and the present invention can still be applied.

進一步如圖2A所示,還提供了索引暫存器202。索引暫存器202包括四個位址,即#0、#5、#10和#15。對於每個位址,值3、值31、值67和值98分別存儲在位址#0、#5、#10和#15中。接下來,請求進來。請求詢問值75是否存在於記憶體201中。索引暫存器202可以是任何形式。也就是說,索引暫存器202可以實現為軟體或硬體。 As further shown in FIG. 2A, an index register 202 is also provided. The index register 202 includes four addresses, namely #0, #5, #10 and #15. For each address, the value 3, the value 31, the value 67, and the value 98 are stored in addresses #0, #5, #10, and #15 respectively. Next, the request comes in. The request asks whether value 75 exists in memory 201 . Index register 202 can be in any form. That is to say, the index register 202 can be implemented as software or hardware.

接下來參考圖2B,進一步說明了請求進來後的步驟1。對於步驟1,根據索引暫存器202中記錄的信息,可以發現75大於67且小於比98。即67<75<98。因此,位址#0到#9以及位址#10和位址#15可以排除搜尋,因為目標值75落在67之間(存儲在#10)和98(存儲在#15中),使搜尋從位址#11到位址#14執行。從圖可以看出,在未經記憶體讀取的情況下,這種索引暫存器202有助於排除一半以上的位址。 Next, referring to Figure 2B, step 1 after the request comes in is further explained. For step 1, according to the information recorded in the index register 202, it can be found that 75 is greater than 67 and less than 98. That is 67<75<98. Therefore, addresses #0 to #9 and addresses #10 and #15 can be eliminated from the search because the target value 75 falls between 67 (stored in #10) and 98 (stored in #15), making the search Execute from address #11 to address #14. It can be seen from the figure that this index register 202 helps to exclude more than half of the addresses without reading from the memory.

接下來參考圖2C,其示出了步驟2和步驟3。在步驟2中,讀取存儲在位址#12中的值。發現值80存儲在位址#80中。由於值80大於目標值75,並且在每個存儲值按順序排列的前提下,很快就會發現不需要從位址#13到#14搜尋,因為存儲在兩個位址必須大於值75。 Next, refer to Figure 2C, which shows steps 2 and 3. In step 2, the value stored in address #12 is read. The value 80 is found to be stored in address #80. Since the value 80 is greater than the target value 75, and each stored value is arranged in order, it will soon be found that there is no need to search from address #13 to #14, because the value stored in both addresses must be greater than the value 75.

本發明進一步進行到步驟3,接下來讀取存儲在記憶體位址#11中的值。然後發現位址#11中存儲的值為72。這樣的值72是目前沒有排除的最後一 個值。然而,由於72不等於75,因此可以得出結論,值75不存在於記憶體201中。 The present invention further proceeds to step 3, and then reads the value stored in the memory address #11. Then it is found that the value stored in the address #11 is 72. Such a value 72 is the last value that is not currently excluded. However, since 72 is not equal to 75, it can be concluded that the value 75 does not exist in the memory 201.

回到圖2C的步驟2,本領域普通技術人員可以相應地調整讀取其他位址中存儲的值(例如,可以不讀取#12中的值,而是可以讀取13中存儲的值) Returning to step 2 of Figure 2C, a person skilled in the art can adjust the reading of the values stored in other addresses accordingly (for example, instead of reading the value in #12, the value stored in 13 can be read)

接下來參考圖3,其提供了本發明的改進的二分搜尋方法的一般說明。 Reference is next made to Figure 3, which provides a general illustration of the improved binary search method of the present invention.

假設記憶體301包括M個表項,編號為表項1、表項2……到表項M。每個表項中存儲有一個值,所有值按從小到大的順序排列。排序可以通過軟體的輔助來完成,由於排序的相關技術為本領域的常規技術,為方便起見,不再贅述。 Assume that the memory 301 includes M entries, numbered from entry 1, entry 2, ... to entry M. Each entry stores a value, and all values are arranged in ascending order. Sorting can be done with the assistance of software. Since the relevant technology of sorting is a conventional technology in this field, it will not be repeated for convenience.

可以相應地修改排序。也就是說,每個值可以按照從大到小的順序排列,本發明仍然可以適用。 The sorting can be modified accordingly. That is, each value can be arranged in order from largest to smallest, and the present invention can still be applied.

再次參考圖3,提供了索引暫存器302。索引暫存器302包括N個區域,編號為Reg 1、Reg 2…到Reg N。這N個區域將二分搜尋表劃分為N+1個二分搜尋區域,標記為Binary Search Area 1、Binary Search Area 2…to Binary搜尋區域N+1。 Referring again to FIG. 3 , an index register 302 is provided. The index register 302 includes N regions, numbered Reg 1, Reg 2… to Reg N. The N regions divide the binary search table into N+1 binary search areas, labeled Binary Search Area 1, Binary Search Area 2… to Binary Search Area N+1.

應用上述步驟,本發明改進的二分搜尋可以進一步減少計算資源。 Applying the above steps, the improved binary search of the present invention can further reduce computing resources.

因此,表格條目由軟體排序。在設置記憶體中具有M個條目的硬體二分搜尋表的內容時,軟體還設置了額外的N個索引暫存器(N<M),每個索引暫存器包含相同的([M/(N+1)]*K)'th個表項,其中K的範圍從1到N。 Therefore, the table entries are sorted by software. When setting up the contents of a hardware binary search table with M entries in memory, software also sets up an additional N index registers (N<M), each containing the same ([M/(N+1)]*K)'th table entries, where K ranges from 1 to N.

需要說明的是,N個區域是從記憶體的位址中提取的。例如,在圖中。如圖2A所示,索引暫存器202具有四個區域,分別從位址#0、位址#5、位址#10和位址#15中提取。 It should be noted that the N regions are extracted from the addresses of the memory. For example, in FIG. As shown in FIG. 2A , the index register 202 has four regions, which are extracted from address #0, address #5, address #10, and address #15, respectively.

還需要說明的是,如果將記憶體的首尾位址都提取出來,則劃分的搜尋區域將下降到N-1個。如果提取了記憶體首尾位址中的一個,則分區搜尋區域為N。如果沒有提取記憶體首尾位址,則分區搜尋區域為N+1。 It should also be noted that if the first and last addresses of the memory are extracted, the divided search areas will be reduced to N-1. If one of the first and last addresses of the memory is extracted, the partition search area is N. If the first and last addresses of the memory are not extracted, the partition search area is N+1.

應用上述步驟,本發明改進的二分搜尋可以進一步減少計算資源。 By applying the above steps, the improved binary search of the present invention can further reduce computing resources.

因此,表格條目由軟體排序。在設置記憶體中具有M個條目的硬體二分搜尋表的內容時,軟體還設置了額外的N個索引暫存器(N<M),每個索引暫存器包含相同的([M/(N+1)]*K)'th個表項,其中K的範圍從1到N。 Therefore, the table entries are sorted by software. When setting up the contents of a hardware binary search table with M entries in memory, software also sets up an additional N index registers (N<M), each containing the same ([M/(N+1)]*K)'th table entries, where K ranges from 1 to N.

需要說明的是,N個區域是從記憶體的位址中提取的。例如,在圖中。如圖2A所示,索引暫存器202具有四個區域,分別從位址#0、位址#5、位址#10和位址#15中提取。 It should be noted that the N regions are extracted from the addresses of the memory. For example, in FIG. As shown in FIG. 2A , the index register 202 has four regions, which are extracted from address #0, address #5, address #10, and address #15, respectively.

還需要說明的是,如果將記憶體的首尾位址都提取出來,則劃分的搜尋區域將下降到N-1個。如果提取了記憶體首尾位址中的一個,則分區搜尋區域為N。如果沒有提取記憶體首尾位址,則分區搜尋區域為N+1。 It should also be noted that if the first and last addresses of the memory are extracted, the divided search areas will be reduced to N-1. If one of the first and last addresses of the memory is extracted, the partition search area is N. If the first and last addresses of the memory are not extracted, the partition search area is N+1.

通過索引暫存器中存儲的信息,記憶體中的目標二分搜尋區域顯著減少,並且無論表大小有多大,搜尋區域的大小都是固定的。最大二分搜尋時間上限為log2((M-N)/(N+1))。 By storing information in the index scratchpad, the target binary search area in memory is significantly reduced, and the size of the search area is fixed regardless of the size of the table. The maximum binary search time is upper bounded by log 2 ((MN)/(N+1)).

綜上所述,對於本發明,還可以進一步理解,在軟體的輔助下,無論硬體表的大小有多大,本發明的二分搜尋在記憶體上的最大搜尋時間上限都可以是固定的。 In summary, for the present invention, it can be further understood that with the assistance of software, no matter how big the size of the hardware table is, the upper limit of the maximum search time of the binary search in the memory of the present invention can be fixed.

綜上所述,本發明的目的之一是,本發明控制二分搜尋的最大搜尋時間上限以適應性能要求。 In summary, one of the purposes of the present invention is to control the maximum search time limit of binary search to meet performance requirements.

此外,本發明可以應用於各種環境,例如所有硬體二分搜尋表設計,無論表大小有多大,透過軟體協助,限制其最大搜尋響應時間。 In addition, the present invention can be applied to various environments, such as all hardware binary search table designs. No matter how big the table size is, the maximum search response time can be limited through software assistance.

綜上所述,根據本發明,由軟體處理表單條目排序和插入額外的索引暫存器。這種設計降低了硬體複雜性。 In summary, according to the present invention, the sorting of form entries and the insertion of additional index registers are handled by software. This design reduces hardware complexity.

進一步地,通過增加適當數量的索引暫存器,可以控制最大二分搜尋響應時間以滿足性能要求。不一定需要高成本的BCAM作為解決方案。 Furthermore, by adding an appropriate number of index registers, the maximum binary search response time can be controlled to meet performance requirements. High-cost BCAM is not necessarily required as a solution.

綜上所述,本發明具有一定的潛在應用和市場。例如,對於所有硬體二分搜尋表設計,無論表大小有多大,都需要有限的最大響應時間。 In summary, the present invention has certain potential applications and markets. For example, all hardware binary search table designs require a finite maximum response time, regardless of table size.

綜上所述,本發明提供了一種具有固定最大響應時間的可擴展硬體二分搜尋設計,其中表項排序和插入由軟體處理。此外,還增加了適量的索引暫存器來記錄記憶體的內容。使用索引暫存器,目標二分搜尋區域只是表單的一小部分,搜尋區域大小保持不變,但可使整個搜尋表單大小增加。 In summary, the present invention provides a scalable hardware binary search design with a fixed maximum response time, in which table entry sorting and insertion are handled by software. In addition, an appropriate amount of index registers are added to record the contents of the memory. Using the index register, the target binary search area is only a small part of the table, and the search area size remains unchanged, but the size of the entire search table can be increased.

可見本揭露在突破先前之技術下,確實已達到所欲增進之功效,且也非熟悉該項技藝者所易於思及,其所具之進步性、實用性,顯已符合專利之申請要件,爰依法提出專利申請。 It can be seen that this disclosure has indeed achieved the desired improvement effect by breaking through the previous technology, and it is not easily imagined by those familiar with the technology. Its progress and practicality clearly meet the requirements for patent application. Yuan filed a patent application in accordance with the law.

以上所述僅為舉例性,而非為限制性者。其它任何未脫離本揭露之精神與範疇,而對其進行之等效修改或變更,均應該封包含於後附之申請專利範圍中。 The above description is for illustrative purposes only and is not intended to be limiting. Any other equivalent modifications or changes that do not depart from the spirit and scope of this disclosure should be included in the scope of the attached patent application.

201:記憶體 201:Memory

202:索引暫存器 202: Index register

Claims (10)

一種二分搜尋方法,包括:提供具有M個條目的存儲設備,每個所述條目存儲一個數組值;提供包括N個暫存器的索引暫存器,其中所述N個暫存器將存儲設備劃分為N-1、N或N+1個搜尋區域;其中M和N為整數且N<M;其中,當在所述存儲設備中搜尋目標值時,確定所述目標值落在相鄰的兩個暫存器之間,只在剩下兩個暫存器標示的記憶體位址之間進行搜尋。 A binary search method, including: providing a storage device with M entries, each entry storing an array value; providing an index register including N temporary registers, wherein the N temporary registers store the device Divided into N-1, N or N+1 search areas; where M and N are integers and N<M; wherein, when searching for a target value in the storage device, it is determined that the target value falls in an adjacent Between the two registers, only the memory addresses marked by the remaining two registers are searched. 如請求項1所述的二分搜尋的方法,其特徵在於,所述暫存器是從所述存儲設備的M個條目中提取的。 The binary search method as described in claim 1 is characterized in that the register is extracted from M entries of the storage device. 如請求項1所述的二分搜尋的方法,其特徵在於,所述存儲設備中存儲的數組值按從小到大的順序排列。 The binary search method as described in claim 1 is characterized in that the array values stored in the storage device are arranged in order from small to large. 如請求項1所述的二分搜尋的方法,其特徵在於,所述存儲設備中存儲的數組值按從大到小的順序排列。 The binary search method according to claim 1, characterized in that the array values stored in the storage device are arranged in order from large to small. 如請求項2所述的二分搜尋方法,其特徵在於,所述排序由軟體進行。 The binary search method as described in claim 2 is characterized in that the sorting is performed by software. 一種二分搜尋系統,包括:存儲設備,所述存儲設備包括M個條目,每個所述條目存儲一個數組值;和索引暫存器,所述索引暫存器包括N個暫存器,所述N個暫存器將所述存儲設備劃分為N-1、N或N+1個搜尋區;其中M和N為整數且N<M; 其中,當在所述存儲設備中搜尋目標值時,確定所述目標值落在相鄰的兩個暫存器之間,只在剩下兩個暫存器標示的記憶體位址進行搜尋。 A binary search system includes: a storage device, the storage device includes M entries, each of the entries stores an array value; and an index temporary register, the index temporary register includes N temporary registers, the N temporary registers divide the storage device into N-1, N or N+1 search areas; where M and N are integers and N<M; When searching for the target value in the storage device, it is determined that the target value falls between two adjacent temporary registers, and only the memory addresses marked by the remaining two temporary registers are searched. 如請求項6所述的二分搜尋系統,其特徵在於,所述暫存器是從所述存儲設備的M個條目中提取的。 A binary search system as described in claim 6, characterized in that the register is extracted from M entries of the storage device. 如請求項6所述的二分搜尋系統,其特徵在於,所述存儲設備中存儲的數組值按從小到大的順序排列。 The binary search system according to claim 6, characterized in that the array values stored in the storage device are arranged in order from small to large. 如請求項6所述的二分搜尋的方法,其特徵在於,所述存儲設備中存儲的數組值按從大到小的順序排列。 The binary search method as described in claim 6 is characterized in that the array values stored in the storage device are arranged in order from large to small. 如請求項7所述的二分搜尋系統,其特徵在於,所述排序由軟體進行。 The binary search system of claim 7, wherein the sorting is performed by software.
TW110126500A 2021-07-19 Method and system for binary search TWI836239B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW110126500A TWI836239B (en) 2021-07-19 Method and system for binary search

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW110126500A TWI836239B (en) 2021-07-19 Method and system for binary search

Publications (2)

Publication Number Publication Date
TW202305616A TW202305616A (en) 2023-02-01
TWI836239B true TWI836239B (en) 2024-03-21

Family

ID=

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200159915A1 (en) 2018-11-15 2020-05-21 Webroot Inc. Selective Import/Export Address Table Filtering

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200159915A1 (en) 2018-11-15 2020-05-21 Webroot Inc. Selective Import/Export Address Table Filtering

Similar Documents

Publication Publication Date Title
US7380053B2 (en) Method and system for emulating content-addressable memory primitives
US9639458B2 (en) Reducing memory accesses for enhanced in-memory parallel operations
JP5344324B2 (en) Data path, storage method and memory array usage for multi-level cell memory
US6903953B2 (en) Content addressable memory with cascaded array
JPS60136097A (en) Associative memory device
US20060117129A1 (en) High speed DRAM cache architecture
US6754771B2 (en) System for selectively transferring application data between storage devices in a computer system utilizing dynamic memory allocation
JP2019512794A (en) Priority based access of compressed memory lines in memory in processor based systems
TWI836239B (en) Method and system for binary search
TW202232310A (en) Dynamic metadata relocation in memory
Bercea et al. Dynamic dictionaries for multisets and counting filters with constant time operations
CN112732725B (en) NVM (non volatile memory) hybrid memory-based adaptive prefix tree construction method, system and medium
CN106708749A (en) Data search method
CN109933584B (en) Multi-level unordered indexing method and system
TW202305616A (en) Method and system for binary search
US11449275B2 (en) Method and system for binary search
US20080288495A1 (en) Fast select for fetch first n rows with order by
US11100267B1 (en) Multi dimensional memory compression using bytewide write enable
JP2021152900A (en) Storage device for managing command with overlapping range and method for checking overlap
US9824105B2 (en) Adaptive probabilistic indexing with skip lists
US6742077B1 (en) System for accessing a memory comprising interleaved memory modules having different capacities
US6807618B1 (en) Address translation
US11086852B2 (en) Hardware-assisted multi-table database with shared memory footprint
US20240086312A1 (en) Memory searching device and method
US11914587B2 (en) Systems and methods for key-based indexing in storage devices