• Like
  • Save
Lecture915
Upcoming SlideShare
Loading in...5
×
Uploaded on

 

More in: Technology , Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
222
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
0
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Ìýäýýëëèéí ñèñòåì, àëãîðèòìèéí ¿íäýñ Ëåêö ¹15
  • 2. Àãóóëãà 1. Ðåêóðñèâ ôóíêö 2.Ðåêóðñèâ àëãîðèòì
  • 3. Ðåêóðñèâ ôóíêö áà äýä àëãîðèòì Ôóíêöèéã òîäîðõîéëîõäîî ò¿¿íèéã ººðèéã íü àøèãëàñàí áàéâàë óã ôóíêöèéã ðåêóðöèâ ôóíêö ãýíý.
  • 4. Æèøýýëáýë: 1 ,õýðýâ n  0 x n  (1) x  x n-1 ,õýðýâ n  2 1 , õýðýâ n  0 P n (x)  x , õýðýâ n  1 (2) (2n-1)  x  P n-1 (x)  (n  1)  P n  2 (x) , õýðýâ n  2 n
  • 5. ôóíêö¿¿äýä ðåêóðñèâ ôóíêö þì. Òóõàéëáàë (2) òîìü¸íä P n (x) ôóíêö íü P n-1 (x)  P n-2 (x) õî¸ðîîð òîäîðõîéëîãäîæ áàéíà. Æèøýýëáýë : (2  2  1)  x  P 1 (x)  (2  1)  P 0 (x) 3  x  x  1  1 3x 2  1 P 2 (x)=   2 2 2 (2  3  1)  x  P 2 (x)  (3  1)  P 1 (x 5  x ((3x 2  1)/2)  2  x P 3 (x) 5x 3  3x   = 3 2 2
  • 6. Òîäîðõîéëîëò :Äýýä àëãîðèòì áîëîí ôóíêö ººðºº ººðòºº õàíääàã º.õ ºðºº ººðèé㺺 äóóäàæ àøèãëàäàã áîë ò¿¿íèéã ðåêóðñèâ àëãîðèòì ãýíý. Ðåêóðñèâ àëãîðèòìààð áîäîãäîõ àëèâàà áîäëîãî 1.Óã áîäëîãûã ò¿¿íòýé èæèë áîëîâ÷ ò¿¿íýýñ “õÿëáàð” áîäëãîîð ñîëüæ äàõèí òîäîðõîéëîõ áîëîìæòîé áàéõ.
  • 7. 2.Øèéä íü øóóä ìýäýãäýæ áàéõ ýñâýë ò¿¿íèéã øóóä áîäîæ îëîõ íýã þóìóó õýä õýäýí òîõèîëäë áàéõ (ýíý òîõèîëäîëûã óã áîäïîãûí ¿íäýñ òîõèîëäîë ãýíý.) 3.Õÿëáàð áîäëîãîîð ñîëèõ ïðîöåññèéã äàâòàæ õýðýãëýõýä óã áîäëîãî ò¿¿íèé ¿íäñýí òîõèîëäîëä çààâàë õ¿ðäýã áàéõ
  • 8. 4.¯íäñýí òîîõèîëäëûí øèéäèéã àøèãëàí àíõíû áîäëîãûí øèéäèéã îëæ áîëäîã áàéõ .ãýñýí äºðâºí îíöëîã øèíæòýé áàéäàã. ¯¿íä: • Õÿëáàð áîäëîãîíä äàâòàí øèëæèõ ïðîöåññèéã òºãñãºõ íºõöºë áîëíî.
  • 9. .¯íýíäýý øóóä òîäîðõîéëëîãäñîí ¿íäñýí òîõèîëäîë áàéõã¿é áîë ðåêóðñèâ àëãîðèòì ººðºº ººðòºº òºãñãºëã¿é õàíäàõàä õ¿ðãýí • Àíõíû áîäëîãûí øèéäèéã áîäîæ ãàðãàõàä àøèãëàãäàõ ¿íäñýí íýãæ áîëíî.
  • 10. Æèøýý íü: n-íàòóðàë òîîíû ôàêòîðèàë (áóþó n!)-ûã áîäîõ ðåêóðñèâ ôóíêöèéã áè÷. 1 , õýðýâ n=0 n= n· (n-1)· (n-2)··· , õýðýâ n>0 Ôàêòîðèàëûí òîäîðõîéëîëò ¸ñîîð n!=n·(n-1)! ,õýðýâ n>0
  • 11. Èéìä ôàêòîðèàë ôóíêöèéã äàðààõ õýëáýðòýé áè÷íý. ôóíêö ôàêòîðèàë (íàò n íàò m ; õýðýâ n>0 áîë m:=n· ôàêòîðèàë (n-1) ýñâýë m:=1 áóö (m);
  • 12. Çàðèì áîäëîãûã ðåêóðñèâ áà ðåêóðñèâ áèø õî¸ð àëãîðèòìààð áîäîæ áîëäîã. Èéì ¿åä • Òóõàéí áîäëîãûí ïðîãðàììûí áèåëýõ õóðä • Àøèãëàõ ñàíàõ îéí õýìæýý çýðýãò òàâèõ øààðäëàãààñ õàìààðàí àëü àëãîðèòìûã õýðýãëýõýý ñîíãîæ àâàõ íü ç¿éòýé áàéäàã.
  • 13. Æèøýý íü: ñºðºã áèø õî¸ð á¿õýë òîîíû õàìãèéí èõ åðºíõèé õóâààã÷ (ÕÈÅÕ)-èéã îëîõ ðåêóðñèâ áè÷. ôóíêö õèåõ (íàò m,n) íàò k ; õýðýâ n=0 áîë k :=m ýñâýë k := õèåõ (n,m ); áóö(k);
  • 14. Äýýð áè÷ñýí ôóíêöèéí õÿëáàð áîëñîí õèåõ (n,m )óòãà øóóä õèåõ (m,n) ôóóíêöèéí óòãà áîëæ áàéíà. Íýãýí ñîíèó ÷ ýðäýìòýí ïëóòîíè, õàð òóãàëãàí ýðõèéã ñ¿âýëæ äîîðõ íºõöºëèéã õàíãàñàí “àþóëã¿é ãèíæ” èéõýýð øèéäæýý.
  • 15. ¯¿íä: • Õî¸ð ïëóòîíè ýðõè õààíà ÷ íýã äîð îðîõã¿é • Íýã ýëåìåíòèéí ýðõè íü õîîðîíäîî ÿëãààã¿é • Õî¸ð ýëåìåíòýýð õèéñýí ýðõè àëü àëü íü õ¿ðýöýýòýé • Ãèíæ¿¿ä íü òýäãýýðò îðñîí ýðõèíèé äàðààëëààð ÿëãàãäàíà. Ýíý ýðäýìòýí n(n>1 áàéõ ºãºäñºí òîî ) óðòòàé (n øèðõýã ýðõè îðñîí ) àþóëã¿é ãèíæèéã õýäýí ÿíçààð õèéæ áîëîõûã îë.