アルゴリズムとプログラミング
- アルゴリズム:問題を解くための手順(料理のレシピに相当)
- 整列アルゴリズム:バブルソート(単純・低速)・クイックソート(高速)
- 探索:線形探索(1件ずつ確認)・2分探索(ソート済みリストで半分ずつ絞り込む)
- 流れ図(フローチャート):アルゴリズムを図で表現する
An algorithm is a step-by-step recipe to solve a problem. Follow the steps, get the result — every time.
- Bubble sort — repeatedly swap neighbours if out of order. Simple but slow for large lists.
- Binary search — to find a name in a sorted list: check the middle. Too early alphabetically? Search the second half. Too late? Search the first half. Repeat. Very fast.
- Flowchart — a diagram using boxes and arrows to show algorithm steps visually.
Algorithm သည် ပြဿနာဖြေရှင်းရန် အဆင့်ဆင့်ညွှန်ကြားချက်ဖြစ်သည် — ချက်ပြုတ်နည်းကဲ့သို့ လိုက်နာပါ၊ ရလဒ်ရသည်။
- Bubble sort — ကပ်လျက်ရှိသော item များ မှားနေလျှင် ဖလှယ်ကာ ကြိမ်ဖန်များစွာ ဆောင်ရွက်သည်။ ရိုးရှင်းသော်လည်း နှေးကွေးသည်။
- Binary search — စီထားသောစာရင်းတွင် အလယ်ကိုစစ်ဆေး၊ မမှန်ဘူးဆိုရင် တစ်ဝက်ကို ဖယ်ထုတ်ပြီး ထပ်စစ်ဆေးသည်။ မြန်ဆန်သည်။
Related Practice Questions
ဆက်စပ် လေ့ကျင့်ခန်းမေးခွန်းများ
What is the output when procedure calcMod3 is called? [Program] ○calcMod3() Integer: totalValue, i totalValue ← 0 for (i from 1 to 7, increment by 1) if (remainder of i ÷ 3 equals 0) totalValue ← totalValue + i endif endfor output totalValue
calcMod3 procedure ကို ခေါ်သောအခါ ထုတ်ပေးသော output မှာ အဘယ်နည်း? [Program] ○calcMod3() Integer: totalValue, i totalValue ← 0 for (i ကို 1 မှ 7 သို့ 1 စီ တိုးသည်) if (i ÷ 3 ၏ အကြွင်းသည် 0 နှင့် ညီ) totalValue ← totalValue + i endif endfor totalValue ကို ထုတ်ပြပါ
When sorting 4 elements in ascending order by repeating the procedure below, how many times is the series of steps (1)-(3) executed until sorting is complete? Data: [27, 42, 33, 12] (1) Find the maximum in the sort target and swap it with the last element. (2) Remove the last element from the sort target. (3) If one or more elements remain, execute (1)-(3) again; otherwise, sorting is complete.
အောက်ပါ လုပ်ငန်းစဉ်ကို ထပ်ခါတလဲလဲ ဆောင်ရွက်ကာ ဒြပ်စင် ၄ ခု ပါဝင်သော ဒေတာကို ascending order ဖြင့် စီစဉ်ရာ sorting ပြီးစီးသည်အထိ (1)-(3) လုပ်ဆောင်ချက်များ မည်မျှ ကြိမ် ဆောင်ရွက်ရမည်နည်း? ဒေတာ: [27, 42, 33, 12] (1) sort target တွင် အကြီးဆုံးတန်ဖိုးကို ရှာဖွေ၍ နောက်ဆုံးဒြပ်စင်နှင့် လဲလှယ်သည်။ (2) နောက်ဆုံးဒြပ်စင်ကို sort target မှ ဖယ်ရှားသည်။ (3) sort target တွင် ဒြပ်စင် တစ်ခုနှင့်အထက် ကျန်ရှိပါက (1)-(3) ကို ထပ်ဆောင်ရွက်သည်; မကျန်ပါက sorting ပြီးစီးသည်။
Function calculateAmountOfPrize receives improvement amount and time reduction as 'improvement' and 'period', returning the prize amount. There were two improvements: 200,000 yen/3 days and 50,000 yen/14 days. What is the total prize amount? [Program] ○Integer: calculateAmountOfPrize(Integer: improvement, Integer: period) Integer: prize if (improvement < 100000) if (period < 7) prize ← 500 else prize ← 1000 endif else if (period < 7) prize ← 2000 else prize ← 5000 endif endif return prize
calculateAmountOfPrize function သည် လုပ်ငန်း တိုးတက်မှုပမာဏ (improvement) နှင့် အချိန်တိုတောင်းမှုကာလ (period) ကို လက်ခံကာ ဆုကြေးငွေ ပြန်ပေးသည်။ တိုးတက်မှု ၂ ဦးရှိသည်: ကျပ် ၂၀၀,၀၀၀ / ၃ ရက် နှင့် ကျပ် ၅၀,၀၀၀ / ၁၄ ရက်။ ဆုကြေးငွေ ပေါင်းစုစုမျှ မည်မျှနည်း? [Program] ○Integer: calculateAmountOfPrize(Integer: improvement, Integer: period) Integer: prize if (improvement < 100000) if (period < 7) prize ← 500 else prize ← 1000 endif else if (period < 7) prize ← 2000 else prize ← 5000 endif endif return prize