2

Yadda ‘Algorithm’ Yake Chanja Tunanin Mutum

Algorithm

Algorithm a kimiyyar na’ura da lissafi hanya ce saukakka da ke kai mutum wani mataki na warware wata matsalar kimiyya. Hanya a nan kan iya zama wata dama da muddin mutum ya bi ta daki-daki bisa ga yadda yake tunanin warware wannan matsalar domin dacewa da ka’idojinta.

Karanta: Yaya Ake Zama Developer?

Misali a kan iya cewa mutum ya kirkiri wata manhaja ta aika sako. To abunda zai fara yi shine bin matakan algorithm domin samun daidaitacciyar damar da zai iya kirkirar wanan manhaja, a inda kirkirar manhajar ita ce matsalar, dan haka warware matsalar shi ake kira “problem solving” Matakan algorithm da ake bi wajen warware matsala sune kamar haka:

1. Sanin matsalar – abunda ya kamata mutum ya sani da farko kuma yayi la’akari da shi shine sanin wacce iri ce matsalar, anan matsalarmu ita ce kirkirar manhajar tura sako.

2. Tsara yadda zai warware ta – yanzu sai kayi tunanin ta wacce hanya kake ganin za ka iya warware wannan matsala. Anan aikinmu shine kirkirar manhajar tura sako, dan haka za mu kirkire ta ne da yaren na’ura, sannan sai mu zabi wanne yare ne zai fi dacewa da ita.

3. Rubuta gundarin algorithm din – abu na gaba shine rubuta gundarin algorithm din. Ana so duk lokacin da mutum zai yi wannan aikin ya kasance ya tsara wato rubuta yadda algorithm dinsa zai kasance. Wannan kuma matakin da yake ba wa mutane da dama matsala saboda rashin fahimtar abunda yake nufi. Yanzu yadda matsalarmu ita ce kirkirar manhajar tura sako, abunda ake bukata mu yi a wannan mataki shine rubuta yadda za mu fara kirkirar manhajar, ta yaya mutum zai fara amfani da ita, waye zai karbi sakon, ta yaya zai karba da sauransu.

Misali a ce an bamu wani aiki mu kirkiri manhajar lissafi da za ta hada wasu lambobi kamar 2 da 8 da sauransu. To anan abunda za mu fara yi shine rubuta sunayen lambobin (wato inkiyarsu) da kuma lambobin kamar haka:

lambarTaFarko = 2

lambaTaBiyu = 8

Abunda ya rage yanzu shine rubuta sunan lambar da za ta hada wadannan lambonin – lambarTaFarko da lambaTaBiyu kamar haka:

jimilla = lambarTaFarko + lambaTaBiyu

Ka ga anan lambarTaFarko ita ce 2, sannan lambaTaBiyu ita ce 8, a inda jimilla za ta zama 10 daidai.

Dukka wannan lisafi shine tsara algorithm dinka. Wato kamar yadda muka yi a sama cewa mun hada wadannan lambobin guda biyu wadanda muka san da su. To idan kuma ba mu san da lambobin ba fa? Wato a ce mu hada manhajar da mutum da kansa zai rubuta lambobin da yake so ya hada.

Da farko za mu rubuta sunan lamba ta farko da ta biyu kamar haka:

lambaTaFarko = ?

lambaTaBiyu = ?

Yanzu tunda ba mu san lambobin ba sai mu yi wata hikima da za ta ba wa mutum damar shigar da lambobin da ya ke so da kuma yadda za mu gano lambobin har mu iya hada su wuri daya. Yanzu ga hikimar da za ta ba wa mutum damar shigar da lambobin:

lambaTaFarko = input(“Rubuta lamba ta farko: ”);

lambaTaBiyu = input(“Rubuta lamba ta biyu: ”);

Yanzu a ce wannan hikima ita za ta ba wa mutum damar shigar da lambobin guda biyu daban-daban. Yanzu kuma sai mu kara rubuta wata hikima da za ta gano wadanne lambobi aka shigar:

Scanner = scan.lambaTaFarko;

Scanner = scan.lambaTaBiyu;

Yanzu muna tunanin cewa wannan hikima za ta gano ma na wadanne lambobi aka shigar dan haka yanzu sai mu hada su mu gani:

jimilla = lambaTaFarko + lambaTaBiyu;

Watakila anan za mu iya samun sakamako mai kyau. Dan haka matukar mun zo wannan mataki sai mu yi kokarin aiwatar da fikirarmu ta algorithm zuwa yaren na’urar da mu ke so muyi amfani da shi wanda shine mataki na gaba.

4. Rubuta yaren na’ura – ana so a wannan matakin mutum ya zabi wanne yaren na’ura ne yafi dacewa da aikinsa, domin ba kowanne yare ne zai yi daidai da kowanne aiki ba. Misali a ce mu zabi yaren na’ura Python, ga yadda lamarin zai kasance: 

lambaTaFarko = int(input(“Rubuta lamba ta farko: ”))

lambaTaBiyu = int(input(“Rubuta lamba ta biyu: ”))

jimilla = lambaTaFarko + lambaTaBiyu

5. Gwaji – bayan ka gama rubuta yaren na’urar abunda yayi saura shine gwadawa ka ga yadda yake aiki. Ana so ka gwada shi ta kowace siga ka ga wacce irin matsala ce za ta biyo baya da kuma yadda za ka warware ta idan hakan ta faru. A wannan gwajin ana so ka ba wa wasu ma domin su gwada ta.

Duk wadannan matakai su ke sa mutum yayi tunani kan yadda zai warware wata matsala ta rayuwa ba ma ta na’ura kadai ba. A irin wannan yanayi ne mafi yawan lokuta ake cewa mai tsare-tsaren na’ura ya kan iya warware matsala a cikin kankanin lokaci fiye da kowane mutum. Yanayin yadda yake tunani mai zurfi ke sa shi kasancewa daban da sauran mutane wanda sanadiyyar hakan ta samo asali ne daga zana algorithm kafin kai wa ga rubuta gundarin tsari ko yaren na’urar.

Sauke wannan littafin “Program a Computer to Learn ‘How to Think’” domin samun damar karanta wasu matakai game da algorithm da kuma yadda za ka iya warware wata matsala.

Mohiddeen Ahmad

I am Muhammad Auwal Ahmad (Mohiddeen), a technologist and a writer. I Specifically write on sciences and modern technology. Hit my about page to learn more about me.

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *