Binciken Multi-manufa shine muhimmin algorithm a cikin shirye-shirye wanda ke ba da damar bincika ƙididdiga masu yawa a cikin bayanan da aka saita lokaci guda. Wannan algorithm yana magance batutuwa masu amfani a cikin shirye-shirye, kamar gano abubuwan da suka gamsar da yanayi a cikin jeri ko tsararru.
Ayyukan Algorithm
Algorithm ɗin bincike mai yawan manufa gabaɗaya yana aiki iri ɗaya ga algorithm don bincika manufa ɗaya. Duk da haka, maimakon tsayawa bayan gano manufa guda, yana ci gaba da bincike don nemo duk makasudin da suka gamsar da yanayin. Gaba ɗaya hanya na algorithm shine kamar haka:
- Yi maimaita ta kowane kashi a cikin saitin bayanai.
- Bincika yanayin kowane kashi. Idan kashi ya gamsar da yanayin, ƙara shi zuwa jerin sakamako.
- Ci gaba da maimaitawa ta wasu abubuwa don nemo wasu maƙasudai waɗanda suka gamsar da yanayin.
- Mayar da lissafin sakamako mai ɗauke da duk makasudin da suka gamsar da yanayin.
Abũbuwan amfãni da rashin amfani
Amfani:
- Algorithm na bincike mai yawan manufa yana da m kuma yana aiki a yanayi daban-daban.
- Yana adana lokaci da ƙoƙari idan aka kwatanta da yin madaukai daban-daban don nemo kowace manufa.
Rashin hasara:
- Ayyukan algorithm za a iya shafar lokacin da ake hulɗa da manyan bayanan bayanai da adadi mai yawa da ke gamsar da yanayin.
- Yana iya haifar da gazawar ƙwaƙwalwar ajiya lokacin adana babban jerin sakamako tare da hari da yawa.
Misali da Bayani
Bari mu ɗauka muna da jerin ƙididdiga kuma muna son nemo duk lambobi waɗanda suke da yawa na 3 a cikin wannan jeri. A ƙasa akwai misali na amfani da algorithm na bincike mai yawa a cikin PHP:
function findMultiplesOfThree($numbers) {
$result = array();
foreach($numbers as $number) {
if($number % 3 === 0) {
$result[] = $number; // Add the satisfying number to the result list
}
}
return $result;
}
$numbers = array(9, 4, 15, 7, 12, 6);
$multiplesOfThree = findMultiplesOfThree($numbers);
echo "Numbers that are multiples of 3 in the list are: ";
foreach($multiplesOfThree as $number) {
echo $number. ";
}
A cikin wannan misali, findMultiplesOfThree
aikin yana ƙara ta kowace lamba a lissafin. Idan lambar tana da rabe-rabe da 3(yana da ragowar 0 idan aka raba ta 3), ana ƙara shi zuwa lissafin sakamako. A ƙarshe, jerin sakamakon zai ƙunshi lambobi 9, 15, da 12, waɗanda za a buga su akan allo.
Don haka, algorithm na bincike da yawa a cikin PHP yana taimaka mana samun sauƙi da aiwatar da duk maƙasudin da suka gamsar da yanayin da aka bayar a cikin saitin bayanai.