Ukusesha nge-binary kuqhathaniswa kanjani nezinye izinhlelo zokusesha?
Context:Ama-array ahlelwe ngokucinga kanambambili ayisixazululo esingasebenzi kahle lapho ukufakwa nokususa imisebenzi kuhlanganiswa nokubuyisa, kuthatha  O (n) isikhathi somsebenzi ngamunye onjalo. Ngaphezu kwalokho, ama-array ahleliwe angenza kube nzima ukusebenzisa inkumbulo ikakhulukazi lapho izakhi zivame ukufakwa ku-array. Kukhona nezinye izakhiwo zedatha ezisekela ukufakwa nokususa okusezingeni eliphezulu kakhulu. Ukusesha kanambambili kungasetshenziselwa ukwenza ukufanisa okuqondile nokubeka ubulungu (ukunquma ukuthi ngabe inani elihlosiwe liseqoqweni lamagugu). Kukhona izakhiwo zedatha ezisekela ukufanisa okusheshayo nokulingana okusheshayo. Kodwa-ke, ngokungafani nezinye izinhlelo eziningi zokusesha, ukusesha kanambambili kungasetshenziselwa ukufanisa okusondele kahle, imvamisa kwenziwa ukufanisa okunjalo O ((log n) isikhathi kungakhathaliseki uhlobo noma isakhiwo amagugu ngokwabo. Ngaphezu kwalokho, kunemisebenzi ethile, njengokuthola into encane kakhulu futhi enkulu kunazo zonke, engenziwa kahle kuloluhlu oluhleliwe.  Ukusesha okuqondile:  Ukusesha okuqondile kuyi-algorithm elula yokusesha ehlola irekhodi ngalinye kuze kube yilapho ithola inani elihlosiwe. Ukucinga okuqondile kungenziwa ohlwini oluxhunyiwe, okuvumela ukufakwa nokususwa okusheshayo kunohlu. Ukusesha kanambambili kuyashesha kunokusesha okuqondile kwemigqa ehleliwe ngaphandle uma i-array imfushane, yize i-array idinga ukuhlelwa kusengaphambili. Zonke izixazululo zokuhlunga ezisekelwe ekuqhathaniseni izakhi, ezifana nokuhlunga okusheshayo nokuhlunga okuhlanganisiwe, zidinga okungenani O ((nlog n) ukuqhathanisa esimweni esibi kakhulu. Ngokungafani nokusesha okuqondile, ukusesha kanambambili kungasetshenziselwa ukufanisa okuseduze. Kukhona imisebenzi efana nokuthola into encane kunazo zonke futhi enkulu kunazo zonke engenziwa ngokuphumelelayo ku-array ehleliwe kodwa hhayi ku-array engahleliwe.  Izihlahla:  Izihlahla zokucinga kanambambili ziseswa kusetshenziswa i-algorithm efana nokucinga kanambambili. Isihlahla sokusesha kanambambili siyisakhiwo sedatha sesihlahla kanambambili esisebenza ngokusekelwe kumgomo wokusesha kanambambili. Amarekhodi esihlahla ahlelwe ngokulandelana, futhi irekhodi ngalinye esihlahleni lingaseshwa kusetshenziswa i-algorithm efana nokusesha kanambambili, kuthatha isikhathi esimaphakathi se-logarithmic. Ukufaka nokususa kudinga nesikhathi esilinganiselwe se-logarithmic ezihlahleni zokusesha kanambambili. Lokhu kungaba ngokushesha kunokufakwa kwesikhathi okuqondile nokususwa kwezinhlaka ezihleliwe, futhi izihlahla kanambambili zigcina ikhono lokwenza yonke imisebenzi engenzeka kuhlaka oluhleliwe, kufaka phakathi uhla kanye nemibuzo esondele.  Nokho, ukucinga kanambambili kuvame ukusebenza kangcono ekufuneni njengoba izihlahla zokucinga kanambambili cishe zizoba nokulinganisela okungaphelele, okuholele ekusebenzeni okubi kakhulu kunokucinga kanambambili. Lokhu kusebenza ngisho nasezihlahleni zokucwaninga kanambambili ezilinganiselwe, izihlahla zokucwaninga kanambambili ezilinganisela ama-node azo, ngoba azivamile ukukhiqiza isihlahla esinamazinga ambalwa kakhulu. Ngaphandle kwezihlahla zokucinga ezilinganiselwe, isihlahla singase sibe nokungalingani kakhulu nama-node ambalwa angaphakathi anezingane ezimbili, okuholela ekutheni isikhathi sokucinga esijwayelekile nesimbi kakhulu sisondele n ukuqhathanisa.[e] Izihlahla zokucinga kanambambili zithatha isikhala esithe xaxa kunama-array ahlelwe.  Izihlahla zokucinga kanambambili ziyakwazi ukusesha ngokushesha kwimemori yangaphandle egcinwe kuma-hard disk, njengoba izihlahla zokucinga kanambambili zingahlelwa kahle ezinhlelweni zamafayela. Isihlahla-B sihlanganisa le ndlela yokuhlelwa kwezihlahla. Izihlahla ze-B zivame ukusetshenziselwa ukuhlela isitoreji sesikhathi eside njengama-database nezinhlelo zamafayela.  Ukushaya: Ukuze kusetshenziswe ama-array ahlangene, amathebula e-hash, isakhiwo sedatha esibala amaphasi okhiye kumarekhodi asebenzisa umsebenzi we-hash, ngokuvamile sishesha kunokusesha kanambambili ku-array ehleliwe yamarekhodi. Iningi lokusetshenziswa kwetafula le-hash lidinga kuphela isikhathi esiqhubekayo esiphelelwe yisikhathi ngokwesilinganiso. Kodwa-ke, i-hashing ayilusizo ekufaneni okucishe kube khona, njengokubala ukhiye olandelayo omncane, olandelayo omkhulu, futhi oseduze, njengoba okuwukuphela kolwazi olunikezwe ekusesheni okungaphumelelanga ukuthi inhloso ayikho kunoma iyiphi irekhodi. Ukusesha nge-binary kuwusizo kakhulu ekufaneni okunjalo, ngoba kwenziwa ngesikhathi sokulinganisa. Ukusesha nge-binary nakho kusekela ukufanelana okuseduze. Eminye imisebenzi, efana nokuthola into encane kunazo zonke futhi enkulu kunazo zonke, ingenziwa ngokuphumelelayo kuma-array ahlelwe kodwa hhayi kumatafula e-hash.  Setha ama-algorithm wobulungu: Inkinga ehlobene nokufuna ubulungu besethi. Noma iyiphi i-algorithm eyenza ukubheka, njengokusesha kanambambili, nayo ingasetshenziselwa ubulungu besethi. Kukhona nezinye izinqubo ezifaneleka ngokukhethekile ukuba yilungu leqoqo. I- bit array iyona elula kunazo zonke, ewusizo lapho uhla lwezinkinobho lulinganiselwe. Igcina iqoqo lama-bit ngokucophelela, i-bit ngayinye imelela ukhiye owodwa ngaphakathi kwebanga lokhiye. Ama-array we-bit ashesha kakhulu, adinga kuphela O(1) isikhathi. Uhlobo lweJudy1 lwe-Judy array luphatha okhiye abangama-64-bit kahle.  Ukuze uthole imiphumela eseduze, izihlungi ze-Bloom, esinye isakhiwo sedatha esinobufakazi esisekelwe ekuhlanganiseni, sigcina isethi yezikhiye ngokufaka amakhodi okhiye besebenzisa uhla lwe-bit nemisebenzi eminingi ye-hash. Izihlungi ze-Bloom zisebenza kahle kakhulu endaweni kunama-bit arrays ezimweni eziningi futhi aziphuzi kakhulu: nge k imisebenzi ye-hash, imibuzo yobulungu idinga kuphela Isikhathi esihle. Nokho, izihlungi zeBloom zihlushwa ama-false positive.  Ezinye izakhiwo zedatha: Kukhona izakhiwo idatha okungase ngcono on search kanambambili kwezinye izimo kokubili ukucinga kanye nezinye imisebenzi etholakalayo array ihlelwe. Ngokwesibonelo, ukusesha, ukufanisa okuseduze, kanye nemisebenzi etholakalayo kuma-array ahleliwe kungenziwa ngokuphumelelayo kunokusesha kanambambili ezakhiweni zedatha ezikhethekile ezifana nezihlahla ze-van Emde Boas, izihlahla zokuhlanganiswa, ukuzama, kanye nama-array we-bit. Lezi zakhiwo zedatha ezikhethekile ngokuvamile zishesha kuphela ngoba zisebenzisa izakhiwo zezikhiye ezinezici ezithile (ngokuvamile izinkinobho ezincane eziphelele), futhi ngaleyo ndlela zizodla isikhathi noma isikhala sezikhiye ezingenazo lezo zimfanelo. Uma nje izinkinobho zingahlelwa, le misebenzi ingenziwa njalo okungenani ngokuphumelelayo ku-array ehleliwe kungakhathalekile ukuthi yiziphi izinkinobho. Ezinye izakhiwo, njengezinhlaka zikaJudy, zisebenzisa inhlanganisela yezindlela zokunciphisa lokhu ngenkathi zigcina ukusebenza kahle kanye nekhono lokwenza ukufanisa okuseduze.
Ama-array ahleliwe anokusesha kanambambili ayisixazululo esingasebenzi kahle lapho ukufaka nokususa imisebenzi kuhlanganiswa nokubuyisa. Ngaphezu kwalokho, ama-array ahleliwe angenza kube nzima ukusebenzisa inkumbulo ikakhulukazi lapho izakhi zivame ukufakwa ku-array. Ukusesha kanambambili kuyashesha kunokusesha okuqondile kwemigqa ehleliwe ngaphandle uma i-array imfushane, yize i-array idinga ukuhlelwa kusengaphambili. Ukusesha kanambambili kuvame ukusebenza kahle kakhulu ekusesheni njengoba izihlahla zokusesha kanambambili cishe zizoba nokulinganisela okungaphelele, okuholele ekusebenzeni okubi kakhulu kunokusesha kanambambili. isakhiwo sedatha esibala izinkinobho kumarekhodi sisebenzisa umsebenzi we-hash, ngokuvamile sishesha ukwedlula ukusesha kanambambili ku-array ehleliwe yamarekhodi.