Video: Dab tsi yog qhov teeb meem phem tshaj plaws thiab qhov teeb meem nruab nrab nyuaj ntawm binary nrhiav ntoo?
2024 Tus sau: Lynn Donovan | [email protected]. Kawg hloov kho: 2023-12-15 23:47
Binary nrhiav tsob ntoo
Algorithm | Nruab nrab | Qhov phem tshaj plaws |
---|---|---|
Qhov chaw | O(n) | O(n) |
Nrhiav | O (log n) | O(n) |
Ntxig | O (log n) | O(n) |
Rho tawm | O (log n) | O(n) |
Dhau li ntawd, dab tsi yog qhov loj O phem tshaj lub sij hawm nyuaj ntawm ib tsob ntoo nrhiav binary?
Tus qauv recursive ntawm a BST yields ib tug recursive algorithm. Nrhiav hauv a BST muaj O (h) phem tshaj - cas lub sijhawm ua haujlwm nyuaj , qhov twg h yog qhov siab ntawm lub tsob ntoo . Txij li thaum s binary nrhiav tsob ntoo nrog n nodes muaj yam tsawg kawg nkaus O (log n) theem, nws yuav siv sij hawm tsawg kawg O (log n) kev sib piv los nrhiav ib qho chaw tshwj xeeb.
Qhov thib ob, dab tsi yog lub sijhawm nyuaj ntawm kev tshawb nrhiav binary nrog iteration? Kev ua tau zoo ntawm Binary Nrhiav Algorithm : Yog li ntawd, lub sij hawm complexity ntawm binary nrhiav algorithm yog O (log2n) uas ua tau zoo heev. Qhov chaw pabcuam siv los ntawm nws yog O (1) rau rov hais dua kev siv thiab O (log2n) rau recursive siv vim hu pawg.
Tsis tas li lo lus nug yog, dab tsi yuav yog qhov phem tshaj lub sij hawm nyuaj ntawm kev tshawb nrhiav ib qho hauv ib tsob ntoo nrhiav binary?
Lub sij hawm nyuaj : Cov phem tshaj lub sij hawm complexity ntawm nrhiav thiab ntxig cov haujlwm yog O(h) qhov twg h yog qhov siab ntawm Binary Nrhiav tsob ntoo . Hauv qhov phem tshaj plaws , peb muaj muaj rau taug kev los ntawm cag rau nplooj nplooj tob. Qhov siab ntawm ib tug skewed tsob ntoo muaj ua n og lub sij hawm complexity ntawm nrhiav thiab ntxig kev ua haujlwm muaj ua O(n).
Puas yog Big O qhov xwm txheej phem tshaj?
Yog li, Hauv kev tshawb nrhiav binary, qhov zoo tshaj plaws cas yog O (1), nruab nrab thiab qhov phem tshaj plaws yog O (logn). Hauv luv luv, tsis muaj kev sib raug zoo ntawm hom loj O yog siv rau qhov phem tshaj plaws , Theta rau nruab nrab cas ”. Txhua hom kev sau ntawv tuaj yeem siv tau (thiab qee zaum) siv thaum tham txog qhov zoo tshaj plaws, nruab nrab, lossis qhov phem tshaj plaws ntawm ib qho algorithm.
Pom zoo:
Qhov txawv ntawm qhov nyuaj thiab nyuaj yog dab tsi?
Raws li adjectives qhov txawv ntawm qhov nyuaj thiab nyuaj. yog qhov nyuaj yog qhov nyuaj, tsis yooj yim, yuav tsum tau siv zog ntau thaum qhov nyuaj yog qhov nyuaj lossis convoluted
Qhov twg sorting algorithm yog qhov zoo tshaj plaws hauv qhov phem tshaj?
Sorting algorithms Algorithm Cov ntaub ntawv qauv Lub Sijhawm complexity: Qhov phem tshaj plaws ceev xaiv Array O(n2) Sib sau ua ke Array O(n log(n)) Heap txheeb Array O(n log(n)) Smooth txheeb Array O(n log(n))
Dab tsi yog qee qhov teeb meem kev coj ncaj ncees thiab teeb meem cuam tshuam nrog khoos phis tawj thiab kev sib txuas lus hluav taws xob?
Qee qhov teeb meem no yog qhov tshiab (xws li luam theej duab software), thaum lwm tus yog cov tshiab version ntawm cov teeb meem qub txog qhov raug thiab tsis ncaj ncees, kev ncaj ncees, kev ncaj ncees, lub luag haujlwm, tsis pub lwm tus paub, kev ntseeg siab, kev lav phib xaub, thiab kev ncaj ncees. Cov neeg siv ntsib qee qhov teeb meem no thaum cov kws tshaj lij hauv computer ntsib tag nrho lawv
Dab tsi yog qhov txawv ntawm 2 txoj kev thiab nruab nrab lub teeb hloov?
Ib qho kev hloov nruab nrab tuaj yeem siv los ua ib txoj hauv kev lossis ob txoj kev hloov (tab sis yog kim dua, yog li feem ntau tsis siv rau qhov no). Ob txoj kev hloov yuav siv tau los ua ib txoj kev hloov los yog ob txoj kev hloov. Lawv feem ntau siv los ua ob qho tib si
Dab tsi yog qhov xav tau rau cov chav kawm paub daws teeb meem thiab kev paub daws teeb meem?
Cov chav kawm Abstract. Abstract (uas Java txhawb nrog cov ntsiab lus paub daws teeb meem) txhais tau hais tias chav kawm lossis txoj hauv kev lossis teb lossis txhua yam tsis tuaj yeem ua tam sim (uas yog, tsim) qhov twg nws tau txhais. Lwm yam khoom yuav tsum instantiate cov khoom nyob rau hauv nqe lus nug. Yog tias koj ua ib chav kawm abstract, koj tsis tuaj yeem instantiate ib yam khoom los ntawm nws