Code

September 5, 2023

Introduction to Data Structure and Algorithm

Introduction to Data Structure and Algorithm

       Data Structure and Algorithm ဆိုတဲ့ဘာသာရပ်က ကျွန်တော် NCC lv 4, industry နဲ့ academic ဆိုပြီး diploma နှစ်ခုပြိုင်တက်ခဲ့တုန်းက industry ဘက်မှာပါခဲ့တဲ့ subject တခုပါ။ ‌ဒီ content ကို ရှည်လို့ part 1 နဲ့ part 2 ခွဲထားပါတယ်။ Part 1 မှာတော့ Data structures တွေအကြောင်းပြောသွားမှာဖြစ်ပြီး Part 2 မှာတော့ algorithms တွေအကြောင်းပြောသွားမှာပါ။ ဒီ content ဟာ “Data Structure and Algorithm” ဆိုတဲ့ဘာသာရပ်ကြီးရဲ့ intro လောက်ပဲ cover လုပ်သွားမှာပါ။ ဒီ ဘာသာရပ်က ကျယ်ပြန့်တဲ့အတွက် content series လေးတခုလောက်နဲ့အကုန် cover မလုပ်နိုင်ပါဘူး။ ဒါပေမယ့် ဒီ content ဖတ်ပြီးရင်တော့ ဒီဘာသာရပ်နဲ့ပတ်သက်ပြီး ဘာတွေကို deep dive လုပ်ရမလဲသဘောပေါက်သွားပါလိမ့်မယ်။

Introduction

          Data Structure and Algorithm(DSA) ဟာ computer science ရဲ့ foundation ပါပဲ။ သင်ဟာ ဘယ် language ပဲရွေးချယ်ရွေးချယ် ဒီ data structures တွေ၊ ဒီ algorithms တွေကနေပြေးမလွတ်ပါဘူး။ ဒါကြောင့်လဲ ဒီဘာသာရပ်ဟာ programmer or developer တယောက်အနေနဲ့ career စတော့မယ်ဆိုရင် မဖြစ်မနေလေ့လာသင့်တဲ့ ဘာသာရပ်တွေထဲကတခုဖြစ်နေတာပါ။ CS student ဆိုရင်ပိုတောင်ဆိုးပါသေးတယ် မဖြစ်မနေသိထားရမယ့် ဘာသာရပ်ပါ။

What is Data Structure?

          Data Structure ဆိုတာ data ကို efficient ဖြစ်ဖြစ် အသုံးချဖို့ ဘယ်လို သိမ်းဆည်း မလဲဆိုတဲ့ နည်းတမျိုးပါပဲ။ အလွယ်ပြောရရင်တော့ program တခုထဲမှာ data တွေကို ဘယ်လို store and organize လုပ်ပြီး၊ အဲ့ data တွေကို ဘယ်လို manipulate လုပ်မယ်ဆိုပြီး သတ်မှတ်ထားတဲ့ နည်းပေါ့။ Data Structures တွေကအများကြီးရှိပါတယ်။ တခုနဲ့တခု လုပ်ဆောင်ရတဲ့ task မတူတဲ့အလျောက်၊ တခုချင်းစီမှာ unique ဖြစ်တဲ့ characteristics တွေရှိပါတယ်။

Common Data Structures

          အောက်မှာတော့အသုံးများတဲ့ data structures တွေကို အကျဉ်းချုပ်ဖော်ပြပေးထားပါတယ်။ Programmer တယောက်လုပ်တော့မယ်ဆို အနည်းဆုံး ဒါတွေနဲ့ familiar အောင်လုပ်ထားသင့်ပါတယ်။

Array

          Array ကဝောာ့ programmer တွေ တော်တော်များများနဲ့ရင်းနှီးမယ်ထင်ပါတယ်။ Fundamental အကျဆုံး data structure ဆိုလဲမမှားပါဘူး။ Array ကို data type တူတဲ့ data တွေကို တနေရာထဲမှာ sequence အလိုက် store လုပ်ဖို့အတွက် သုံးပါတယ်။ ရထားတွဲကြီးလို့သတ်မှတ်လိုက်ပေါ့။ အဲ့ရထားတွဲကြီးမှာ နဂိုကသတ်မှတ်ထားတဲ့ အခန်းအရေအတွက်ပါတယ်။ အဲ့အခန်းတွေမှာ data တွေကို store လုပ်မယ်။ အခန်းနံပါတ် တွေကို programming term နဲ့ဆိုရင်တော့ index လို့ခေါ်ပါတယ်။ တခုသတိထားရမှာက index က 0 ကနေစပါတယ်။ အခန်းတခုစီမှာပါ၀င်တဲ့ data တွေကို index နဲ့ access လုပ်လို့ရပြီး၊ array function တွေနဲ့ manipulate လုပ်လို့ရပါတယ်။ Array function တွေကလဲအများကြီးပါပဲ။ Push, pop, reverse, length, forEach စသဖြင့် အဲ့ function တွေကအသုံးများပါတယ်။ Array တွေဟာ ပုံမှန် one dimensional array အပြင် multidimensional arrays တွေလဲရှိပါတယ်။ ဒါပေမယ့် two dimensional လောက်ပဲသုံးတာများပါတယ်။

String

          String ကိုဝောာ့ မသိတဲ့ programmer မရှိလောက်ပါဘူး။ String ဟာ သူရဲ့ characters တွေကို sequence အလိုက်သိမ်းဆည်းတဲ့ structure အရ data structure တွေထဲကတခုအနေနဲ့သတ်မှတ်ပါတယ်။ အလွယ်ပြောရရင်တော့ string က one dimensional array ပါပဲ။

Linked List

          Linked list ဟာ array လို linear data structure တခုပါပဲ။ ဒါပေမယ့် array နဲ့မတူတာက linked list ဟာ dynamic ဖြစ်ပါတယ်။ နောက်ပြီး linked list မှာ nodes တွေလဲပါပါတယ်။ node တခုချင်းစီထဲမှာ data နဲ့ pointer ပါပါတယ်။ အဲ့ pointer နဲ့ သူ့အနောက်က node ကို link လုပ်ပါတယ်။

Singly Linked List

          Singly linked list တွေမှာဆိုရင် node တခုစီမှာ pointer တခုပါ၀င်ပြီး နောက်က node ကို link လုပ်ထားပါတယ်။ အဲ့လို link လုပ်ခြင်းအားဖြင့် uni-directional chain ဖြစ်လာစေပါတယ်။ ဒါကြောင့်မို့ singly linked list တွေဟာ direction တခုပဲ traverse လုပ်နိုင်ပါတယ်။

Doubly Linked List

          Doubly linked list တွေမှာဆိုရင် node တခုစီမှာ pointers နှစ်ခုပါပါတယ်။ Pointer တခုက အရှေ့က node ကို link လုပ်ပြီး၊ ကျန် pointer က အနောက်က node ကို link လုပ်ခြင်းအားဖြင့် bi-directional chain ကိုဖြစ်ပေါ်စေပါတယ်။ ဆိုလိုချင်တာက doubly linked list မှာ nodes တွေက အရှေ့ကော၊အနောက်ကောချိတ်ဆက်ထားတဲ့အတွက် direction နှစ်ခုလုံး traverse လုပ်လို့ရပါတယ်။

Circular Linked List

          Circular linked list ဟာဆိုရင် doubly linked list လိုပါပဲ။ မတူတာကတော့ circular linked list မှာ နောက်ဆုံး node(tail) ဟာ ရှေ့ဆုံး node(head) နဲ့ link လုပ်ထားခြင်းဖြင့် closed loop တခုဖြစ်လာပါတယ်။

Note: Linked list တွေဟာ dynamic data structure တွေဖြစ်တဲ့အတွက် array ထက် efficient ပိုဖြစ်တယ်ဆိုပေမယ့် random access time မှာဆိုရင်တော့ head to tail traverse လုပ်ရတဲ့အတွက် array ထက်ပိုနှေးပါတယ်။

Queue

          Queue က First-In-First-Out(𝗙𝗜𝗙𝗢) principle ကိုအသုံးပြုထားတဲ့ linear data structure တခုဖြစ်ပါတယ်။ ဆိုလိုချင်တာက head ကနေ ပထမဆုံး စထည့်လိုက်တဲ့ data က၊ tail ကနေ ပထမဆုံး ထွက်လာပါလိမ့်မယ်။ ရုပ်ရှင်ရုံမှာ ticket တန်းစီသလိုပေါ့။ အရင်ဆုံး

တန်းစီတဲ့လူက အရင်ဆုံး ticket ၀ယ်ပြီး queue ကနေအရင်ဆုံးထွက်သွားမှာပါ။

Queue မှာ enqueue နဲ့ dequeue ဆိုပြီး operations နှစ်ခုရှိပါတယ်။ Tail ကနေ data ထည့်တာကို enqueue လို့ခေါ်ပြီး head ကနေ data ထုတ်တာကို dequeue လို့ခေါ်ပါတယ်။ Web development အပိုင်းမှာဆိုရင်တော့ queue ကို server ထဲမှာ requests တွေ handling လုပ်တဲ့နေရာမှာသုံးပါတယ်။

Stack

          Stack ကတော့ Last-In-First-Out(𝗟𝗜𝗙𝗢) principle ကိုသုံးတဲ့ linear data structure ပါ။ ဆိုလိုချင်တာက top ကနေ နောက်ဆုံးထည့်လိုက်တဲ့ data က အရင်ပြန်ထွက်လာမှာပါ။ တဖက်ပိတ်စလင်ဒါ တခုထဲမှာ ပန်းကန်တွေဆင့်ပြီး သိမ်းသလိုပါပဲ။ နောက်ဆုံးမှထည့်လိုက်တဲ့ကောင်က ထိပ်ဆုံးမှာရှိနေမှာဖြစ်တဲ့အတွက် ပြန်ထုတ်ရင် အဲ့ကောင်ကနေပဲ ပြန်ထုတ်ရမှာပါ။

Stack မှာလဲ push နဲ့ pop ဆိုပြီး operations နှစ်ခုရှိပါတယ်။ Top ကနေ data ထည့်လိုက်တာကို push လို့ခေါ်ပြီး top ကနေ data ပြန်ထုတ်တာကို pop လို့ခေါ်ပါတယ်။

Note: Queue ကော၊ stack ကော array or linked list သုံးပြီး implement လုပ်လို့ရပါတယ်။

Tree

          Tree ဟာ hierarchical data structure အသုံးပြုထားတဲ့ data structure တခုပါ။ Tree data structure ကို nodes တွေ တခုနဲ့တခု ချိတ်ဆက်ပြီး တည်ဆောက်ထားတာဖြစ်ပါတယ်။ သစ်ကိုင်းတွေကိုပြေးမြင်လိုက်ပါ။ ပထမဆုံး root node ကနေ nodes နှစ်ခုထွက်လာမယ်၊ အဲ့ nodes နှစ်ခုကနေတဆင့် သစ်ကိုင်းတွေဖြာထွက်သလိုပုံစံနဲ့ တခုနဲ့ တခု ချိတ်ဆက်ပြီး tree structure ဖြစ်လာတာပါ။ Hierarchical data structure ဖြစ်တဲ့အတွက် root node ကြီးကလွဲရင် ကျန်တဲ့ node တွေမှာ parent-child relationship ရှိပါတယ်။

Tree data structure မှာတွေ့ရတတ်တဲ့ node တွေ‌ကတော့

Root Node

Parent Node

Child Node

Sibling Node

Leaf Node

Internal Node

စတာတွေပဲဖြစ်ပါတယ်။

Heap

          Heap က specialized လုပ်ထားတဲ့ tree-based data structure တခုဖြစ်ပါတယ်။ Binary heap အနေနဲ့အတွေ့များပါတယ်။ Heap မှာ min-heap နဲ့ max-heap ဆိုပြီးနှစ်မျိုးရှိပါတယ်။ Min-heap မှာဆိုရင် parent node ဟာ child nodes တွေထက် value ပိုနည်းပြီး၊ max-heap မှာဆိုရင်တော့ parent node ဟာ child nodes တွေထက် value ပိုများပါတယ်။ ရှင်းအောင်ပြောရရင်တော့ tree data structure လိုပါပဲ၊ ဒါပေမယ့် min-heap or max-heap ပေါ်မူတည်ပြီး root ကနေ branches တွေအထိ values တွေဟာ ငယ်စဉ်ကြီးလိုက် or ကြီးစဉ်ငယ်လိုက်ကွဲသွားပါလိမ့်မယ်။

Hash Table

          Hash table(Hash map) ဆိုတာ key-value pairing ကိုသုံးပြီး store လုပ်တဲ့ data structure တခုဖြစ်ပါတယ်။ မျက်လုံးထဲမြင်အောင်ပြောရရင်တော့ keys တွေရယ်၊ hash table ရယ်ရှိမယ်၊ hash table ထဲမှာ values တွေနဲ့ အဲ့ values တွေရဲ့ index တွေပါမယ်။ Values တွေကို access လုပ်ဖို့ အဲ့ values တွေရဲ့ index တွေနဲ့၊ သက်ဆိုင်တဲ့ key တခုချင်းစီကို hash function သုံးပြီး map လုပ်ထားတယ်။ အဲ့တာကြောင့်လဲ key-value pairing လို့ခေါ်တာပါ။

Graph

          Graph data structure ဟာ nodes တွေ edges တွေနဲ့ တည်ဆောက်ထားတဲ့ non-linear data structure တခုဖြစ်ပါတယ်။ Nodes တွေကို vertices တွေလို့လဲခေါ်ပြီး edges တွေကတော့ အဲ့ nodes တွေကို တခုခုနဲ့ချိတ်ဆက်ပေးထားတဲ့ line တွေပဲဖြစ်ပါတယ်။ Graph တွေကို data points တွေကြားထဲက connections နဲ့ relationships တွေကိုဖော်ပြဖို့သုံးပါတယ်။ Graph မှာလဲ directed graph, indirected graph, weighted graph, acyclic graph စသည်ဖြင့် အမျိုးအစားအများကြီးရှိပါသေးတယ်။ Graph တွေဟာ complex ဖြစ်တဲ့ problems တွေကို solve လုပ်ဖို့အလွန်အရေးပါပါတယ်။ Social networks(e.g. Facebook)၊ recommendation systems၊ နောက်ဆုံး search engines တွေကအစ graph data structure ကိုအသုံးပြုထားတာပါ။

What is Algorithms?

          Algorithms တွေဆိုတာ ကျွန်တော်တို့နေ့စဉ်သုံးစွဲနေတဲ့ software တွေ၊ app တွေ ကောင်းကောင်းအလုပ်လုပ်ဖို့အတွက် အဓိကျတဲ့ အခရာပါ။

Algorithm ကို အဓိပ္ပါယ်ဖွင့်ရမယ်ဆိုရင် အလုပ်တခုပြီးမြောက်ဖို့ သို့မဟုတ် problem တခုကို ဖြေရှင်းဖို့ သတ်မှတ်ထားတဲ့ step-by-step procedure တခုပါ။ Simple math calculation ကနေပြီး machine learning အထိ ရိုးရှင်းလှတဲ့ algorithms တွေလဲရှိသလို၊ complex ဖြစ်တဲ့ algorithms တွေလဲများစွာရှိပါတယ်။

Key Components of a Program

          Algorithm အကြောင်းမပြောခင်မှာ program တခုမှာ ပါ၀င်တဲ့ basic components သုံးခုအကြောင်းပြောပြချင်ပါတယ်။ Program တခုမှာအခြေခံအားဖြင့် input, algorithm နဲ့ output ဆိုပြီး components သုံးခုပါ၀င်ပါတယ်။

Input

          Algorithm တခုကို perform လုပ်ဖို့အတွက် အနည်းဆုံး input တမျိုးမျိုးလိုပါတယ်။ အဲ့ဒီ input တွေကို variables တွေ၊ data structures တွေထဲ store လုပ်ပါတယ်။ Input တွေဟာ pre-insert or user input ဆိုပြီးကွဲပြားနိုင်ပါတယ်။

Algorithm

          Algorithm ကတော့ အပေါ်ကရှင်းပြခဲ့တဲ့အတိုင်းပါပဲ၊ problem တခုကို solve လုပ်ဖို့ ဒါမှမဟုတ် အလုပ်တခုပြီးမြောက်ဖို့ သတ်မှတ်ထားတဲ့ step-by-step set of rules တွေပဲဖြစ်ပါတယ်။

Output

          Algorithm တခုကနေ ထွက်လာတဲ့ calculated results တွေကို output လို့ခေါ်ပါတယ်။ Algorithm နဲ့ input တွေပေါ်မူတည်ပြီး output အမျိုးမျိုးကွဲပြားနိုင်ပါတယ်။

Key Components of a Algorithm

          Algorithm တခုမှာ အခြေခံအားဖြင့် ဒါတွေပါ၀င်ပါတယ်။

Variable

          User input ဒါမှမဟုတ် pre-insert လုပ်ထားတဲ့ input တွေ၊ resulted output တွေကို store လုပ်ဖို့ variables တွေကို သုံးပါတယ်။

Data Structure

         Data တွေကို store လုပ်ဖို့ variables တွေနဲ့ပဲအမြဲမလုံလောက်ပါဘူး။ Data တွေကို organize လုပ်ဖို့နဲ့ ပိုပြီး efficient ဖြစ်ဖြစ် store လုပ်ဖို့ data structures တွေကိုအသုံးပြုပါတယ်။

Operation

          Operation ဆိုတာ data တွေကိုအသုံးပြုပြီးလုပ်ဆောင်တဲ့ simple calculations တွေ၊ basic actions တွေကိုခေါ်ပါတယ်။ ဒီ operations တွေကို operators တွေ အသုံးပြုပြီးလုပ်ဆောင်ပါတယ်။

Operators တွေအများကြီးရှိပါတယ်။ 𝗔𝗿𝗶𝘁𝗵𝗺𝗲𝘁𝗶𝗰 𝗼𝗽𝗲𝗿𝗮𝘁𝗼𝗿𝘀 (eg. +, -, *, /, ^, %, etc.), 𝗿𝗲𝗹𝗮𝘁𝗶𝗼𝗻𝗮𝗹 𝗼𝗽𝗲𝗿𝗮𝘁𝗼𝗿𝘀 (eg. <, >, <=, >=, ==, !=, etc.), 𝗹𝗼𝗴𝗶𝗰𝗮𝗹 𝗼𝗽𝗲𝗿𝗮𝘁𝗼𝗿𝘀 (eg. &&, ||, etc.), 𝗮𝘀𝘀𝗶𝗴𝗻𝗺𝗲𝗻𝘁 𝗼𝗽𝗲𝗿𝗮𝘁𝗼𝗿 (=), 𝗰𝗼𝗻𝗱𝗶𝘁𝗶𝗼𝗻𝗮𝗹 𝗼𝗽𝗲𝗿𝗮𝘁𝗼𝗿 (?), 𝘂𝗻𝗮𝗿𝘆 𝗼𝗽𝗲𝗿𝗮𝘁𝗼𝗿𝘀 (eg. -x, !y, etc.) စတာတွေကတော့ အသုံးအများဆုံး operators တွေပဲဖြစ်ပါတယ်။ Operators တွေကို သုံးချင်တိုင်းလဲသုံးလို့မရပါဘူး၊ သူ့ order နဲ့သူရှိပါတယ်။

Control Structure

          Default အရဆို code တွေကို top to bottom and left to right direction နဲ့ execute လုပ်ပါတယ်။ ကျွန်တော်တို့ဟာ ဒီ flow ကိုပြောင်းချင်တဲ့ အခါမှာ control structures တွေကိုအသုံးပြုပါတယ်။ 𝗖𝗼𝗻𝗱𝗶𝘁𝗶𝗼𝗻𝗮𝗹 𝘀𝘁𝗮𝘁𝗲𝗺𝗲𝗻𝘁𝘀 (eg. if else, switch case, etc.), 𝗥𝗲𝗽𝗲𝘁𝗶𝘁𝗶𝗼𝗻 𝘀𝘁𝗮𝘁𝗲𝗺𝗲𝗻𝘁𝘀 (eg. for loop, while loop, do-while loop, etc.), 𝗝𝘂𝗺𝗽 𝘀𝘁𝗮𝘁𝗲𝗺𝗲𝗻𝘁𝘀 (eg. break, continue, etc.) စတာတွေဟာ control structures တွေပဲဖြစ်ပါတယ်။ Recursive functions တွေနဲ့ iterate လုပ်လို့ရတာကြောင့် functions တွေကိုလဲ control structure တွေထဲကတခုလို့ သတ်မှတ်လို့ရပါတယ်။

Function

          Function ဆိုတာ သင့်ရဲ့ program ထဲက mini program လေးတခုပါပဲ။ အပေါ်က ဖော်ပြခဲ့တဲ့ အရာတွေကိုအသုံးပြုပြီး function တခုတည်ဆောက်နိုင်ပါတယ်။ Functions တွေဟာ variables တွေကို parameters တွေအနေနဲ့ လက်ခံပြီး၊ output ကို return values အနေနဲ့ပြန်ထုတ်ပေးပါတယ်။ Return မပြန်ပဲ output direct ထုတ်ပေးတဲ့ functions တွေလဲရှိပါတယ်။ Functions တွေကိုအသုံးပြုခြင်းအားဖြင့် algorithm တခုဟာ ပိုပြီး readable ဖြစ်သလို၊ လိုအပ်တဲ့နေရာမှာ လိုသလိုခေါ်သုံးလို့ရတာကြောင့် efficient လဲဖြစ်ပါတယ်။

Error Handling

          Algorithm တခုမှာ error handling ကလဲမရှိမဖြစ်အရေးပါပါတယ်။ Input တွေဟာ ကျွန်တော်တို့ခန့်မှန်းထားတဲ့အတိုင်းလာမှာမဟုတ်ပါဘူး။ ဒါကြောင့်မို့လို့ unexpected input တွေအတွက် check လုပ်တာတွေ၊ error message ပြန်ထုတ်ပေးတာတွေ စသည်ဖြင့် လိုအပ်ပါတယ်။

Testing and Debugging

          အပေါ်ကအရာတွေအားလုံးလုပ်ပြီးသွားရင်တော့ ကိုယ်ရေးထားတဲ့ algorithm ဟာ output တွေမှန်မှန်ကန်ကန်ထုတ်ပေးရဲ့လား၊ error handling တွေသေချာလုပ်ရဲ့လား၊ ဘယ်နားမှာ error တွေရှိနေလဲ စသည်ဖြင့် testing သေချာလုပ်ပြီး၊ debug လုပ်ဖို့လိုပါတယ်။

Documentation

          Testing and Debugging လဲလုပ်ပြီးသွားပြီဆိုရင်တော့ ကိုယ့် algorithm ကို publish မလုပ်ခင် နောက်ဆုံးအဆင့်အနေနဲ့ documentation ရေးဖို့လိုပါတယ်။ ဒါမှ ကိုယ့် algorithm ကိုအသုံးပြုမယ့် တခြား developer တွေက ဒီ algorithm ဘယ်လိုအလုပ်လုပ်လဲ နားလည်မှာဖြစ်ပြီး အသုံးပြုနိုင်မှာပါ။ ကိုယ့် algorithm ကို တခြားလူတွေအသုံးပြုဖို့ ရည်ရွယ်တယ်ဆိုရင် သူများတွေနားလည်အောင် documentation ရေးပေးဖို့လိုပါတယ်။ တခြားလူတွေကိုလဲ အသုံးပြုစေချင်တယ် documentation လဲပါမလာဘူးဆိုရင်တော့ အလကားပါပဲ။

ဒါ‌တွေဟာ algorithm တခု တည်ဆောက်ဖို့လိုအပ်တဲ့ အခြေခံအချက်တွေပါ။ ဒါတွေနဲ့ တည်ဆောက်ထားရုံနဲ့ algorithm ကောင်းတခုဖြစ်ပြီလို့ ပြောလို့မရသေးပါဘူး။

What is a Good Algorithm?

          Algorithm ကောင်းတခုဖြစ်ဖို့ဆို ဒါတွေလိုအပ်ပါတယ်။

Correctness

          Algorithm ကောင်းတခုဟာ သင့်တော်တဲ့ input တိုင်းအတွက် မှန်ကန်တဲ့ output ပြန်ထုတ်ပေးဖို့လိုပါတယ်။

Efficiency

          Algorithm ကောင်းတခုဟာ efficient ဖြစ်ဖို့လိုပါတယ်။ Efficient ဖြစ်တယ်ဆိုတာ resources နည်းနည်းနဲ့ အလုပ်ပြီးမြောက်တာကို ဆိုလိုတာပါ။ Algorithm တခုအတွက်အဲ့ resources တွေဆိုတာ ကုန်သွားမယ့် အချိန်(time complexity) နဲ့ အသုံးပြုမယ့် memory (space complexity) တွေဖြစ်ပါတယ်။ Algorithm တခု efficient ဖြစ်မဖြစ်၊ Big O notation ကို အသုံးပြုပြီး time and space complexity ကို တွက်ချက်၍ သိနိုင်ပါတယ်။

Simplicity

          Algorithm ကောင်းတခုဟာ simple ဖြစ်ပြီး easy-to-understand ဖြစ်ရပါမယ်။ ရိုးရှင်းတဲ့ algorithm တခုဟာ ကိုယ်ကိုတိုင်အတွက် maintenance လုပ်ဖို့လွယ်ရုံသာမက ကိုယ့် algorithm ကိုအသုံးပြုမယ့် တခြား developer တွေအတွက်လဲ ပိုပြီး အဆင်ပြေစေပါတယ်။

          ဒီသုံးခုဟာ algorithm ကောင်းတခုဖြစ်ဖို့လိုအပ်တဲ့ အဓိက အချက်သုံးချက်ဖြစ်ပြီး၊ ဒါတွေအပြင် robustness, optimality, scalability, security စသည်ဖြင့် အများကြီးကျန်ရှိပါသေးတယ်။ အပေါ်ကဖော်ပြခဲ့တဲ့အရာတွေအကုန်လုံးဟာ algorithm နဲ့ပတ်သက်တဲ့ အခြေခံသဘောတရားတွေပဲဖြစ်ပါတယ်။ Algorithm ဆိုတာ ဘာလဲ၊ algorithm တခုမှာဘာတွေပါ၀င်လဲ၊ algorithm တခုကို ဘာတွေနဲ့တည်ဆောက်ထားလဲ၊ algorithm ကောင်းတခုဖြစ်ဖို့ဘာတွေလိုအပ်လဲဆိုတာ အခြေခံလောက်တော့ နားလည်သွားမယ်ထင်ပါတယ်။

0
1
2
3
4
5
6
7
8
9
0
0
1
2
3
4
5
6
7
8
9
0
0
1
2
3
4
5
6
7
8
9
0
%