├── README.md ├── articles ├── abstraction.md ├── avltree.md ├── bigO.md ├── binarysearch.md ├── binarytree.md ├── binarytree_operations.md ├── binarytree_traversals.md ├── divide&conquer.md ├── dynamicprogramming.md ├── fenwick.md ├── fenwick_construction.md ├── fenwick_pointupdate.md ├── greedy.md ├── hashtable-openaddressing-linearprobing.md ├── hashtable-openaddressing-quadraticprobing.md ├── hashtable-openaddressing.md ├── hashtable-removing-openaddressing.md ├── hashtable-separatechaining.md ├── hashtable_hashing.md ├── hastable-openaddressing-doublehashing.md ├── introduction.md ├── linkedlist.md ├── priority_queue.md ├── priority_queue_with_heap_part1.md ├── priority_queue_with_heap_part2.md ├── queue.md ├── sorting.md ├── stack.md ├── static-dynamic-arrays.md └── unionfind.md ├── assets ├── AVL tree │ ├── fig1.1 advantages of avl tree.png │ ├── fig2.1 tree rotation sample.png │ ├── fig2.2 tree rotation sample.png │ ├── fig2.3 tree rotation sample.png │ ├── fig2.4 tree rotation sample.png │ ├── fig3.1 avl tree example.jpg │ ├── fig3.2 avl_left_rotation.jpg │ ├── fig3.3 avl_right_rotation.jpg │ ├── fig3.4 left_right_rotation.png │ └── fig3.5 right_left_rotation.png ├── abstraction.png ├── big0.png ├── binary tree │ ├── Binary-Search.png │ ├── binary_tree.jpg │ ├── binarytree inorder traversal.png │ ├── binarytree insertion.png │ ├── binarytree levelorder traversal.png │ ├── binarytree postorder traversal.png │ ├── binarytree preorder traversal.png │ ├── binarytree removing case1.png │ ├── binarytree search.png │ ├── fig 1.binary tree removing case2and3.png │ ├── fig 1.binary tree removing case4.png │ ├── fig 2.binary tree removing case2and3.png │ ├── fig 2.binary tree removing case4.png │ ├── fig 3.binary tree removing case4.png │ └── fig 4.binary tree removing case4.png ├── dividenconquer │ └── dividenconquer.png ├── dynamicprogramming │ └── dynamicprogramming.png ├── fenwick(binary indexed tree) │ ├── fenwick tree construction.png │ ├── fenwick-point update.png │ ├── fig1. fenwick tree.png │ └── fig2. calculating range value.png ├── greedy │ └── Screen Shot 2019-08-10 at 6.54.15 PM.png ├── hashtable │ ├── hash function │ │ ├── fig1. hash function.png │ │ └── fig2. hash function.png │ ├── open addressing │ │ ├── Screen Shot 2019-08-26 at 11.25.04 AM.png │ │ ├── doublehashing.jpg │ │ ├── linear probing.png │ │ ├── quadratic probing.png │ │ └── removing.png │ └── separate chaining │ │ ├── fig1. insertion as linked list.png │ │ ├── fig1. selecting the node.png │ │ ├── fig2. insertion as linked list.png │ │ └── fig2. selecting the node.png ├── linked lists │ ├── doubly linked list inserting operation.png │ ├── doubly linked list.png │ ├── doubly linked removing operation.png │ ├── singly linked list inserting operation.png │ ├── singly linked list.png │ └── singly linked removing operation.png ├── priority queue with heap part 1 │ ├── fig 1. what is binary heap.png │ ├── fig 2. binary heap representation.png │ ├── fig 3. binary heap representation.png │ ├── fig 4.1. adding elements to binary heap.png │ ├── fig 4.2. adding elements to binary heap.png │ ├── fig 4.3. adding elements to binary heap.png │ ├── fig 4.4. adding elements to binary heap.png │ ├── fig 5.1 polling elements from binary heap.png │ ├── fig 5.2 polling elements from binary heap.png │ ├── fig 5.3 polling elements from binary heap.png │ ├── fig 5.4 polling elements from binary heap.png │ ├── fig 5.5 polling elements from binary heap.png │ ├── fig 5.6 polling elements from binary heap.png │ ├── fig 6.1 removing elements from binary heap with value parameter.png │ ├── fig 6.2 removing elements from binary heap with value parameter.png │ └── fig 6.3 removing elements from binary heap with value parameter.png ├── priority queue with heap part 2 │ ├── fig 1 heap data presentation with hashtable lookup.png │ ├── fig 2.1 inserting data using lookup.png │ ├── fig 2.2 inserting data using lookup.png │ ├── fig 2.3 inserting data using lookup.png │ ├── fig 2.4 inserting data using lookup.png │ ├── fig 3.1 removing data using lookup.png │ ├── fig 3.2 removing data using lookup.png │ ├── fig 3.3 removing data using lookup.png │ ├── fig 3.4 removing data using lookup.png │ ├── fig 4.1 polling data using lookup.png │ ├── fig 4.2 polling data using lookup.png │ └── fig 4.3 polling data using lookup.png ├── priority queue │ ├── what is a heap.png │ └── what is pq and its instruction.png ├── queue │ └── understanding queue │ │ ├── adding queue instruction.png │ │ ├── dequeue.png │ │ ├── enqueue.png │ │ ├── removing queue instruction.png │ │ └── whatisqueue.png ├── stacks │ ├── stack example 1.png │ ├── stack example 2.png │ ├── stack example 3.png │ ├── stack poping.png │ └── stack pushing.png ├── static & dynamic arrays │ ├── dynamic array.png │ └── static array.png └── union find │ ├── union find with magnet example 1.png │ ├── union find with magnet example 2.png │ ├── union find with magnet example 3.png │ └── union find with path compression.png └── datastructures&algorithms_v2.1.pdf /README.md: -------------------------------------------------------------------------------- 1 | ကျောင်းသားတွေပဲဖြစ်ဖြစ် လုပ်ငန်းခွင်ဝင်နေတဲ့ သူတွေပဲဖြစ်ဖြစ် data structure & algorithm နဲ့ပတ်သတ်တဲ့ စာတွေလေ့လာတဲ့ နေရာမှာ မြန်မာလို ဖတ်နိုင်လို့ရှိရင် ပိုနားလည်နိုင်မယ်လို့ယူဆရတဲ့အတွက် ဒီ repo ကိုဖန်တီးထားခြင်းဖြစ်ပါတယ်။ ကျနော်ကိုယ်တိုင်လည် လေ့လာနေရင်း sharing ပြန်လုပ်ပေးနေတာဖြစ်တဲ့အတွက် လိုအပ်ချက်တွေရှိခဲ့မယ်ဆိုရင် ဝင်ရောက်ဖြည့်စွက်ပေးနိုင်ပါတယ်ခင်ဗျ။ ကျေးဇူးတင်ပါတယ်။ 2 | 3 | ရေးပြီးသား ဆောင်းပါးတွေကို list လုပ်ပေးထားပါမယ်ခင်ဗျာ။ 4 | 5 | စာအုပ်ဒေါင်းလုပ်ချချင်ရင်တော့ datastructures_algorithm.pdf ဆိုတဲ့ file ကို download ယူနိုင်ပါတယ် 6 | 7 | Web development နဲ့ပတ်သတ်တဲ့ playlists, videos များကိုလည်း Youtube မှာဝင်ရောက်ကြည့်ရှုနိုင်ပါတယ်။
8 | https://bit.ly/3xtURtI 9 | 10 | #### Introduction 11 | http://bit.ly/2ms2eNC 12 | 13 | #### Abstraction 14 | http://bit.ly/2KHmwwh 15 | 16 | #### Big O Notation 17 | https://bit.ly/3whDZTs 18 | 19 | #### Static & Dynamic Array 20 | http://bit.ly/2MpGaii 21 | 22 | #### Linked Lists 23 | http://bit.ly/33LGBsA 24 | 25 | #### Stack 26 | http://bit.ly/2P6op9S 27 | 28 | #### Queue 29 | http://bit.ly/2Zg91eY 30 | 31 | #### Priority Queue 32 | http://bit.ly/30j7D8C 33 | 34 | #### Priority Queue with heap part 1 35 | http://bit.ly/2P2rx6M 36 | 37 | #### Priority Queue with heap part 2 (hash table) 38 | http://bit.ly/2Nfd5Wl 39 | 40 | #### Sorting 41 | http://bit.ly/2kVe1Ue 42 | 43 | #### Union Find 44 | http://bit.ly/2KIVx3u 45 | 46 | #### Greedy 47 | http://bit.ly/2KWFLAZ 48 | 49 | #### Divide & conquer 50 | http://bit.ly/2H8MIOb 51 | 52 | #### Dynamic programming 53 | http://bit.ly/2TJ6Rzq 54 | 55 | #### Binary tree 56 | http://bit.ly/2MpDLnX 57 | 58 | #### Binary tree's operation 59 | http://bit.ly/2YZiqIv 60 | 61 | #### Binary tress's traversal 62 | http://bit.ly/31L0oH1 63 | 64 | #### Binary search 65 | http://bit.ly/2KZCTDe 66 | 67 | #### Hash table (hashing) 68 | http://bit.ly/2NCd4MH 69 | 70 | #### Hash table (Separate Chaining) 71 | http://bit.ly/2KSdJaN 72 | 73 | #### Hash table (Open Addressing) 74 | http://bit.ly/2ZkEdL8 75 | 76 | #### Hash table (Open Addressing - Linear Probing) 77 | http://bit.ly/2ZCjbTx 78 | 79 | #### Hash table (Open Addressing - Quadratic Probing) 80 | http://bit.ly/2HDVYKe 81 | 82 | #### Hash table (Open Addressing - Double Hashing) 83 | http://bit.ly/2ktCQGr 84 | 85 | #### Hash table removing case via open addressing 86 | http://bit.ly/2lApN6w 87 | 88 | #### Fenwick tree (Binary Indexed Tree) 89 | http://bit.ly/2lDTvaO 90 | 91 | #### Fenwick tree (Point Update) 92 | http://bit.ly/2lQKLOn 93 | 94 | #### Fenwick Tree Construction 95 | http://bit.ly/2lMjI79 96 | 97 | #### AVL Tree 98 | http://bit.ly/2kMaXJR 99 | -------------------------------------------------------------------------------- /articles/abstraction.md: -------------------------------------------------------------------------------- 1 | ## Abstraction (Low Level Abstraction) 2 | 3 | ဟိုတစ်နေ့က YGN CODE က article တစ်ခုဖတ်ရင်းနဲ့ (https://www.ygncode.com/how-does-computer-work/) CS50 က Professor David J. Malan ပြောတဲ့ presentation တစ်ခုနားထောင်နေမိရင်းနဲ့ သဘောကျလို့ ကိုယ်နားလည်သလောက် ဘာသာပြန်ရင်း sharing ပြန်လုပ်ပေးလိုက်ပါတယ်။ ပြောသွားတဲ့ အကြောင်းအရာ ကတော့ Abstraction အကြောင်းကို ပြောသွားတာ။ 4 | 5 | Abstraction ဆိုတာ က ရှုပ်ထွေးတဲ့ အရာတစ်ခုကနေပြီးတော့ တစ်ဆင့်ခြင်းတစ်ဆင့်ခြင်းလွယ်ကူတဲ့ အခြေအနေတစ်ခု (နားလည်ရလွယ်ကူနိုင်တဲ့ အခြေအနေ) တစ်ခု အဖြစ် ခွဲထုတ်လိုက်တာမျိုးကိုဆိုလိုတာပါ။ ဥပမာ တစ်ခု အနေနဲ့ပြောရမယ်ဆိုရင် ကားတစ်စီး ဘယ်လိုအလုပ်လုပ်လဲဆိုတာ အသေးစိတ် ကျနော်တို့မသိဘူး၊ ဒီကားဘီး ကြီးကို ဘယ်လိုတွေလုပ်ထားလဲ၊ engine ကိုရောဘယ်လိုအစိတ်အပိုင်းတွေနဲ့ ဖွဲ့စည်းထားလဲ၊ ဒီကားတစ်ခုခု ပျက်သွားရင်ရော ဘယ်လိုပြင်မလဲ စသည်ဖြင့် အသေးစိတ်ကို ကျနော်တို့ မသိဘူး။ ဒါပေမဲ့ ဒီကားကို ကျနော်တို့ operate လုပ်တတ်တယ်၊ ဆိုလိုချင်တာ က ကားကို စက်နှိုးတတ်တယ်၊ မောင်းတတ်တယ်၊ ရပ်မယ်ဆို ဘာကို နင်းရမယ်၊ ဒီကားကို energy ဘယ်လို ပြန်ဖြည့်ရမယ်စသည်ဖြင့် ကျနော်တို့ Interfacing ပိုင်းကို ကောင်းကောင်းသိပြီး ကားကို အသုံးပြုနိုင်တယ်။ ဘာကြောင့်လဲ ဆိုတော့ abstract လုပ်လိုက်လို့ပဲ၊ ခက်ခက်ခဲခဲ ပိုင်းတွေကို အသေးစိတ် မစဉ်းစားတော့ ဘဲ ကားတစ်စီး ကို operate လုပ်နိုင်မယ့် Interface အပိုင်းကိုပဲ abstract လုပ်လိုက်တဲ့ အတွက် ကျနော်တို့ ကားကို လွယ်လင့်တစ်ကူ အသုံးပြုလို့ရသွားပါတယ်။ 6 | 7 | နောက်ထပ် ဥပမာတစ်ခု အနေနဲ့ပြောရရင် what is a country ဆိုပြီး filter လုပ်ကြည့်မယ်ဆို country ဆိုတာ states & divisions တွေစုထားတာ၊ states & divisions တွေဆိုတာ မြို့ နယ်တွေစုထားတာ ၊ မြို့ နယ်တွေ ဆိုတာ ရပ်ကွက်တွေ၊ ရပ်ကွက်တွေဆိုတာ အိမ်တွေစုထားတာ၊ အိမ်ဆိုတာ နံရံတွေပါတယ် အမိုးတွေပါတယ်၊ နံရံတွေဆိုတာ သစ်သားတို့ အုတ်တို့နဲ့ လုပ်ထားတာ စသည်ဖြင့် တစ်ဆင့် ခြင်း ဆီ filter လုပ်သွားလို့ရပါတယ်။ ဒါပေမဲ့ ကျနော်တို့တွေက ဒီလိုတွေ အောက်ခြေ အစကနေ ပြီးတော့ construct လုပ်ထားတဲ့အကြောင်းအရာတွေသိစရာမလိုဘူး။ နိုင်ငံလို့ပြောလိုက်ပြီဆိုလဲ နားလည်တယ်။ ရန်ကုန်တိုင်းလို့ပြောလိုက်ပြီ ဆိုလဲနားလည်ပါတယ်။ 8 | 9 | ထိုနည်းလည်းကောင်းပဲ computer မှာဆိုလို့ရှိရင်လဲ ကျနော်တို့ resource အနေနဲ့သူ့ကို ပေးရတာ power ပဲ ရှိတယ်။ ကျနော်တို့ ဒီ computer ကို Input အနေနဲ့ electricity တစ်ခုပဲ ပေးရုံနဲ့ နေ့စဉ်ကျနော်တို့လုပ်နေတဲ့ program ရေးတာတို့ design ဆွဲတာတို့ စသည်ဖြင့် complex ဖြစ်တဲ့ task တွေကို ဘယ်လိုလုပ်သွားလဲပေါ့။ ကျနော်တို့သိထားတာ က computer တွေက binary system နဲ့ အလုပ်လုပ်တယ်။ အိုကေ ဒါဆိုရင် Microsoft word, note software တွေမှာ HI ဆိုတဲ့ message ကို ရနိုင်ဖို့ decompose လုပ်မယ်ဆိုရင် binary system အရ အလုပ်လုပ်သွားတာက 01001000, 01001001။ အဲ့ဒါကို decimal system ကို convert လုပ်မယ်ဆို 72, 73 ရတယ်။ ဒီ decimal conversion အရဆိုလို့ရှိရင် Microsoft word တို့ notes တို့ လို software တွေမှာ HI ဆိုတဲ့ message ရတယ်။ Graphic software တွေ browser တွေမှာဆိုရင် 72 က အနီရောင်၊ 73 က အစိမ်းရောင်စသည်ဖြင့် သတ်မှတ်ထားပြီး mapping လုပ်ထားကြတယ်။ ဒါပေမဲ့လည်း ကျနော်တို့ ဒါတွေသိစရာမလိုဘူး HI ကဘယ်လို ဖြစ်လာတာလဲ color တွေဘယ်လိုထွက်လာလဲ စသည်ဖြင့် သိစရာမလိုဘူး။ ကျနော်တို့က တစ်ကယ့် work done ဖြစ်တာကိုပဲလိုချင်တဲ့အတွက် low level abstraction လုပ်ပြီးတော့ အသုံးပြုနေကြတာပါ။ 10 | 11 | ဆိုတော့ abstraction က ဘယ်လောက်အရေးပါတယ် ဆိုတာတော့ သိလောက်ပြီထင်ပါတယ်။ Abstraction မရှိရင်လဲ ကျနော်တို့ရဲ့ daily operation တွေမှာ တော်တော်အခက်အခဲ တွေ့မှာကျိန်းသေပါတယ်။ 12 | 13 | ဒါပေမဲ့ လည်း computer science ကို လေ့လာတဲ့သူတွေအတွက် abstraction ဘယ်လိုလုပ်သွားလဲဆိုတာ အရေးပါတဲ့ အကြောင်းကို stage presentation တစ်ခုနဲ့ prove လုပ်ပြသွားတယ်။ 14 | ဘာလိုလဲဆိုတော့ stage အောက်က လူတွေကို ကုဗတုံးပုံဆွဲခိုင်းတာ ဒါပေမဲ့ကုဗတုံးလို့ အစက မပြောဘူး၊ မျဉ်း တစ်ကြောင်းဆွဲပါ၊ ပြီးရင် ညာဘက်ကိုဆက်ဆွဲ၊ ဘယ်လို ဘယ်ပုံ ဆိုပြီး တော့ တစ်ဆင့်ခြင်းဆီ instruction ပေးသွားတယ်။ Instruction ပြီးသွားတဲ့ အချိန်မှာ အကုန်လုံးလိုလို က ကုဗတုံးလိုလို ပုံစံတွေထွက်တယ်၊ တစ်ချို့ ဆို ကွက်တိပုံအတိုင်းထွက်တယ်။ 15 | 16 | ဒီ scenario က ဘာကိုဆိုလိုချင်တာလဲဆိုတော့ ကုဗတုံးတစ်ခုကို ဘယ်လိုဆွဲရမလဲဆိုတဲ့ ဆွဲပုံဆွဲနည်း (high level instruction) ကို မသိဘူးဆိုရင် ကိုယ်က လုံး၀ ground up အစကနေ ဆွဲရမှာဖြစ်ပါတယ်။ အဲ့အတွက်ကြောင့် ကုဗတုံးတစ်ခုကိုဘယ်လို ဆွဲသွားတယ်၊ low level အထိ ဘယ်လို abstract လုပ်သွားလဲ ဆိုတာကို နားလည်သွားလို့ရှိရင် ဆွဲနိုင်သွားမှာဖြစ်ပါတယ်။ 17 | 18 | ထိုနည်းလည်းကောင်းပဲ computer science major မှာလည်း system တွေက low level abstraction အထိ ဘယ်လိုလုပ်သွားတယ်ဆိုတဲ့ အချက်က သိဖို့လိုအပ်တယ်၊ အရေးကြီးတယ်ဆိုတဲ့ အကြောင်းပြောရင်း conclude လုပ်သွားပါတယ်။ 19 | 20 | ![Image of Abstraction](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/abstraction.png) 21 | -------------------------------------------------------------------------------- /articles/avltree.md: -------------------------------------------------------------------------------- 1 | ## AVL Tree 2 | 3 | AVL tree ဆိုတာကတော့ binary tree ကို modify ထပ်လုပ်ထားတဲ့ balanced binary tree ကိုအခြေခံထားတဲ့ algorithm တစ်ခုပဲဖြစ်ပါတယ်။ Binary tree ရှိရဲ့ သားနဲ့ balanced binary ဆိုပြီး ဘာလို့ထပ်လာတာလဲမေးစရာရှိပါတယ်။ ရှင်းပါတယ်၊ binary tree ကမပြည့်စုံသေးလို့ပါ၊ ဘာလို့လဲဆိုတော့ binary tree ရဲ့ worst case တွေမှာ performance က linear time အထိ ပြန်နိမ့်ကျသွားလို့ပါ။ ဥပမာ 1, 2, 3, 4, 5, 6, 7 ကို binary tree နဲ့ စီထည့် လိုက်မယ်ဆို tree က right side ကိုပဲ တစ်ဖတ်သတ်ချည်းစီသွားလိုက်မယ်၊ ဘာလို့right side ကိုဆင်းသွားလဲဆိုတာမသိရင် binary tree articles တွေပြန်ဖတ်ဖို့လိုပါတယ်။ အောက်က link တွေမှာဖတ်ပါ။ 4 | 5 | Binary tree 6 | http://bit.ly/2MpDLnX 7 | 8 | Binary tree's operation 9 | http://bit.ly/2YZiqIv 10 | 11 | Binary tress's traversal 12 | http://bit.ly/31L0oH1 13 | 14 | Binary search 15 | http://bit.ly/2KZCTDe 16 | 17 | စကားပြန်ဆက်ရမယ်ဆို ဆိုလိုချင်တာက node တစ်ခု insert ထည့်တော့မယ်ဆို process က 7 ခါလုပ်ရပါမယ်၊ ဆိုတော့ linear အတိုင်းပဲပြန်ကြာသွားပါလိမ့်မယ်။ အဲ့အတွက်ကြောင့် မို့လို့ binary tree တွေကို balanced ထပ်လုပ်ဖို့လိုအပ်လာတာပါ။ balanced လုပ်ထားတဲ့ tree ဆိုရင် linear time မကြာဘဲ နဲ့ process ကိုလျော့ချ နိုင်ပြီး performance အတွက်ပိုကောင်းပါတယ်။ attachment မှာ sample ကြည့်နိုင်ပါတယ်။ 18 | 19 | ![Image of avl](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/AVL%20tree/fig1.1%20advantages%20of%20avl%20tree.png) 20 | 21 | Balanced binary tree မှာ အခရာကျတာက binary tree ကို rules (ဘယ်ကငယ်၊ညာကကြီး) ကိုလိုက်နာနိုင်ဖို့နဲ့ နောက်တစ်ချက် က tree rotation ပါပဲ။ Tree rotation ဘယ်လိုလုပ်လဲဆိုတာ အောက်က attachment example ပုံလေးတွေမှာ တစ်ဆင့်ခြင်းဆီကြည့်လို့ရပါတယ်။ 22 | 23 | #### Tree Rotation Sample 24 | ![Image of avl](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/AVL%20tree/fig2.1%20tree%20rotation%20sample.png) 25 | 26 | #### Tree Rotation Example 1 27 | ![Image of avl](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/AVL%20tree/fig2.2%20tree%20rotation%20sample.png) 28 | 29 | #### Tree Rotation Example 2 30 | ![Image of avl](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/AVL%20tree/fig2.3%20tree%20rotation%20sample.png) 31 | 32 | #### Tree Rotation Example 3 33 | ![Image of avl](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/AVL%20tree/fig2.4%20tree%20rotation%20sample.png) 34 | 35 | 36 | AVL tree ဆိုတာလဲ balancing လုပ်ထားတဲ့ tree ပါပဲ။ avl မှာတော့ tree ရဲ့ height ကိုယူပြီးတော့ balance ဖြစ်အောင်လုပ်ပါတယ်။ height တွေကိုအခြေခံပြီး balance factor တွက်ပါတယ်။ 37 | 38 | BalanceFactor = height(left-sutree) − height(right-sutree). 39 | Sub tree တစ်ခုမှာ balance factor ကို 1 ထက်ကြီးလို့မရပါဘူး။ ဆိုလိုချင်တာက difference 1 ပဲလက်ခံပါတယ်။ ဥပမာ -1,1,0 ဖြစ်မှသာ balance ဖြစ်ပါမယ်။ နမူနာပုံ attach တွဲပေးလိုက်ပါတယ်။ 40 | 41 | ![Image of avl](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/AVL%20tree/fig3.1%20avl%20tree%20example.jpg) 42 | 43 | Rotation 4 မျိုး ရှိပါတယ်။ စာနဲ့ရှင်းပြတာထက်စာရင် ပုံလေးတွေနဲ့ ပိုနားလည်လွယ်မယ်ထင်ရတဲ့ အတွက် tutorial point က ပုံလေးတွေယူပြီး reference လုပ်လိုက်ပါတယ်။ 44 | 45 | #### Left Rotation 46 | ![Image of avl](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/AVL%20tree/fig3.2%20avl_left_rotation.jpg) 47 | 48 | #### Right Rotation 49 | ![Image of avl](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/AVL%20tree/fig3.3%20avl_right_rotation.jpg) 50 | 51 | #### Left Right Rotation 52 | ![Image of avl](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/AVL%20tree/fig3.4%20left_right_rotation.png) 53 | 54 | #### Right Left Rotation 55 | ![Image of avl](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/AVL%20tree/fig3.5%20right_left_rotation.png) 56 | 57 | Insert လုပ်တာ remove လုပ်တာတွေကတော့ binary tree အတိုင်းပါပဲ။ ပိုသွားတာက insert လုပ်တဲ့ အချိန်မှာ binary tree အတိုင်း insert လုပ်ပြီးရင် sub tree ရဲ့ balance factor ကိုပြန်စစ်ရတာပါပဲ။ balance factor မမှန်ရင် rotation လုပ်ပြီး balance ညှိရမှာမို့လို့ပါ။ 58 | 59 | 60 | Photos credit goes to 61 | w3schools.in, udemy, tutorialspoint 62 | -------------------------------------------------------------------------------- /articles/bigO.md: -------------------------------------------------------------------------------- 1 | ## Big O Notation 2 | 3 | Big O Notation ဆိုတာက program/algorithm တစ်ခုရဲ့ performance run time ကိုဆိုလိုတာပါ၊ ဒီ algorithm တစ်ခု က ဘယ်လောက်မြန်လဲ၊ ဘယ်လောက်နှေးလဲစသည်ဖြင့်ပေါ့။ တစ်နည်းအားဖြင့် ပြောရမယ်ဆိုရင် algorithm တစ်ခုရဲ့ ခက်ခဲမှု (complexity) လို့လဲပြောလို့ရပါတယ်။ ဒီနေ့မှာ ကျနော် big O notation ကို နားလည်ရလွယ်အောင် real world example တွေနဲ့ နှိုင်းယှဉ်ပြီး ပြောပြပေးသွားပါမယ်။ 4 | 5 | စာကြည့်တိုက်ကြီးတစ်ခုရှိတယ်ဆိုပါစို့၊ စာအုပ်တွေလည်း တော်တော်စုံတယ်။ စာအုပ်ပေါင်း အမျိုးအစား အားလုံးပေါင်းလိုက်ရင် 1million လောက်တောင် ရှိတယ်ပဲထားလိုက်ရအောင်။ ဒါပေမဲ့ စာကြည့်တိုက်မှာ စာအုပ်လာငှားတဲ့ လူက ဘယ်စာအုပ်လေးလိုချင်ပါတယ် ဆိုပြီး နာမည်တပ်ပြောလိုက်ရင် အဲ့ စာအုပ်ကို လိုက်ရှာဖို့က အချိန်တော်တော်ယူနေရတယ်။ ဒါနဲ့ပဲ စာအုပ်တွေကို ရှာမယ့် searching algorithm တစ်ခုရေးဖို့စဉ်းစားကြတယ်၊ မြန်နိုင်သမျှ မြန်မြန်လိုအပ်တဲ့စာအုပ်ကို ရနိုင်ဖို့ပေ့ါ။ algorithm မှာ နှစ်ခုရှိတယ်၊ simple search နဲ့ binary search ဆိုပြီး (main topic က big O အကြောင်းဆိုတော့ binary search ကိုမသိလဲရပါတယ်)။ 6 | Algorithm နှစ်ခုလုံး က တိကျပြီး မြန်မြန်ဆန်ဆန် နဲ့ ထွက်လာဖို့လိုပါတယ်။ binary search ကတော့ ပိုမြန်တယ်။ 7 | 8 | Algorithm တွေရဲ့ run time ကို သိဖို့အတွက် စာအုပ် ၁၀၀ ပေါ်မှာ အခြေခံပြီးတွက်ကြည့်ရအောင်။ စာအုပ်တစ်အုပ် ကို 1millisecond (1000ms = 1 sec) ကြာတယ်လို့ define လုပ်လိုက်ရအောင်။ simple search က စာအုပ် ၁၀၀ လုံးအတွက် လိုက်စစ်စရာလိုတဲ့ အတွက် simple search နဲ့ ရှာမယ်ဆို စာအုပ် ၁၀၀ အတွက် 100ms ကြာပါမယ်။ binary search နဲ့ဆို စာအုပ် ၁၀၀ မှာ လိုချင်တဲ့ result ထွက်လာဖို့ အတွက် စာအုပ် ၇ အုပ်စာလောက်ပဲ စစ်ရပါတယ်။ binary search ရဲ့ algorithm အရ (log2 100 ဆို 7 လောက်ရပါတယ်)။ ဆိုတဲ့အတွက် ကြောင့် binary search နဲ့ run မယ်ဆို 7ms ပဲကြာပါမယ်။ တစ်ကယ်တော့ ၁၀၀ ပဲ run ရမှာ မဟုတ်ဘူး။ 1million record ကို run ရမှာပါ။ 9 | 10 | Record 100 base အရ ထွက်လာတဲ့ run time (milliseconds) ပေါ်မူတည်ပြီး binary search က simple search ထက်စာရင် 14 ဆလောက်မြန်တယ်လို့မှတ်ယူထားပါတယ်။ Binary search နဲ့ record တစ်သန်းကို run လိုက်တဲ့ အချိန်မှာ 20sec လောက်ကြာပါတယ်။ simple search နဲ့ဆို 14 ဆ ဆိုတော့ 280sec လောက်ကြာမယ်လို့ခန့်မှန်းပါတယ်။ 11 | 12 | အဲ့မှာ စမှား တာပါ တစ်ကယ်တော့ simple search နဲ့ဆို 16 mins ကျော်ကြာသွားမှာပါ။ ဘာလို့လဲဆိုတော့ algorithm နှစ်ခု က rate ခြင်းမတူကြပါဘူး။ ဆိုလိုတာက input size များလာတာနဲ့အမျှ run time လဲပိုပြီးကွာသွားမှာပါ။ 14 ဆပိုမြန်တယ်ဆိုပြီး ပုံသေတွက်လို့မရပါဘူး။ ဆိုလိုချင်တာက ဒါက record 1million ပဲရှိသေးတယ်။ 1 billion ဆို binary search နဲ့ဆို 30sec လောက်ပဲကြာပြီး simple search နဲ့ဆို 11 ရက်လောက်ကြာမှာပါ။ rate ကလည်း 33million လောက်ပိုမြန်မှာပါ။ 13 | 14 | Big O ရဲ့ အဓိက ဆိုလိုရင်းက လည်း အဲ့ဒါပါပဲ algorithm တစ်ခုရဲ့ run time ကိုပြတယ်။ ဒါပေမဲ့ အချိန် တွေ seconds တွေနဲ့ မဟုတ်ပဲနဲ့ operation နဲ့ပြတယ်။ simple search algorithm နဲ့ဆို အုပ်ရေ ၁၀၀ မှာ အခေါက် ၁၀၀ run ရပေမဲ့ binary search algorithm နဲ့ ဆို ၇ ခေါက် (7 operations) ပဲ run ရမယ်။ input size ကြီးလာတာနဲ့ အမျှ သူတို့ကြားထဲက ကွာခြားချက်ကလဲ ကြီးလာမှာပဲ။ ဘယ်လောက် ကွာခြားသွားလဲဆိုတာကို big O notation က formula တွေနဲ့ define လုပ်ပေးတယ်။ 15 | 16 | သတိချပ်စရာရှိတာက big O calculation တွက်ပြီးဆို wrost case တွေအထိစဉ်းစားပြီး တွက်ရတယ်။ ဥပမာ record 100 မှာရှာမယ်ဆို ကိုယ်ရှာတဲ့ key ကို ပထမဆုံးတင်တွေ့တယ်ဆိုပါစို့။ algorithm က entry တိုင်းကို သွားဖတ်စရာမလိုတော့တဲ့အတွက် ကိုယ့် algorithm က n time လား 1 time လားဆိုတာ သတိပြန်ချပ်သင့်ပါတယ်။ entry အကုန်လုံးကို run မှ big O of n ရလာမှာပါ။ ဒါကြောင့် လည်း အဆိုးဆုံး worst case အထိစဉ်းစားခိုင်းတာပါ။ 17 | 18 | Big O ရဲ့ run times တွေ အမျိုးမျိုးရှိတယ်။ အသုံးများတာတွေကို အောက်မှာ ရေးပေးလိုက်တယ်။ fastest to slowest order နဲ့။ 19 | 20 | O(log n), log time (eg binary search) 21 | O(n), linear time (eg simple search) 22 | O(n * log n), (fast sorting algorithm) 23 | O(n2), (slow sorting algorithm) 24 | O(n!) (pretty slow algorithm) 25 | 26 | Run time တွေကို စမ်းကြည့်ချင်တယ်ဆို ကိုယ့်ဘာသာ calculator နဲ့တွက်ပြီး စမ်းကြည့်လို့ရတယ်။ ဥပမာ 1billion records မှာ log time နဲ့ဆိုဘယ်လောက်ကြာမလဲ၊ linear နဲ့ဆိုဘယ်လောက်လဲ စသည်ဖြင့်ပေါ့။ 27 | 28 | -------------------------------------------------------------------------------- /articles/binarysearch.md: -------------------------------------------------------------------------------- 1 | ## Binary Search Algorithm 2 | 3 | Binary search ကတော့ strong ဖြစ်တဲ့ searching algorithm တစ်ခုဖြစ်ပြီးတော့ divide & conquer algorithm အပေါ်မှီငြမ်းထားပြီးအလုပ်လုပ်ပါတယ်။ 4 | Binary search intro နဲ့ time complexity အကြောင်းဖတ်ရန် - http://bit.ly/2KHIOhy 5 | Divide & conquer အကြောင်းဖတ်ရန် - http://bit.ly/2H8MIOb 6 | 7 | Binary search algorithm အလုပ်လုပ်ဖို့ဆိုရင် data value တွေက sorted form နဲ့ရှိထားရပါတယ်။ ဘာလို့လဲဆိုတော့ သူအလုပ်လုပ်ပုံက data collection ထဲကနေ middle item ကိုလှမ်းထောက်တယ်၊ ရလာတဲ့ key နဲ့ ရှာမယ့် key ကိုတိုက်စစ်ပြီး ငယ်တယ်ဆို ဘယ်ဘက်ကိုရွေ့ ပြီး mid item ထပ်ရှာ၊ ကြီးတယ်ဆို ညာဘက်ရွေးပြီး mid item ထပ်ရှာ၊ တူတာတွေ့ပြီဆို ရင်တော့ process ပြီးပြီပေါ့၊ မတွေ့သေးသမျှတော့ middle most node ကို ထောက်ထောက်ပြီးတော့ အလုပ်လုပ်သွားတယ်။ ဒါကြောင့်မို့လို့ data collection တွေက တိုက်စစ်ပေးနိုင်ဖို့အတွက် sorted form ဖြစ်နေရမယ်ပြောတာ။ 8 | 9 | ကျနော်တို့ example တစ်ခုအနေနဲ့ binary search ကိုသုံးပြီး ရှာကြည့်ကြရအောင်။ Photo attach တွဲပေးထားတာကိုကြည့်ပါ။ 10 | 11 | ![Images of linked list](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/binary%20tree/Binary-Search.png) 12 | 13 | Array 10 ခုပါတဲ့ data collection တစ်ခုမှာ 23 ပါတဲ့ array key ကိုရှာကြမယ်ဆိုပါစို့။ 14 | ပထမဆုံး အဆင့် အနေနဲ့ medium node ကို အရင်ရှာပါတယ်၊ ဒီ formula နဲ့ ရှာလို့ရပါတယ်။ 15 | mid = low + (high - low) / 2 16 | mid = 0 + (9 - 0 ) / 2 = 4 လို့ပဲယူထားလိုက်ပါမယ်။(integer value of 4.5) 17 | 18 | arrray key 4 ဖြစ်တဲ့ value 16 ရပါတယ်။ ကျနော်တို့ရှာမယ့် 23 က16ထက်ကြီးတယ်ဆိုတော့ ညာဘက် sub collection ကိုထပ်ရွေးပြီးတော့ medium ထပ်ရှာပါမယ်။ ကြီးတဲ့ညာဘက် ကိုသွားမယ်ဆို 19 | low = medium + 1 20 | mid = 5 + (9 - 5 ) / 2 = 7 ရပါတယ်။ 21 | 22 | array key 7 ဖြစ်တဲ့ 56 ကိုရပါမယ်။ ကျနော်တို့ ရှာတဲ့ 23 မရသေးပါဘူး။ 23 က 56 ထက်ငယ်တာဖြစ်တဲ့အတွက် ဘယ်ဘက် sub collection ကိုထပ်ရွေးပြီးတော့ medium ထပ်ရှာပါမယ်။ ငယ်တဲ့ဘယ်ဘက်ကို သွားမယ်ဆို 23 | high = medium -1 24 | mid = 5 + (6-5)/2 = 5 ရပါမယ် (integer value of 5.5) 25 | 26 | array key 5 ဖြစ်တဲ့ 23 ကိုရပါပြီ၊ ကျနော်တို့ ရှာချင်တဲ့ array key ကိုရှာတွေ့သွားတာပဲဖြစ်ပါတယ်။ 27 | 28 | #### Pseudo code sample 29 | ``` 30 | Function search(root, node) 31 | if (root == null) //failed search 32 | return null; 33 | if (node == root.key) //succesfull search 34 | return root; 35 | if (node < root.key) //node in left branch 36 | return Search(root.left, k); 37 | else //node > root.key, i.e. node in right branch 38 | return Search(root.right, k); 39 | ``` 40 | photos credit to geeksforgeeks 41 | -------------------------------------------------------------------------------- /articles/binarytree.md: -------------------------------------------------------------------------------- 1 | ## What is a tree & binary tree introduction? 2 | 3 | Data Structure ရဲ့ အပိုင်းမှာ tree ဆိုတာက တော်တော်လေးအရေးပါတယ်။ algorithm တော်တော်များများကို tree တွေနဲ့ represent လုပ်ထားကြတဲ့အတွက်ကြောင့်ဖြစ်ပါတယ်။ ဒီနေ့မှာ ကျနော် tree ဆိုတာဘာလဲ ဆိုတဲ့အကြောင်းအရာကို အသုံးများတဲ့ binary tree နဲ့ ဥပမာ ပြုပြီးဆွေးနွေးသွားပါမယ်။ 4 | 5 | Tree ဆိုတဲ့ သဘောတရားကတော့ ရှင်းတယ်။ Node တစ်ခုနဲ့ တစ်ခု ကို tree structure အတိုင်း တစ်ဆင့်ခြင်းဆီ ချိတ်ဆတ်ထားတယ်၊ ဒါပေမဲ့ ချိတ်ဆက်ထားတဲ့ node တွေက circular ပုံစံဖြစ်သွားတယ်ဆို tree လို့ခေါ်လို့မရတော့ဘူး။ binary tree အကြောင်းကို ဆက်ကြည့်လိုက်မယ်ဆို tree ဆိုတာ ဘယ်လိုလဲဆိုတာ တိတိကျကျမြင်သွားပါလိမ့်မယ်။ 6 | 7 | Binary tree/binary search tree အတူတူပါပဲ၊ binary tree လို့ပြောလိုက်ပြီဆိုတာနဲ့ Node တစ်ခုမှာ child node နှစ်ခု လို့ ပြေးမြင်ထားလို့ရပါတယ်။ binary tree မှာလည်း သူ့ရဲ့ behavior လေးတွေလဲရှိတယ်။ Node တစ်ခုမှာ အများဆုံး child node နှစ်ခုပဲရှိရမယ်။ left child က parent node ထက် နည်းရမယ်၊ right child က parent node ထက် ကြီးရမယ်။ 8 | 9 | Tree structure မှာလည်း သူ့ရဲ့ အခေါ်အဝေါ်လေးတွေရှိတယ်။ 10 | Root - tree တစ်ခုလုံးရဲ့ ထိပ်ဆုံးက Node. 11 | Parent - parent node ဆိုတာကတော့ သိတဲ့အတိုင်း sub tree (child node) တွေရှိ(ပိုင်ဆိုင်)တဲ့ node. 12 | Child - node တစ်ခုရဲ့ အောက်မှာ sub tree အနေနဲ့ ရှိနေတဲ့ node. 13 | Subtree – node တစ်ခုရဲ့ အောက်မှာရှိတဲ့ sub tree structure တစ်ခု(parent ရှိတယ်၊ child ရှိတယ်။). 14 | Leaf - child node တွေမရှိတဲ့ node. 15 | Tree structure မှာလည်း အဆင့်ဆင့် သတ်မှတ်ထားတဲ့ level တွေလည်း ရှိတယ်၊ ဥပမာ root node က level 1, root node ရဲ့ အောက်က level 2. 16 | Tree structure မှာ search လုပ်တဲ့ အခါတို့ တစ်ခြား operation တွေလုပ်တဲ့ အခါမှာ node တွေတစ်ခုခြင်းဆီ ကို လိုက်ထောက်တာကို လည်း traversing လုပ်တယ်လို့ခေါ်ပါတယ်။ 17 | 18 | Binary Tree မှာ Basic Operations တွေကို ကြည့်မယ်ဆိုရင် 19 | - Inserting 20 | - Searching 21 | - Removing ရှိမယ်။ 22 | Node တွေကို Traversal လုပ်တဲ့ နေရာမှာဆိုရင် 23 | - Preorder Traversal 24 | - Inorder Traversal 25 | - Postorder Traversal 26 | ဆိုပြီးရှိပါတယ်။ 27 | 28 | ဒီ လောက်ဆိုရင်တော့ tree ဆိုတာကဘာလဲနဲ့ binary tree အကြောင်းကို Introduction အနေနဲ့ လုံလောက်ပြီလို့ထင်ပါတယ်။ နောက်နေ့တွေမှာ Basic operation တွေအတွက် article တစ်ခု ၊ traversal လုပ်တဲ့ ပုံစံတွေအတွက် article တစ်ခု စီ သက်သက်ထပ်တင်ပေးသွားပါမယ်။ 29 | 30 | photo credits to tutorialpoint 31 | 32 | 33 | ![Image of binarytree](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/binary%20tree/binary_tree.jpg) 34 | -------------------------------------------------------------------------------- /articles/binarytree_operations.md: -------------------------------------------------------------------------------- 1 | ## Binary tree’s operation 2 | 3 | ဟိုတစ်နေ့ကတော့ binary tree အကြောင်းကို ပြောပြပေးပြီးသွားပြီဆိုတော့ အခု binary tree ရဲ့ operation တွေအကြောင်းကို ပြောပြပေးသွားပါမယ်။ operation တွေကတော့ insert , search , remove ဆိုပြီးတော့ ရှိမယ်၊ တစ်ခုခြင်းဆီ ဘယ်လို အလုပ်လုပ်လဲဆိုတာနဲ့အတူ algorithm အတွက် pseudo sample တွေပါ ရေးပေးသွားပါမယ်။ 4 | 5 | Operation လုပ်တော့မယ်ဆို ကျနော်တို့ အရင်ဆုံး binary tree ရဲ့ property ကို တစ်ချက် remind လုပ်ရပါမယ်။ node တစ်ခုမှာ child နှစ်ခုရှိတယ်၊ left child က အဲ့ဒီ parent node ထက် ငယ်ရမယ်၊ right child က parent node ထက် ကြီးရမယ်။ ဒါကို မှတ်ထားဖို့လိုမယ်။ operation ဘယ်လိုလုပ်လဲကြည့်ရအောင်။ 6 | 7 | ### Insert Operation 8 | 9 | Node တစ်ခုစထည့်တော့မယ်ဆိုရင် သူ့ရဲ့ထည့်ရမယ့်နေရာကို စဉ်းစားရပါတယ်။ ဘာမှမရှိသေးတဲ့ tree ကို node တစ်ခုစထည့်ပြီဆိုရင်တော့ အဲ့ဒီ node က root node ဖြစ်သွားမယ်၊ နောက်ထပ်ထပ်ထည့်ပြီဆို ထည့်တော့မယ့် value က root/parent node ထက် ငယ်လား၊ကြီးလား ကြည့်ရမယ်၊ ငယ်တယ်ဆို ဘယ်ဘက်မှာထည့်၊ ကြီးတယ်ဆို ညာဘက်မှာထည့်ပါမယ်။ 10 | 11 | ![Image of binarytree](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/binary%20tree/binarytree%20insertion.png) 12 | ``` 13 | function insert(root , node) //node for new inserting element 14 | if (empty(root)) 15 | return create Root(node); //create root with newly inserted node 16 | if (node <= root.node) // if the inserting node is less than root node 17 | root.left = create(root.left , node) //insert in left side of the tree 18 | else // if the inserting node is greater than root node 19 | root.right = create(root.right, node) //insert in right side of the tree 20 | ``` 21 | ### Search Operation 22 | 23 | Node တစ်ခုကို search တော့မယ်ဆိုရင် tree ရဲ့ root node ကနေပြီးတော့ စရှာတယ်။ ရှာမယ့် value က root node value ထက်ငယ်မယ်ဆို left side ကိုဆင်းပြီးထပ်ရှာတယ်၊ ကြီးတယ်ဆို right side ကိုဆင်းပြီးထပ်ရှာတယ်။ အဲ့လိုနဲ့ပဲအဆင့်ဆင့် node value တွေနဲ့ တိုက်ပြီး ကြီးရင် ညာ၊ ငယ်ရင် ဘယ် နဲ့ ရလဒ်တွေ့တဲ့ ထိရှာသွားတယ်။ 24 | 25 | ![Image of binarytree](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/binary%20tree/binarytree%20search.png) 26 | 27 | ``` 28 | function search(root, node) 29 | if (root == null) //failed search 30 | return null; 31 | if (node == root.node) //found 32 | return root; 33 | if (node < root.node) //if the node is less than root/parent node 34 | return Search(root.left, node); //continue searching on the left side of tree 35 | else //if the node is greater than root/parent node 36 | return Search(root.right, node); //continue searching on the left side of tree 37 | ``` 38 | ### Removing operation 39 | Remove လုပ်တဲ့ နေရာမှာတော့ insert တို့ search တို့လို မရိုးရှင်းဘူး၊ နည်းနည်း tricky ဖြစ်တယ်။ ဘာလို့လဲဆိုတော့ ဖျက်တဲ့ နေရာမှာ case က ၄ ခုဖြစ်နိုင်တယ်။ 40 | - Case I. Leaf node ကိုဖျက်တဲ့case (အောက်က child node မရှိတော့တဲ့ node တစ်ခုကိုဖျက်တာ) 41 | - Case II. Child node အနေနဲ့ Left side node ပဲရှိတဲ့ node ကိုဖျက်တဲ့ case 42 | - Case III. Child node အနေနဲ့ right side node ပဲရှိတဲ့ node ကိုဖျက်တဲ့ case 43 | - Case IV. Child node အနေနဲ့ left ရော right ရောရှိတဲ့ node ကိုဖျက်တဲ့ case 44 | 45 | Case II and III ကတော့ အတူတူပဲလို့ပြောလို့ရပါတယ်။ 46 | 47 | Case I ကိုဖျက်တဲ့နေရာမှာတော့ ရှင်းပါတယ်။ သူ့အောက်မှာ တစ်ခြား ဘာ child node မှမရှိတဲ့ အတွက် တန်းဖျက်လိုက်လို့ရပါတယ်။ 48 | 49 | ![Image of binarytree](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/binary%20tree/binarytree%20removing%20case1.png) 50 | 51 | Case II ကိုဖျက်တဲ့နေရာမှာတော့ ဖျက်ရမယ့် node အောက်မှာ left side node ထက်ရှိတယ်ဆိုရင် ဖျက်မယ့် node ကိုဖျက်ပြီး အဲ့ node အောက်က left side tree ရဲ့ parent node နဲ့ အစားထိုးလိုက်ရင်ရပါပြီ။ right side လည်း အဲ့နည်းအတိုင်းပါပဲ။ 52 | 53 | ![Image of binarytree](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/binary%20tree/fig%201.binary%20tree%20removing%20case2and3.png) 54 | 55 | ![Image of binarytree](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/binary%20tree/fig%202.binary%20tree%20removing%20case2and3.png) 56 | 57 | 58 | Case IV ကတော့ ပိုရှုပ်ပါတယ်။ ဖျက်မယ့် node တစ်ခု အောက်မှာ left ကော right ကော ရှိတယ်။ အဲ့လို node ကိုဖျက်တော့မယ်ဆို ပိုပြီးသတိထားရပါတယ်၊ binary tree ရဲ့ property မပျက်အောင် ဖျက်ရပါတယ်။ ဖျက်တော့မယ်ဆို left side ဘက်ကိုရွေးမယ်ဆို အကြီးဆုံး value ၊ right side ကိုရှာမယ်ဆို အငယ်ဆုံး value တို့ကို ရှာပြီးတော့ ဖျက်ရမယ့် node ဆီကို replace လုပ်ပြီးတော့ ဖျက်ပါမယ်။ left side ကိုရွေးတယ်ဆို အကြီးဆုံး value ကိုရှာရမှာဖြစ်တဲ့အတွက် tree ရဲ့ ညာဘက် အခြမ်းတွေကို ဆင်းပြီးတော့ right sub tree မရှိတော့တဲ့ node အထိဆင်းသွားမယ်ဆို left side ရဲ့ အကြီးဆုံးကိုရမှာဖြစ်ပြီးတော့၊ right side ကိုရွေးမယ်ဆို ဘယ်ဘက်ကိုတောက်လျောက်ဆင်းသွားပြီး left sub tree မရှိတော့တဲ့ node အထိဆို right side ရဲ့ အငယ်ဆုံး node ကိုရမှာဖြစ်ပါတယ်။ ရလာတဲ့ အငယ်ဆုံး OR အကြီးဆုံး value ကို ဖျက်ရမယ့် node နဲ့ replace လုပ်ပြီး အဲ့ဒီ ခုနက ရှာထားတဲ့ အငယ်ဆုံး OR အကြီးဆုံးရှိတဲ့ node ကိုဖျက်လိုက်ရင်ရပါပြီ။ အဲ့ဖျက်တဲ့ အချိန်မှာတော့ Case I OR case II & III နဲ့ဖျက်သွားလို့ရပါပြီ။ 59 | 60 | ![Image of binarytree](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/binary%20tree/fig%201.binary%20tree%20removing%20case4.png) 61 | 62 | ![Image of binarytree](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/binary%20tree/fig%202.binary%20tree%20removing%20case4.png) 63 | 64 | ![Image of binarytree](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/binary%20tree/fig%203.binary%20tree%20removing%20case4.png) 65 | 66 | ![Image of binarytree](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/binary%20tree/fig%204.binary%20tree%20removing%20case4.png) 67 | 68 | ``` 69 | function delete(root, node) 70 | if (root == null) // failed search 71 | return null; 72 | if (node == root.node) // successful search 73 | return deletecasefour(root); 74 | if (node < root.node) // node in the left branch 75 | root.left = Delete(root.left, node); 76 | else // node > root.node, i.e., node in the right branch 77 | root.right = Delete(root.right, node); 78 | return root; 79 | ``` 80 | ``` 81 | function deletecasefour(root) 82 | if root has two children 83 | p = Largest(root.left); // replace root with its immediate predecessor p 84 | root.node = p.node; 85 | root.left = Delete(root.left, p) 86 | return root; 87 | if root has only left child 88 | return root.left 89 | if root has only right child 90 | return root.right 91 | else root has no children 92 | return null 93 | ``` 94 | ``` 95 | function Largest(Node root) 96 | if root has no right child 97 | return root 98 | return Largest(root.right) 99 | ``` 100 | photos credit to udemy 101 | -------------------------------------------------------------------------------- /articles/binarytree_traversals.md: -------------------------------------------------------------------------------- 1 | ## Binary Tree’s traversal 2 | 3 | Binary tree မှာ traversal လုပ်တယ်ဆိုတာ tree ထဲမှာရှိတဲ့ node တွေကို visit လုပ်တာကိုဆိုလိုတာပါ။ tree ထဲမှာရှိတဲ့ level 2 က value 7 ရှိတဲ့ node ကိုလှမ်းထောက်ပါဆို ဒီတိုင်း plain ကြီး သွားထောက်လို့မရပါဘူး။ level 0 ဖြစ်တဲ့ root node ကနေစပြီးတော့ တစ်ဆင့်ခြင်းဆီ အဲ့ဒီ node ကိုရောက်ဖို့အထိ visit လုပ်ရပါတယ်။ အဲ့လို visit လုပ်တာကို traversal လုပ်တယ်လို့ခေါ်ပါတယ်။ 4 | 5 | Traversal လုပ်တဲ့ နေရာမှာ 6 | - In-order Traversal 7 | - Pre-order Traversal 8 | - Post-order Traversal 9 | - Level order Traversal 10 | ဆိုပြီးတော့ ရှိပါတယ်။ 11 | 12 | ### In-order Traversal 13 | 14 | Inorder ကတော့ ascending order နဲ့သွားတယ်၊ ဘာလို့လဲဆိုတော့ သူ traversal လုပ်တာက left sub tree အရင်လုပ်တယ်၊ ပြီးတော့ မှ root ပြီးတော့မှ right sub tree ကိုလုပ်သွားတယ်။ ဆိုတော့ left to right သွားတဲ့ အတွက်ကြောင့် value တွေကလည်း အစဉ်သင့် ascending order နဲ့ sort ပြီးသားဖြစ်သွားပါတယ်။ 15 | 16 | ![Image of binarytree](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/binary%20tree/binarytree%20inorder%20traversal.png) 17 | 18 | ### Pre-order Traversal 19 | 20 | Preorder မှာတော့ root ကိုအရင်ဆုံး visit လုပ်တယ်၊ ပြီးတော့မှ left sub tree ကို visit လုပ်ပြီး နောက်ဆုံးမှာမှ right sub tree ကို visit လုပ်တယ်။ root->left sub tree->right sub tree 21 | 22 | ![Image of binarytree](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/binary%20tree/binarytree%20preorder%20traversal.png) 23 | 24 | ### Post-order Traversal 25 | 26 | Postorder မှာတော့ root ကိုနောက်ဆုံးမှ visit လုပ်တယ်။ left sub tree ကို အရင် visit လုပ်တယ်၊ ပြီးတော့ right sub tree ၊ နောက်ဆုံးမှ root ဆီ visit လုပ်ပါတယ်။ left sub tree->right sub tree->root 27 | 28 | ![Image of binarytree](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/binary%20tree/binarytree%20postorder%20traversal.png) 29 | 30 | ### Level Order Traversal 31 | 32 | Level order ကတော့ tree ရဲ့ level နဲ့ အလိုက် visit လုပ်ပြီး print လုပ်ပါတယ်။ သူအလုပ်လုပ်က အပေါ်ကကောင်တွေလောက်မရိုးရှင်းဘူး၊ queue algorithm ကိုအသုံးပြုပြီးတော့ အလုပ်လုပ်ပါတယ်။ ဘယ်လိုအလုပ်လုပ်လဲဆိုတော့ root node ကနေ စပြီး အလုပ်လုပ်မယ်ဆိုရင် root node ကို အရင် queue ထဲမှာထည့်ထားတယ်၊ အဲ့ node ကို queue ထဲက ထုတ်ပြီး print လိုက်ပြီဆိုတာနဲ့ အဲ့ node ရဲ့ left and right child node တွေကို queue ထဲမှာထည့်ပါတယ်။ အဲ့လိုနည်း နဲ့ပဲ iterate လုပ်သွားပြီးတော့ level အလိုက် node တွေကို ရရှိလာပါတယ်။ 33 | 34 | ![Image of binarytree](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/binary%20tree/binarytree%20levelorder%20traversal.png) 35 | 36 | photos credit to tutorialpoint 37 | -------------------------------------------------------------------------------- /articles/divide&conquer.md: -------------------------------------------------------------------------------- 1 | ## Divide and Conquer Algorithm 2 | 3 | Greedy လို algorithmic paradigm တစ်ခုပဲ။ သူက ဘာလုပ်လဲဆိုတော့ problem တစ်ခုရလာပြီဆိုရင် အဲ့ problem ကို sub problem တွေအဖြစ်ခွဲချလိုက်တယ်။ အဲ့ဒီ sub problem တွေကိုလည်း နောက်ထပ် sub problem တွေအဖြစ်ခွဲချလိုက်လို့ရသေးတယ်။ လုံး၀ နောက်ထပ် ထပ်ခွဲထုတ်လို့ မရနိုင်တော့တဲ့ အခြေအနေတစ်ခု အထိ ခွဲချလိုက်တာ တစ်နည်းအားဖြင့် ဆိုရမယ်ဆို problem ကို တစ်ဆင့်ခြင်းဆီ break down လုပ်လိုက်တယ်ပေါ့။ နောက်တစ်ဆင့် အနေနဲ့ ဘာလုပ်လဲဆိုတော့ အဲ့ဒီ ခွဲထားတဲ့ Sub problem လေးတွေတစ်ခုခြင်းဆီကို solution ရှာတယ်။ ရှာပြီး တော့မှ ခုနက ဖြိုခွဲထားတဲ့ အတိုင်း အဆင့်ဆင့် ပြန်ပေါင်းလိုက်တယ်။ ခွဲထားတုန်းကလည်း recursive approach အနေနဲ့ sub problem တွေ ခွဲထားတယ်၊ ပြန်ပေါင်းတော့လည်း recursively ပဲ အဆင့်ဆင့်ပြန်ပေါင်းတယ်။ 4 | 5 | အပေါ်မှာပြောထားခဲ့သလိုပဲ divide & conquer က step ၃ ခုနဲ့အလုပ်လုပ်တယ်။ 6 | 7 | ### Divide 8 | Problem တွေကို breaking down အရင်လုပ်တယ်။ recursive approach ကိုသုံးပြီးတော့ problem တစ်ခုကို sub problem တွေအဖြစ်ခွဲချတယ်၊ နောက်ထပ် sub တွေခွဲချလို့မရတော့တဲ့ အထိပေ့ါ၊ 9 | 10 | ### Conquer 11 | Sub problem တွေကို solving လုပ်တဲ့အဆင့်ပေါ့၊ ခွဲချထားတဲ့ problem တစ်ခုခြင်းဆီကို solve လုပ်လိုက်ပါတယ်။ 12 | 13 | ### Combine 14 | Conquer stage မှာ solved လုပ်ထားတဲ့ sub solution တွေကို recursively ပြန် merge လုပ်ပြီးတော့ နဂို ခွဲချလိုက်တဲ့ မူရင်း problem အတွက် solution ထုတ်ပါတယ်။ 15 | 16 | ဒီလောက်ဆိုရင်တော့ divide & conquer အကြောင်းကို အကြမ်းဖျင်းအားဖြင့် နားလည်လောက်ပြီ ထင်ပါတယ်။ 17 | 18 | ဘယ်လိုနေရာတွေမှာ apply လုပ်လဲဆိုတော့ problem ကို divide လုပ်တာတို့ ၊ recursively run တာတို့ လုပ်တဲ့ sorting algorithms တွေဖြစ်တဲ့ quick sort တို့ ၊ merge sort တို့ မှာသုံးတယ်၊ Binary search algorithm မှာလဲ apply လုပ်ထားတယ်။ sorting algorithm တွေနဲ့ binary search အကြောင်းလဲ နောက် articles တွေမှာ algorithm code sample တွေနဲ့အတူ ရေးပေးသွားပါမယ်။ 19 | 20 | photo credits to khanacademy 21 | 22 | ![Image of dividenconquer](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese-Explanations/master/assets/dividenconquer/dividenconquer.png) 23 | -------------------------------------------------------------------------------- /articles/dynamicprogramming.md: -------------------------------------------------------------------------------- 1 | ## Dynamic Programming 2 | 3 | Dynamic programming approach ကလည်း အရှေ့မှာ ရေးထားခဲ့တဲ့ greedy နဲ့ divide & conquer ပုံစံတွေနဲ့ဆင်ပါတယ်။ divide & conquer လိုမျိုး sub problem တွေခွဲချပြီး recursion လုပ်ပြီးပြန်ပေါင်းတယ်။ greedy လိုမျိုး optimum solution ရဖို့အတွက်လည်း လုပ်ထားတယ်။ ဘယ်လို လုပ်ထားလဲဆိုတာ တစ်ချက်လောက်ကြည့်လိုက်ရအောင်။ ဒီ article မဖတ်ခင် divide & conquer နဲ့ greedy ကို အရင်ဖတ်ကြည့်ဖို့ အကြံပေးချင်ပါတယ်။ အောက်က link တွေမှာ ဝင်ဖတ်လို့ရပါတယ်။ 4 | 5 | Divide & conquer 6 | https://www.facebook.com/permalink.php?story_fbid=862512540771458&id=100010381592688 7 | Greedy 8 | https://www.facebook.com/permalink.php?story_fbid=861903050832407&id=100010381592688 9 | 10 | Dynamic programming မှာ problem တစ်ခု ရှိလာတဲ့အခါမှာ divide & conquer approach ပုံစံမျိုးပဲ sub problem တွေအဖြစ်ခွဲချလိုက်တယ်။ ခွဲပြီးတာနဲ့ အဲ့ဒီ sub problem တွေကို solution လုပ်တယ်၊ sub problem တွေခွဲတဲ့ အချိန်က နေပြီးတော့ solution formula ထွက်တဲ့အထိ dynamic programming approach က memorized လုပ်ထားတယ်။ နောင်တစ်ချိန် ဒီလို မျိုး sub problem တွေ့ပြီဆို ပြန်ပြီးတော့ သုံးလို့ရအောင်လို့ပါ။ 11 | 12 | ဥပမာ ကျနော်တို့ sub problem တစ်ခုမှာပေ့ါ၊ x ကိုရှာတဲ့ solution ကိုရထားတယ်။ နောက်တစ်ခါ x ရဲ့တန်ဖိုးကိုထပ်ရှာရမယ့် sub problem မျိုး ရှိလာခဲ့ရင် ကျနော်တို့မှာ x ရဲ့ တန်ဖိုးကို ရှာနိုင်တဲ့ formula ကို memorized လုပ်ထားတဲ့အတွက် နောက်တစ်ခေါက်ထပ်ရှင်းစရာ မလိုတော့ဘဲ optimum ဖြစ်တဲ့ solution ကိုရတယ်။ ဥပမာ နောက်တစ်ခု အနေနဲ့ ထပ်ရှင်းအောင် ပြောရမယ်ဆိုရင် 3+4+5 ဆို 12 ရမယ်။ အဲ့ဒါကို 1 ထပ်ပေါင်းမယ်ဆိုပါစို့ ၊ 13 လို့တန်းပြောနိုင်တယ်။ ဘာလို့လဲဆိုတော့ ကျနော်တို့ က 1 ကိုပဲထပ်ဆင့် ပေါင်းလိုက်တာ 3+4+5 ပေါင်းတာကို ထပ်မတွက်တော့ဘဲ memorized လုပ်ထားတဲ့ 12 နဲ့ 1 ကိုပဲပေါင်းလိုက်တဲ့အတွက် solution က မြန်မြန်ဆန်ဆန် ထွက်လာတာပါ။ 13 | 14 | ဆိုတော့ dynamic programming ကိုဘယ်နေရာတွေမှာ apply လုပ်လို့ရလဲဆိုတော့ problem တွေကို sub structure အဖြစ်ခွဲချလို့ရမယ်၊ ပြီးတော့ sub problem တွေက overlap ဖြစ်လာမယ်ဆိုရင် memorized လုပ်ထားတဲ့ solution ကိုအစားထိုးပြီးတော့ optimize ဖြစ်အောင်လုပ်တယ်။ 15 | 16 | Divide & conquer မှာတုန်းကတော့ sub problem တွေကို ပြန်ပေါင်းပြီးတော့ over all solution တစ်ခုထုတ်တယ်။ dynamic programming ကတော့ sub problem တစ်ခုခြင်းဆီရဲ့ formula ကို memorized လုပ်ထားပြီးတော့ နောက်တစ်ဆင့် နောက်တစ်ဆင့် problem တွေအတွက် optimized လုပ်နိုင်ဖို့ကို ပိုပြီး အာရုံစိုက်ထားတယ်။ CPU ရဲ့ computing power ကိုလည်း သက်သာစေတာပေါ့။ 17 | 18 | Greedy မှာတုန်းကတော့ local optimization အတွက် အဆင်ပြေပြီးတော့ dynamic programming ကကျ local အတွက်တင် မဟုတ်ဘဲ overall problem တစ်ခုလုံးအတွက် အဆင်ပြေအောင် address လုပ်ထားတယ်။ 19 | 20 | ဒီလောက်ဆိုရင်တော့ ဖြင့် dynamic programming အကြောင်းကို theory အရ အကြမ်းဖျင်း နားလည်သွားလောက်ပြီထင်ပါတယ်။ 21 | 22 | 23 | ![Image of dynammicprogramming](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese-Explanations/master/assets/dynamicprogramming/dynamicprogramming.png) 24 | -------------------------------------------------------------------------------- /articles/fenwick.md: -------------------------------------------------------------------------------- 1 | ## Fenwick tree (Binary Indexed Tree) 2 | 3 | Fenwick tree အကြောင်းစပြောတော့မယ်ဆိုရင်တော့ fenwick ကိုဘာကြောင့်သုံးတာလဲ fenwick ကဘာလဲဆိုတာနဲ့ စဆွေးနွေးကြရအောင်။ 4 | 5 | ဥပမာ တစ်ခုနဲ့ပြောရမယ်ဆိုရင် ကျနော်တို့မှာ array 10 ခန်းရှိတဲ့ data တစ်ခုရှိတယ်ဆိုပါစို့။ လိုချင်တာက range query ပုံစံမျိုးလိုချင်တာ။ (eg. Sum of array index 1 to 7, array အခန်း ၁ ကနေပြီးတော့ ၇ အထိပေါင်းခြင်းရလဒ်). ပေါင်းလို့ရလားဆိုတော့ ရတယ် လေ။ array ၁ ခန်းခြင်းဆီ လိုက်ထောက်ပြီးတော့ ပေါင်းရုံပဲ။ array 1 + array 2 + array 3 etc. ပုံစံမျိုးပေါ့။ ဒါပေမဲ့ တစ်ခုခြင်းဆီလိုက်ထောက်နေရတဲ့အတွက် linear time ကြာတယ်။ ဆိုလိုချင်တာက range သာကြီးလာမယ်ဆိုရင် performance ကလည်း ထပ်တူ နှေးလာလိမ့်မယ်။ 6 | 7 | အဲ့လို တစ်ခန်းခြင်းဆီလိုက်ထောက်မယ့်အစား prefix sum ဆိုတဲ့ array structure တစ်ခုဆောက်လိုက်မယ်။ array အခန်း ၁၁ ခန်းနဲ့ပေါ့။ အဲ့ဒီ ၁၁ ခန်းမှာ array index တွေကို တစ်ခန်းခြင်းဆီလိုက်ထောက်ပြီး ပေါင်းပြီးသား result တွေကို store လုပ်ထားမယ်။ sum range query လုပ်တော့မယ်ဆို ဥပမာ index 1 to 7 ရဲ့ ပေါင်းလဒ်ကိုလိုချင်ပြီဆို prefix sum လုပ်ထားတဲ့ array ဆီကနေ value of index 7 – value of index 1 ဆို လိုချင်တဲ့ အဖြေကိုရသွားမှာဖြစ်ပါတယ်။ array တစ်ခန်းခြင်းဆီထောက်ပြီးလဲ ပေါင်းစရာမလိုတော့ဘူးပေါ့။ attach တွဲထားတဲ့ example ကြည့်နိုင်ပါတယ်။ 8 | 9 | ![Image of fenwick](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/fenwick(binary%20indexed%20tree)/fig1.%20fenwick%20tree.png) 10 | 11 | ဒါဆို ကျနော်တို့မှာ လက်ရှိ normal array နဲ့ prefix sum လုပ်ထားတဲ့ array ဆိုပြီး နှစ်ခုရှိတယ်။ အဲ့ထဲကမှ normal array ထဲက value တစ်ခုကို change ချင်တယ်ဆိုပါစို့ ၊ change လုပ်မယ်ဆိုရင် prefix sum လုပ်ထားတဲ့ array ပျက်သွားပြီတော့ အစအဆုံး sum value တွေကို ပြန်တွက်ပေးဖို့လိုလာပါမယ်။ ဒီနေရာမှာ fenwick tree ဆိုပြီး ဝင်လာတာပါ။ range query တွေလဲဆွဲလို့ရမယ်။ key ကိုလည်း update လုပ်လို့ရမယ်၊ linear time မကြာဘဲနဲ့ performance ကောင်းကောင်းနဲ့ပေါ့။ 12 | 13 | ဒီ article မှာတော့ fenwick ကိုသုံးပြီးတော့ range query တွက်နည်း ရေးပေးသွားပါမယ်။ fenwick နဲ့ range query လုပ်တော့မယ်ဆိုတော့ least significant bit (LSB) အကြောင်းလေးပါထည့်ပြောသွားလိုက်ပါမယ်။ LSB ဆိုတာ binary number series မှာရှိတဲ့ lowest bit , ညာဘက်ကနေစပြီး count လုပ်ပါတယ်။ ဥပမာ 10001 ဆိုရင် ညာဘက်ကနေစ count ပြီး LSB က 1 နေရာမှာရှိပါတယ်။ 10010 ဆိုရင် 2 နေရာမှာရှိပါတယ်။ 10100 ဆိုရင် 3 နေရာ၊ 11000 ဆိုရင် 4၊ 10000 ဆိုရင် 5 ။ ဒီလောက်ဆိုရင် LSB သိပြီလို့ထင်ပါတယ်။ 14 | 15 | အပေါ်ကပြောထားတဲ့အတိုင်း ကျနော်တို့မှာ array 10 ခန်းပါတဲ့ data တစ်ခုရှိတယ်ဆိုပါစို့။ index 1 to 10 ကို binary နဲ့ အတူ range value တွေစမ်းတွက်ကြည့်ရအောင်။ 16 | 17 | Index 10 = 1010 , LSB = 2, ပြီးရင် 2 to the power of LSB - 1(fenwick မှာ base အတွက် 2 ကိုသုံးပါတယ်). ဆိုတော့ 2 to the power of LSB-1 = 2 ရပါတယ်။ 18 | 19 | Index 9 ဆိုရင် = 1001 , LSB = 1, 2 to the power of 1-1 = 2 power 0 = 1 ရပါတယ်။ 20 | 21 | အခုလိုဥပမာပေးပြီး တွက်ထုတ်ထားတဲ့ range value တွေကို range query ဆွဲတဲ့ နေရာမှာ ဘယ်လိုသုံးလဲဆိုတာကြည့်ရအောင်။ Index 7 ရဲ့ prefix sum value ကိုလိုချင်တယ်ဆိုပါစို့။ 22 | 23 | Sum = Index[7] + Index[6] + Index[4] ရပါတယ်။ ဘာလို့လဲဆိုတော့ 24 | Index 7 ရဲ့ range value က 1 ပါ။ ဆိုတော့ အောက်တစ်ထစ်ဆင်းပါတယ်။ Index[6] ရပါတယ်၊ သူ့ရဲ့ range value က 2 ရပါတယ်။ အောက်နှစ်ထစ်ဆင်းပါတယ်၊ index[4] ရပါတယ်။ index[4] ရဲ့ range value 4 ရတဲ့အတွက် 0 အထိဆင်းသွားပြီး end ဖြစ်သွားပါတယ်။ attach တွဲထားပေးတဲ့ example ကြည့်လို့ရပါတယ်။ 25 | 26 | ![Image of fenwick](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/fenwick(binary%20indexed%20tree)/fig2.%20calculating%20range%20value.png) 27 | 28 | နောက်တစ်ခုအနေနဲ့ index[4] ရဲ့ prefix sum ကိုတွက်ကြည့်ရအောင်။ index[4] ရဲ့ prefix sum က index[4] အတိုင်းပါပဲ။ တစ်ချက်ထဲနဲ့ ပြီးသွားပါတယ်။ efficient ဖြစ်တယ်ဆိုတာ ဒါမျိုးကိုပြောတာပါ။ 29 | 30 | ဒါဆိုရင် ကျနော်တို့ လိုချင်တဲ့ range query sum value ကိုဘယ်လိုတွက်မလဲရှင်းပါတယ်။ ဥပမာ index 3 to 8 sum value ကိုလိုချင်တယ်ဆိုပါစို့။ index 8 ရဲ့ prefix sum value ရှာမယ်။ index 3 ရဲ့ prefix sum value ရှာမယ်။ ပြီးရင် 8 ထဲက 3 ကိုနှုတ်လိုက်ရင် လိုချင်တဲ့ 3 to 8 range sum value ကိုရပါပြီ။ 31 | 32 | article ကိုတော့ အတတ်နိုင်ဆုံး နားလည်ရလွယ်အောင်ရေးထားပေးပါတယ်။ နားမလည်လို့ ဆွေးနွေးချင်တာရှိရင် လာပြောလို့ရပါတယ်။ နောက်နေ့ မှာ point update လုပ်တဲ့အကြောင်းရေးပေးသွားပါမယ်။ 33 | 34 | photos credit to udemy 35 | -------------------------------------------------------------------------------- /articles/fenwick_construction.md: -------------------------------------------------------------------------------- 1 | ## Fenwick Tree Construction 2 | 3 | Fenwick tree ရဲ့ range query တွက်နည်းရော point update လုပ်နည်းရော ပြောပြီးပြီဆိုတော့ နောက်ဆုံးအနေနဲ့ အရေးကြီးဆုံး fenwick tree ဘယ်လိုဆောက်လဲဆိုတာ ရေးပေးသွားပါမယ်။ range query တို့ point update တို့မလုပ်ခင်မှာ fenwick tree က အရင်ဆောက်ထားရမှာဖြစ်ပါတယ်။ fenwick tree ကို tree structure အတိုင်းလဲ ဆောက်သွားလို့ရတယ်။ ဒီ article မှာတော့ ဖတ်ရလွယ်အောင်နဲ့ နားလည်ရလွယ်အောင် linear structure နဲ့ ဆောက်သွားပြပါမယ်။ 4 | 5 | Attach တွဲပေးထားတဲ့ ပုံက ကျနော် နမူနာ ဆွဲပြထားတဲ့ fenwick tree ဖြစ်ပါတယ်။ ဘယ်လိုတွက်ပြသွားလဲဆိုတာ ရှင်းပြသွားပါမယ်။ စာနဲ့ ပုံနဲ့ တွဲပြီး ဖတ်ကြည့်လို့ရတာပေါ့။ 6 | 7 | ![Image of fenwick](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/fenwick(binary%20indexed%20tree)/fenwick%20tree%20construction.png) 8 | 9 | တွက်တဲ့နေရာမှာ range value တွေကိုတွက်ပြီးတော့ fenwick value တွေထုတ်သွားပါမယ်။ range value တွက်နည်းတွေကို ရှေ့က article တွေမှာပြန်ကြည့်နိုင်ပါတယ်။ စတွက်ကြည့်ရအောင်။ 10 | 11 | Range value of index 1 = 1, အပေါ် 1 ဆင့်တတ်ပြီးပေါင်း = 10+(-2) = 8 , index 2 = 8 12 | Range value of index 2 = 2, အပေါ် 2 ဆင့်တတ်ပြီးပေါင်း = 8+ 5 = 13 , index 4 = 13 13 | Range value of index 3 = 1, အပေါ် 1 ဆင့်တတ်ပြီးပေါင်း = 6+13 = 19, index 4 = 19 14 | Range value of index 4 = 4, အပေါ် 4 ဆင့်တတ်ပြီးပေါင်း = 19+2 = 21 , index 8 = 21 15 | Range value of index 5 = 1, အပေါ် 1 ဆင့်တတ်ပြီးပေါင်း = -3+1 = -2 , index 6 = -2 16 | Range value of index 6 = 2, အပေါ် 2 ဆင့်တတ်ပြီးပေါင်း = -2+21 = 19 , index 8 = 19 17 | Range value of index 7 = 1, အပေါ် 1 ဆင့်တတ်ပြီးပေါင်း = 4+19 = 23 , index 8 = 23 18 | Range value of index 8 = 8, အပေါ် 8 ဆင့်တတ်လို့မရတော့တဲ့ အတွက် ignore 19 | Range value of index 9 = 1, အပေါ် 1 ဆင့်တတ်ပြီးပေါင်း = -1+8 = 7 , index 10 = 7 20 | 21 | Fenwick tree တွက်ပြီးပြီဆိုတော့ range query ဆွဲတာတို့ point update လုပ်တာတို့ စလုပ်လို့ ရပါပြီ။ မှန်မမှန် proof လုပ်တဲ့အနေနဲ့ sum query တစ်ခုလောက်ဆွဲကြည့်ပါမယ်။ 22 | 23 | Index 7 ရဲ့ prefix sum ကိုတွက်ကြည့်ရအောင်။ ပုံမှန်အတိုင်းတွက်မယ်ဆိုရင်. 24 | 10-2+6+5-3+1+4 = 21 ရပါမယ် 25 | 26 | Fenwick နဲ့တွက်ကြည့်မယ်ဆို index 7 ရဲ့ prefix sum ကိုလိုချင်ရင်. 27 | Prefix sum of index 7 = index(7)+ index(6) + index(4) . ps(နာမလည်ရင် ရှေ့ က article တွေပြန်ဖတ်ပါ။) 28 | Prefix sum of index 7 = 4-2+19 = 21 ရပါမယ်။ 29 | 30 | ကိုယ့်ဘာသာ input data ကို တစ်ခြား ဂဏန်းတွေ စမ်းထည့်ကြည့်ပြီးလဲတွက်ကြည့်လို့ရပါတယ်။ ရေးထားတဲ့ fenwick articles ၃ ခုကိုလည်း ပြန် wrap up လုပ်ပေးလိုက်ပါမယ်။ 31 | -------------------------------------------------------------------------------- /articles/fenwick_pointupdate.md: -------------------------------------------------------------------------------- 1 | ## Fenwick tree (Point Update) 2 | 3 | အရှေ့က ရေးခဲ့တဲ့ topic မှာ fenwick tree ရဲ့ intro နဲ့ sum range query တွက်နည်းကိုပြောပြပေးခဲ့ပါတယ်။ အခု article မှာတော့ မူလရှိပြီးသား array မှာ array value ကိုပြောင်းချင်ရင် fenwick မှာဘယ်လိုလုပ်လဲဆိုတာကိုပြောပြပေးသွားပါမယ်။ အရင် article ကို အောက်က link မှာ ဖတ်လို့ရပါတယ်။ 4 | http://bit.ly/2lDTvaO 5 | 6 | ဒီနေရာမှာပြောစရာရှိတာက range query ပဲတွက်တွက် point update ပဲလုပ်လုပ် range value တန်ဖိုးကိုအရင်တွက်ဖို့လိုပါတယ်။ တွက်နည်းကိုလည်း အရင် article မှာရေးပေးခဲ့ပါတယ်။ revision ပြန်တဲ့အနေနဲ့ ထပ်ရေးလိုက်ပါတယ်။ 7 | 8 | array 10 ခန်းပါတဲ့ data တစ်ခုရှိတယ်ဆိုပါစို့။ index 1 to 10 ကို binary နဲ့ အတူ range value တွေစမ်းတွက်ကြည့်ရအောင်။ 9 | 10 | Index 10 = 1010 , LSB = 2, ပြီးရင် 2 to the power of LSB - 1(fenwick မှာ base အတွက် 2 ကိုသုံးပါတယ်). ဆိုတော့ 2 to the power of LSB-1 = 2 ရပါတယ်။ 11 | 12 | Index 9 ဆိုရင် - 1001 , LSB = 1, 2 to the power of 1-1 = 2 power 0 = 1 ရပါတယ်။ 13 | 14 | အဲ့ဒီ range value တွေကိုသုံးပြီးတော့ prefix sum ကိုတွက်ပါတယ်။ index 7 ရဲ့ prefix sum ကိုလိုချင်တယ်ဆို 15 | 16 | Prefix sum = Index[7] + Index[6] + Index[4] ရပါတယ်။ ဘာလို့လဲဆိုတော့ 17 | Index 7 ရဲ့ range value က 1 ပါ။ ဆိုတော့ အောက်တစ်ထစ်ဆင်းပါတယ်။ Index[6] ရပါတယ်၊ သူ့ရဲ့ range value က 2 ရပါတယ်။ အောက်နှစ်ထစ်ဆင်းပါတယ်၊ index[4] ရပါတယ်။ index[4] ရဲ့ range value 4 ရတဲ့အတွက် 0 အထိဆင်းသွားပြီး end ဖြစ်သွားပါတယ်။ အရင် article ကစာဖြစ်ပါတယ်။ 18 | 19 | အခုမှပြောချင်တာကိုရောက်ပါပြီ။ array တစ်ခုရဲ့ value ကို change ချင်ရင်ကျ prefix sum တွက်တာနဲ့ ပြောင်းပြန် အချိုးကျပါတယ်။ prefix sum မှာက range value ကိုတွက်ပြီး prefix sum အတွက် တစ်ဆင့်ခြင်းဆီ အောက်ဆင်းသွားပါတယ်။ point update လုပ်တဲ့နေရာမှာကျ range value အတိုင်း အပေါ်တတ်သွားရပါမယ်။ ဥပမာ တစ်ခုနဲ့ ကြည့်ကြည့်ရအောင်။ 20 | 21 | Array 16 ခန်းပါတဲ့ data structure တစ်ခုနဲ့ ပြောကြည့်ပါမယ်။ ကျနော်တို့ က index 9 မှာရှိတဲ့ value ကိုပြောင်းချင်ပါတယ်။ ဒါဆိုရင် range value တွေတွက်ပြီး တစ်ဆင့်ခြင်းဆီ အပေါ်တတ်သွားပါမယ်။ attachment image ပါကြည့်လို့ရပါတယ် 22 | 23 | Index 9 ရဲ့ range value 1 ရပါတယ် = index 10 24 | Index 10 ရဲ့ range value 2 ရပါတယ် = index 12 25 | Index 12 ရဲ့ range value 4 ရပါတယ် = index 16 26 | Index 16 မှာ end ဖြစ်သွားပါပြီ။ ဆိုတော့ index 9 မှာရှိတဲ့ value တစ်ခုကို ပြောင်းမယ်ဆို 9 to 16 အထိ လိုက်ပြောင်းနေစရာမလိုပါဘူး ။ index 9,10,12,16 ကိုပြောင်းလိုက်ရင်အဆင်ပြေသွားပါပြီ။ 27 | 28 | ![Image of fenwick](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/fenwick(binary%20indexed%20tree)/fenwick-point%20update.png) 29 | photos credit to udemy 30 | -------------------------------------------------------------------------------- /articles/greedy.md: -------------------------------------------------------------------------------- 1 | ## Greedy algorithm 2 | 3 | Greedy algorithm အကြောင်းအရင် မပြောခင်မှာ localized optimum solution နဲ့ globalized optimum solution ကို အရင်ရှင်းလိုက်ပါမယ်။ ကျနော် တို့ program တစ်ခု run တဲ့အခါ အဆင့်တစ်ဆင့်စီ တိုင်းမှာ အကောင်းဆုံး solution ကို ရွေးသွားတာကို localized optimum solution လို့ခေါ် ပြီးတော့ program တစ်ခုလုံးပြီးသွားလို့ နောက်ဆုံးမှာ အကောင်းဆုံး solution ရတာကို globalized solution လို့ခေါ်ပါတယ်။ Greedy algorithm ရဲ့ ရည်ရွယ်ချက်ကလည်း optimum solution ပေးဖို့အတွက်ပဲ၊ တစ်ဆင့်ခြင်းစီမှာ local optimum solution ကိုရှာပေးရင်းနဲ့ နောက်ဆုံးမှာ global optimum solution ကိုရနိုင်ဖို့အတွက်ပဲ။ ဒါပေမဲ့လည်း သူ့မှာ drawback တွေရှိနေတဲ့အတွက်ကြောင့် အမြဲတမ်း global optimum solution တော့မရနိုင်ဘူး။ ဘာလို့လဲဆိုတာကို အောက်မှာဆက်ကြည့်လိုက်ရအောင်။ 4 | 5 | Greedy က ဘယ်လိုအလုပ်လုပ်လဲဆိုတာ ကျနော် real world example နဲ့ ပြောပြပေးသွားပါမယ်။ ကျနော်တို့မှာ 2 ကျပ်တန် 3 ကျပ်တန် 10 ကျပ်တန် ဆိုပြီး ပိုက်ဆံလေးတွေရှိမယ်။ လိုချင်တာက 15 ကျပ်လိုချင်တယ်။ ဒါဆိုရင် greedy က ဘယ်လို run သွားမလဲဆိုတော့ ပထမဦးဆုံး local optimum ဖြစ်တဲ့ အကြီးဆုံး 10 ကိုယူတယ်၊ နောက်တစ်ခေါက်အတွက် 5ကျပ်ဖြည့်ဖို့ကျန်တဲ့အတွက်ကြောင့် 10 ထပ်ယူလို့မရတော့ဘူး၊ အဲ့အတွက် 3 ကိုယူတယ်။ 2 ကျပ်ထပ်ဖြည့်ဖို့ကျန်တယ်။ 3 ထပ်ယူလို့မရတော့ဘူး။ 2 ကို ထပ်ယူတယ်။ နောက်ဆုံးမှာ run သွားတဲ့ပုံစံက global optimum လည်း ဖြစ်တယ်။ တစ်ဆင့်ခြင်းဆီမှာလည်း local optimum solution တွေယူသွားနိုင်တယ်။ ဒါက satisfy ဖြစ်တဲ့ condition တစ်ခုပါ။ 6 | 7 | အကယ်လို့များ ကျနော်တို့ဆီမှာ ၁၀ ကျပ်တန် ရယ် ၇ ကျပ်တန်ရယ် ၁ကျပ်တန်ရယ်ပဲရှိတယ်ဆိုပါစို့၊ greedy ရဲ့ run နေကြပုံစံအတိုင်း ၁၀ကျပ်တန်ကို အရင်ယူမယ်။ ပြီးရင် ၅ကျပ်ထပ်ဖြည့်ဖို့ကျန်တယ်၊ ၇ထပ်လိုက်ရင်လည်းကြီးသွားမှာဖြစ်တဲ့အတွက်ကြောင့် ၁ကျပ်တန်ကို ၅ခါထပ်ဖြည့်ပါတယ်။ ၁၅ကျပ်တော့ ရသွားတယ်၊ ဒါပေမဲ့ သူ run သွားတဲ့ပုံစံက (၁၀+၁+၁+၁+၁+၁) ဖြစ်သွားတယ်။ process ကို ၆ ခေါက်လောက် run လိုက်ရသလိုဖြစ်သွားတယ်။ အမှန်ဆို (၇+၇+၁) ဆိုလည်း ၁၅ ရနိုင်ပါတယ်။ ဆိုတော့ greedy run သွားတဲ့ပုံစံက တစ်ဆင့်ခြင်းဆီမှာတော့ local optimum solution ကိုရှာသွားနိုင်ပေမဲ့ global အတွက်ကတော့ အဆင်မပြေဘူးဖြစ်သွားတယ်။ 8 | 9 | နောက်ထပ် real world example တွေလည်း ရှိသေးတယ်။ စာအရမ်းရှည်သွားမှာဆိုးလို့ ထပ်ထည့်မရေးတော့ပါဘူး။ 10 | Optimum solution ကိုရှာတဲ့ Huffman coding alogirthm တို့ ၊ minimum spanning Tree algorithm တွေဖြစ်တဲ့ prim တို့ Kruskal တို့မှာလဲ greedy algorithm ကိုသုံးကြပါတယ်။ 11 | 12 | Greedy algorithm ကို implement လုပ်ဖို့အတွက် program logic ကိုကျနော်ထပ်ရှင်းပြပေးပါမယ်။ ရေးရတာလွယ်တဲ့အတွက်ကြောင့် ကိုယ့်ဘာသာ စမ်းပြီး ရေးကြည့်ဖို့ suggest လုပ်ချင်လို့ပါ။ 13 | 14 | ဝင်လာတဲ့ input တွေကို order စီမယ်(optional ပါ)။ ပြီးရင် loop တစ်ခုလုပ်ပြီး destination value (ရချင်တဲ့ target value) နဲ့ compare လုပ်ပြီး input ထဲက ရနိုင်တဲ့ အကြီးဆုံး value တစ်ခုခြင်းဆီဆွဲထုတ်ပါ၊ ပြီးရင် destination value ကိုတော့ input ထဲက ဆွဲထုတ်ထားတဲ့ value နဲ့ နှုတ်ထားဖို့လိုပါတယ်။ conditional statement အနေနဲ့ကတော့ loop တိုင်းမှာ destination value or (နှုတ်ခံထားရတဲ့ လက်ကျန် destination value) ထက် input ဆွဲထုတ်မယ့် value ကကျော်သွားလို့မရပါဘူး။ နောက်ဆုံး destination value 0 ဖြစ်တဲ့အချိန် သို့မဟုတ် input ထဲမှာ destination value ထက် less than or equal ဖြစ်တဲ့ value မရှိတော့တဲ့အချိန်မှာ program ကိုအဆုံးသတ်လို့ရပါပြီ။ 15 | 16 | ![Image of greedy](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese-Explanations/master/assets/greedy/Screen%20Shot%202019-08-10%20at%206.54.15%20PM.png) 17 | -------------------------------------------------------------------------------- /articles/hashtable-openaddressing-linearprobing.md: -------------------------------------------------------------------------------- 1 | ## Hash table - Open addressing (Linear Probing) 2 | 3 | ပြီးခဲ့တဲ့နေ့တွေက hash table နဲ့ collision ဖြစ်ရင်ဖြေရှင်းဖို့ technique တွေရေးခဲ့ပါတယ်၊ အဲ့ထဲက မှ open addressing ဆိုတဲ့ technique ကိုသုံးတဲ့နေရာမှာ လိုအပ်မယ့် function တစ်ခုဖြစ်တဲ့ linear probing အကြောင်းကို ဒီနေ့ဆွေးနွေးသွားမှာဖြစ်ပါတယ်။ open addressing မှာ ရှိတဲ့ cycle issue ကိုလဲတစ်ပါတည်း ဆွေးနွေးသွားမှာဖြစ်ပါတယ်။ 4 | 5 | linear function ကိုသုံးထားလို့ linear probing လို့ခေါ်တယ်။ example . p(x) = ax+b (a is !=0) . ဒါပေမဲ့ သတိတစ်ခုချပ်ထားရမှာက cycle issue ကိုပါပဲ၊ cycle issue ရှိနေရင်တော့ ဘယ် probing function မှ မှန်ကန်စွာ အလုပ်လုပ်နိုင်မှာ မဟုတ်ပါဘူး။ အခုပြောနေတာတွေနားမလည်ဘူးဆိုရင်တော့ အောက်မှာပေးထားတဲ့ article တွေအရင်ဖတ်ဖို့အကြံပေးချင်ပါတယ်။ hash table collision ဖြစ်တဲ့ scenario ၊ ဖြေရှင်းနည်းတွေနဲ့ cycle issue အကြောင်းတွေ နားလည်သွားပါလိမ့်မယ်။ 6 | 7 | Hash table (hashing) 8 | http://bit.ly/2NCd4MH 9 | 10 | Hash table (Separate Chaining) 11 | http://bit.ly/2KSdJaN 12 | 13 | Hash table (Open Addressing) 14 | http://bit.ly/2ZkEdL8 15 | 16 | cycle issue ကိုပြန်trace လိုက်ရမယ်ဆိုရင် cycle issue ဘယ်လိုအချိန်မှာဖြစ်လဲဆိုတာနဲ့ စလိုက်ရအောင်။ eg. အနေနဲ့ p(x) = ax+b ဆိုတဲ့ formula မှာ a ရဲ့ တန်ဖိုးနဲ့ table တစ်ခုရဲ့ size N ကိုယူပြီးတော့ GCD (greatest common denominator) = (GCD(N,a)) တန်ဖိုးကိုတွက်ထုတ်လိုက်လို့ 1 နဲ့ညီနေတယ်ဆိုရင် အဲ့ဒီ probing formula မှန်ကန်စွာအလုပ်လုပ်နိုင်မယ်။ 1 နဲ့ မညီရင်တော့ cycle issue တတ်ပါတယ်။ ဒီနေရာမှာ probing အတွက်ရေးနေတာမို့ GCD အတွက် သက်သက်ကြီးရေးမနေတော့ဘူး၊ GCD calculator လို့ရှာလိုက်ပြီးတွက်ကြည့်လို့ရပါတယ်။ အောက်မှာလဲ ပေးထားပါတယ်။ 17 | http://www.alcula.com/calculators/math/gcd/ 18 | 19 | 20 | ဥပမာ တွေနဲ့ စမ်းတွက်ကြည့်ရအောင်။ 21 | 22 | Table size = 9 23 | Probing function = p(x) = 6x 24 | Max load factor = 0.667 (6/9) 25 | Threshold of the table = N*max load factor = 6 (table size 9 ခန်းရှိပေမဲ့ 6ခန်းပြည့်သွားရင် table resize ထပ်လုပ်ရပါမယ်။) 26 | 27 | GCD တွက်ကြည့်လိုက်မယ်ဆို GCD(N,a) = GCD(9,6) = 3 ရပါတယ်။ 1 မဟုတ်တဲ့ အတွက် ဒီ probing function မှာ cycle issue တတ်ပါမယ်။ အောက်မှာကြည့်ရအောင်။ 28 | 29 | Formula က 30 | p(x) = 6x 31 | index = (h(k)+p(x))mod N ဆိုရင် h(k)ရဲ့ တန်ဖိုးကို 5 လို့သတ်မှတ်ပြီးတွက်ကြည့်ရအောင် 32 | index = (5+0) mod 9 = 5 33 | index = (5+6) mod 9 = 2 34 | index = (5+ 12) mod 9 = 8 35 | index = (5+18) mod 9 = 5 36 | တွေ့တဲ့အတိုင်း cycle issue တတ်သွားမှာပဲဖြစ်ပါတယ်။ GCD တန်ဖိုးက 1 မဖြစ်နေလို့ပါ။ 37 | GCD တန်ဖိုးက 1 သာရခဲ့လျှင် cycle issue မရှိဘဲ empty slot တွေကိုရှာနိုင်သွားမှာပါ။ p(x) ရဲ့ ဆ တန်ဖိုး (a တန်ဖိုး) သာ 1 တို့ 4 တို့ဖြစ်ခဲ့မယ်ဆိုရင် GCD တန်ဖိုး 1 ရတဲ့အတွက် cycle issue မရှိနိုင်တော့ပါဘူး။ 38 | 39 | ![Images of hastable](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/hashtable/open%20addressing/linear%20probing.png) 40 | photo credits to udemy 41 | 42 | ဒီနေရာမှာနောက်တစ်ခုမှတ်ထားစရာရှိတာက table resizing ပါ၊ အပေါ်မှာရှိတဲ့ ကျနော်တို့ရဲ့ table Threshold က 6 ပါ။ ပြည့်သွားမယ်ဆိုရင် တော့ resize ထပ်လုပ်ဖို့လိုပါတယ်။ double resizing လုပ်လိုက်တယ်ဆိုပါစို့၊ resizing လုပ်ပြီးပြီဆို key and value ကို formula (table size N ကပြောင်းသွားပါပြီ) အတိုင်း ပြန်တွက်ပြီးပြန်ထည့်ပေးဖို့လိုပါတယ်။ 43 | 44 | နောက် article မှာ open addressing မှာသုံးတဲ့ quadratic function နဲ့အတူပြန်လာခဲ့ပါမယ်။ 45 | -------------------------------------------------------------------------------- /articles/hashtable-openaddressing-quadraticprobing.md: -------------------------------------------------------------------------------- 1 | ## Hash table - Open addressing (Quadratic Probing) 2 | 3 | Hash table အကြောင်းရေးနေတဲ့ series ထဲ က open addressing မှာသုံးတဲ့ probing function တစ်ခုဖြစ်ပါတယ်။ အရင် article တွေ ဖတ်ပြီးမှ ဒီ article ဖတ်တာ ပိုအဆင်ပြေပါမယ်။ 4 | 5 | Hash table (hashing) 6 | http://bit.ly/2NCd4MH 7 | Hash table (Separate Chaining) 8 | http://bit.ly/2KSdJaN 9 | Hash table (Open Addressing) 10 | http://bit.ly/2ZkEdL8 11 | Hash table (Open Addressing - Linear probing) 12 | http://bit.ly/2ZCjbTx 13 | 14 | ဒီ article ကတော့ နည်းနည်းတိုသွားမယ်။ ဘာလို့လဲဆိုတော့ data collision ဖြစ်တာတို့ open addressing သုံးတဲ့ နေရာမှာ cycle issue ဖြစ်တာတွေအတွက် အရှေ့ က article တွေမှာ လုံလုံလောက်လောက်ရှင်းပြပြီးသွားပြီဖြစ်ပါတယ်။ 15 | 16 | Quadratic probing ကတော့ quadratic formula ကိုသုံးပြီး probing လုပ်တယ်။ eg. (a*square of x + bx +c). a != 0 ဖြစ်ရမယ်။ အရင် article တွေမှာ ပြောခဲ့သလိုပဲ probing function တွေမှာ cycle issue ရှိတတ်သလိုပဲ အခုပြောမယ့် quadratic probing မှာလည်း ဒီ issue ရှိပါတယ်။ ကျန်တဲ့ process တွေက linear probing နဲ့အတူတူပဲ။ မတူတဲ့ အချက်က linear probing မှာ cycle issue ကိုရှင်းနိုင်ဖို့အတွက် GCD တန်ဖိုးရှာပြီး ထိန်းသွားတယ်။ quadratic မှာတော့ ရှင်းနိုင်မယ့် formula တွေအများကြီးရှိတယ်။ အဲ့ထဲကမှ သုံးမျိုးလောက်ကို sharing လုပ်ပေးလိုက်ပါမယ်။ udemy course တစ်ခုကနေ မှီငြမ်းယူထားပါတယ်။ 17 | 18 | 1. P(x) = square of x , table size N number က prime ဖြစ်ပြီးတော့ 3 ထက်ကြီးရမယ်၊ max load factor ကလဲ less than or equal by 1/2 ဖြစ်ရမယ်။ 19 | 2. P(x) = (square of x + x)/2 , ပြီးတော့ table size N က power of 2 ဖြစ်ရပါမယ်။ ဥပမာ 2 power 2 = 4 , 2 power 3 = 8 စသည်ဖြင့်ပေ့ါ။ 20 | 3. P(x) = (-1 power of x) * square of x, ပြီးတော့ table size N က prime number ဖြစ်ပြီးတော့ 3 mod 4 နဲ့ identical ဖြစ်ရမယ်။ ဥပမာ size N က 23 (prime number) . 3 mod 4 ဆို 3 ရမယ်။ ထိုနည်းလည်းကောင်းပဲ 23 mod 4 ဆိုရင်လည်း 3 ရမယ်။ ဒီလိုမျိုးဖြစ်ရမယ်လို့ဆိုလိုတာပါ။ 21 | 22 | Number 1 , 2 နည်းကတော့ တွက်ရတာ ပိုလွယ်မယ်လို့ထင်ပါတယ်။ အပေါ်က ရေးထားတဲ့ formula တွေအတိုင်း probing ကိုတွက်မယ်ဆိုရင် cycle issue မဖြစ်နိုင်တော့ဘဲနဲ့ completely fill up လုပ်နိုင်သွားမှာပါ။ 23 | 24 | ![Images of hashtable](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/hashtable/open%20addressing/quadratic%20probing.png) 25 | photo credits to udemy 26 | 27 | Table ရဲ့ threshold ပြည့်သွားလို့ table resizing လုပ်တဲ့ ပုံစံလည်း linear probing မှာလုပ်တာနဲ့ အတူတူပါပဲ။ cycle issue ကိုကိုင်တွယ်ပုံပဲကွာသွားမှာပါ။ 28 | 29 | နောက် article မှာ double hashing အကြောင်းရေးပေးသွားပါမယ်။ ဒါဆိုရင်တော့ hash table အကြောင်း လည်းတော်တော်စုံသွားပြီး လုံလောက်ပြီလို့ထင်ပါတယ်။ 30 | -------------------------------------------------------------------------------- /articles/hashtable-openaddressing.md: -------------------------------------------------------------------------------- 1 | ## Hash table (Open addressing) 2 | 3 | Open addressing ဆိုတာကလည်း hash table မှာ collision ဖြစ်တဲ့အခါကျ ဖြေရှင်းနိုင်တဲ့ solving technique တစ်ခုပဲဖြစ်ပါတယ်။ ရှေ့ က article တွေမှာတော့ hash table အကြောင်းနဲ့ collision ဖြစ်ရင်ဖြေရှင်းနိုင်တဲ့ technique တစ်ခုဖြစ်တဲ့ separate chaining အကြောင်းကိုရေးပေးထားပါတယ်။ အောက်က link တွေမှာဝင်ဖတ်ကြည့်လို့ရပါတယ်။ 4 | 5 | Hash table (hashing) 6 | http://bit.ly/2NCd4MH 7 | 8 | Hash table (Separate Chaining) 9 | http://bit.ly/2KSdJaN 10 | 11 | ကျနော်တို့ hash table ထဲထည့်ဖို့အတွက် key ကို hash လုပ်တယ်။ hash result ထွက်လာပြီဆို အဲ့ဒီ result အတိုင်း table ထဲမှာ position ယူလိုက်တယ်။ hash result တူပြီး ကိုယ်ထည့်မယ့် position မှာ value ရှိပြီးသားဆို collision ဖြစ်ပြီ၊ ဒါကပုံမှန် process ပဲ။ open addressing ဘယ်လိုအလုပ်လုပ်လဲဆိုတော့ အဲ့ဒီ position က taken ဖြစ်နေတယ်ဆိုရင် နောက်ထပ် လွတ်မယ့် position တစ်ခုကိုဆက်ရှာဖို့ကြိုးစားတယ်။ ဘယ်လိုရှာလဲဆိုတော့ probing sequence formula တစ်ခုထုတ်ပြီးဆက်ရှာတယ်။ ပုံမှန်အတိုင်းဆို ပထမအဆင့်မှာ key ကို hash လုပ်ပြီးရလာတဲ့ result ကို position index အဖြစ်တန်းသတ်မှတ်ပြီးတော့ table ထဲမှာထည့်တယ်၊ probing sequence ကကျ hash result ရယ် မူလkey ရယ်ကို အသုံးပြုပြီးတော့ သူ့ရဲ့ formula ထဲမှာ နောက်ထပ် position index အသစ်တစ်ခုရနိုင်ဖို့အတွက်တွက်ထုတ်ပေးတယ်။ 12 | 13 | Probing sequence မှာလည်း အမျိုးမျိုးရှိတယ်။ 14 | - Linear function နဲ့သုံးမယ်ဆို linear probing 15 | - Quadratic function နဲ့သုံးမယ်ဆို quadratic probing 16 | - နောက်တစ်နည်းကကျ ပုံမှန်သုံးထားတဲ့ hashing method လိုမျိုးကိုပဲ နောက်ထပ် ထပ်သုံးပြီး position index ကိုတွက်တာ ၊ double hashing လို့လဲခေါ်တယ်။ 17 | - Random number တစ်ခုကို generate လုပ်ပြီးတွက်ထုတ်တဲ့ method မျိုးကိုလဲသုံးလို့ရပါတယ်။ 18 | 19 | ဒါပေမဲ့ probing sequence ကိုသုံးတဲ့ အချိန်မှာ issue ရှိနိုင်တဲ့ condition ရှိပါတယ်။ cycles issue လို့လဲခေါ်တယ်။ ဘယ်လို issue ဖြစ်တယ်ဆိုတာ ဥပမာတစ်ခု နဲ့ ယှဉ်ပြီးပြသွားပါမယ်။ probing sequence ကဘယ်လိုအလုပ်လုပ်တယ်ဆိုတဲ့ ပုံစံလည်းပြရင်းနဲ့ပေ့ါ။ 20 | 21 | ကျနော်တို့မှာ slot 12 ခန်းရှိတဲ့ structure တစ်ခုရှိတယ်ပဲဆိုပါစို့၊ (0 to 11)ပေါ့။ slot 0, 4, 8 မှာ data value တွေရှိပြီးသားတွေ။ 22 | အိုကေ၊ ပုံမှန်အတိုင်း key ကို hash လုပ်ပြီး data ထည့်တာပေ့ါ။ formula က H(key) = key mod 12 နဲ့ ဥပမာထားလိုက်ပါမယ်။ key ကို number 8 အဖြစ်နဲ့ ထည့်လိုက်မယ်ဆို hash result က 8 ထွက်လာမယ်။ data value က ရှိပြီးသားဖြစ်တဲ့ အတွက် probing sequence ကိုသုံးပြီးတော့ နောက်ထပ်နေရာလွတ်တစ်ခုကို ထပ်ရှာပါမယ်။ 23 | 24 | Probing sequence အတွက် P(x) = 4x ဆိုပြီး ဥပမာ formula တစ်ခုထားပြီးတော့ position index တွက်မယ့် formula ကို ဒီလို upgrade လုပ်လိုက်ပါမယ်။ x value ကို 0 ကနေ စပြီးတော့ +1 ပေါင်းသွားပြီး ရှာပါမယ်။ 25 | 26 | Index = H(k) + P(x) mod 12 27 | Index = 8+0 mod 12 = 8 (number 8 slot မှာ value ရှိတယ်၊ ထပ်ရှာ) 28 | Index = 8+4 mod 12 = 0 (number 0 slot မှာ value ရှိတယ်၊ ထပ်ရှာ Note: P(x) = 4x) 29 | Index = 8+8 mod 12 = 4 (number 4 slot မှာ value ရှိတယ်၊ ထပ်ရှာ) 30 | Index = 8+12 mod 12 = 8 (number 8 slot မှာ value ရှိတယ်၊ ထပ်ရှာ) 31 | 32 | ရလာတဲ့ result ကိုကြည့်မယ်ဆို 8, 0, 4, 8 ဆိုပြီး cycle အတိုင်း loop ပတ်သွားတာကို တွေ့ရမှာပဲဖြစ်ပါတယ်။ ဆိုတော့ probing function မှာ ဒီလို issue တော့ ရှိတယ်၊ သူ့ကိုဖြေရှင်းနိုင်ဖို့အတွက် ကတော့ ကိုယ်သုံးမယ့် probing function မှာသတိထားပြီးတော့ ကြိုတင်တွက်ချက်ခန့်မှန်းထားဖို့လိုအပ်ပါတယ်။ နောက်နေ့ တွေမှာ linear , quadratic function နဲ့ double hashing article တွေနဲ့အတူ cycle issue ကိုပါဖြေရှင်းနည်းနဲ့ ပြန်လာခဲ့ပါမယ်။ 33 | -------------------------------------------------------------------------------- /articles/hashtable-removing-openaddressing.md: -------------------------------------------------------------------------------- 1 | ## Hash table – Removing elements (open addressing) 2 | 3 | Hash table အကြောင်းရေးနေတဲ့ series ထဲ က hash table ထဲကနေ key တွေ remove လုပ်တဲ့ article ပဲဖြစ်ပါတယ်။ open addressing နဲ့ပဲ ဥပမာ ပြပြီးပြောသွားပါမယ်။ အရင် article တွေ ဖတ်ပြီးမှ ဒီ article ဖတ်တာ ပိုအဆင်ပြေပါမယ်။ 4 | 5 | ##### Hash table (hashing) 6 | http://bit.ly/2NCd4MH 7 | ##### Hash table (Separate Chaining) 8 | http://bit.ly/2KSdJaN 9 | ##### Hash table (Open Addressing) 10 | http://bit.ly/2ZkEdL8 11 | #####Hash table – Open addressing (Linear Probing) 12 | http://bit.ly/2ZCjbTx 13 | ##### Hash table – Open addressing (Quadratic Probing) 14 | http://bit.ly/2HDVYKe 15 | ##### Hash table (Open Addressing - Double Hashing) 16 | http://bit.ly/2ktCQGr 17 | 18 | ကျနော်တို့ hash table မှာ key value တွေထည့်တော့မယ်ဆိုရင် hash လုပ်ပြီးထည့်တယ်။ collision တွေဖြစ်တဲ့အခါ separate chaining တို့ open addressing တို့ technique တွေသုံးပြီး ဖြေရှင်းကြပါတယ်။ ထည့်တဲ့အချိန်မှာလဲ hash လုပ်ပြီးထည့်တယ်ဆို remove လုပ်တဲ့ အချိန်မှာလည်း hash လုပ်ပြီးပဲremove လုပ်ပါတယ်။ ဆိုလိုချင်တာက hash table ထဲမှာထည့်ဖို့အတွက် key ကို hash လုပ်ပြီး position index ရှာတယ်။ remove လုပ်တဲ့ အချိန်မှာလဲ ဖျက်ရမယ့် position index ကို hash လုပ်ပြီးပဲရှာပါတယ်။ ဒါပေမဲ့လည်း remove လုပ်တာကဒီလောက်ကြီး မရိုးရှင်းပါဘူး။ အောက်မှာ scenario လေးတစ်ခုနဲ့ဆွေးနွေးသွားပါမယ်။ 19 | 20 | ![Image of Abstraction](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/hashtable/open%20addressing/removing.png) 21 | photos credit to udemy 22 | 23 | ကျနော်တို့မှာ table size 5 ခုပါတဲ့ အရာတစ်ခုရှိတယ်ဆိုပါစို့ ။ အခန်း 1(key1, val1) , 2(key2,val2) , 3(key3,val3) မှာ key&value တွေရှိတယ်။ key2 ကိုစမ်းဖျက်ကြည့်ရမယ်ဆို အရင်ဆုံး key2 ကို hash လုပ်ပြီးတော့ position index ကိုရှာပါမယ်။ အကယ်လို့ result က 2 ရတယ်ဆိုရင်တော့ အထဲကို ကြည့်ပြီး key2 သေချာတယ်ဆို ဖျက်မယ်။ အကယ်လို့ 2 မဟုတ်တဲ့ တစ်ခြားတစ်ခုရခဲ့မယ်ဆိုရင် အထဲကိုစစ်ကြည့်မယ်၊ key2 မဟုတ်ဘူးဆို မဖျက်ဘဲနဲ့ ဆက်ပြီးတော့ probing လုပ်ပြီးတော့ key2 ကိုရှာပြီးဖျက်ပါမယ်။ အိုကေ key2 ကိုရပြီ၊ ဖျက်လိုက်ပြီရင် အဲ့ slot index က null ဖြစ်သွားပါတယ်။ 24 | 25 | Null ဖြစ်သွားရင်ဘာဖြစ်လဲဆိုတော့ Hash table မှာ searching လုပ်တဲ့အချိန်မှာ issue ဖြစ်ပါတယ်။ ဆိုပါတော့ ကျနော်တို့ က key3 ကိုရှာချင်တယ်။ probing လုပ်ပြီးတော့ တစ်ဆင့်ချင်းဆီသွားတယ်။ index 1 ရတယ်၊ စစ်တယ် ၊ key1 တွေ့တယ်၊ probing ဆက်လုပ်တယ်၊ index2 မှာ null ကြီးဖြစ်နေတယ်။ hashtable ရဲ့ သဘောတရားက အဲ့လို null ကို အရင်တွေ့သွားပြီဆို သူ့တို့ရှာမယ့် key3 က မရှိတော့ဘူးလို့ယူဆလိုက်ပါတယ်။ ဆိုတော့ remove လုပ်တဲ့ case မှာ remove ပြီးတိုင်း null မထားဘဲနဲ့ unique marker တစ်ခုထားလိုက်ပါတယ်။ 26 | 27 | အဲ့ဒီ unique marker ကို tombstone လို့ခေါ်ပါတယ်။ remove လုပ်ပြီးတိုင်း အဲ့ဒီ slot index မှာ tombstone လေးတွေထားခဲ့တယ်။ ဒါဆိုရင် searching လုပ်တဲ့အချိန်မှာ tombstone တွေတွေ့ရင် skip လုပ်ပြီး probing ဆက်လုပ် ဆက်ရှာ၊ ဒါမျိုးလုပ်သွားလို့ရပါတယ်။ tombstone နဲ့ပတ်သတ်ပြီး မှတ်စရာ ၂ မျိုးရှိပါတယ်။ 28 | 29 | ဒါကတော့ table resizing လုပ်လိုက်တဲ့အချိန်ကျ tombstone တွေအကုန်ပျောက်ပါတယ်။ null တွေပြန်ဖြစ်တယ်ပေ့ါ။ resize လုပ်ပြီးသွားရင် key&value အကုန် hash လုပ်ပြီးပြန်ထည့်တဲ့အတွက် tombstone တွေမလိုတော့တဲ့အတွက်ကြောင့်ဖြစ်ပါတယ်။ နောက်တစ်ချက်က tombstone တွေကို key&value တွေနဲ့ အစားထိုးလို့ရပါတယ်။ ဥပမာပြောရရင် ကျနော်တို့ key တစ်ခုကို lookup (search) လုပ်တော့မယ်ဆိုပါစို့၊ probing လုပ်တယ်၊ စစချင်းမှာတင် tombstone တွေ့တယ်၊ ရှာတာမတွေ့သေးတဲ့ အတွက် probing ထပ်လုပ်ပြီး ထပ်ရှာတယ်။ ၄ ခေါက်မြောက်မှာ ကိုယ်ရှာတဲ့ key တွေ့ပြီးပဲဆိုပါစို့ ၊ lookup လုပ်တဲ့ process အပြီးမှာ ခုနတုန်းက ရှာတဲ့ process မှာ ကိုယ်ရှာတဲ့ key မတွေ့သေးချိန်မှာ တွေ့လိုက်တဲ့ tombstone ရှိတဲ့ slot နေရာမှာ သွားအစားထိုးထားလို့ရပါတယ်။ ဒါဆိုရင်နောင်တစ်ချိန် lookup ပြန်လုပ်တဲ့နေရာမှာ ၄ ကြိမ်ရှာစရာမလိုတော့ဘဲ first try မှာတင် ရှာတွေ့သွားမှာပဲဖြစ်ပါတယ်။ 30 | 31 | ဒါဆိုရင်တော့ hash table နဲ့ပတ်သတ်ပြီး article တွေစုံသွားပြီလို့ထင်ပါတယ်။ hash table နဲ့ပတ်သတ်တဲ့ article တွေပြန်ပြီး wrap up လုပ်ပေးလိုက်ပါမယ်။ 32 | -------------------------------------------------------------------------------- /articles/hashtable-separatechaining.md: -------------------------------------------------------------------------------- 1 | ## hash table (separate chaining) 2 | 3 | ပြီးခဲ့တဲ့နေ့က hash table အကြောင်းကို intro ဝင်ပြီးသွားပြီ။ hash table မှာ issue ဖြစ်နေတဲ့ collision အကြောင်းလည်းရေးခဲ့ပါတယ်။ ဒီနေ့တော့ အဲ့လို collision တွေကို ဖြေရှင်းတဲ့ နည်းလမ်းထဲက popular အဖြစ်ဆုံးနဲ့ နားလည်ရလွယ်တဲ့ method တစ်ခုဖြစ်တဲ့ separate chaining အကြောင်းကို ဆွေးနွေးသွားပါမယ်။ ရှင်းရှင်းပြောရင် separate chaining က linked list algorithm ပေါ်ကို မှီငြမ်းပြီးတော့ အလုပ်လုပ်ထားတယ်လို့လဲပြောလို့ရပါတယ်။ 4 | ဆိုတော့ ဒီ article ကိုမဖတ်ခင် hash table ရဲ့ introduction နဲ့ linked list အကြောင်းကို ဖတ်ဖို့အကြံပေးချင်ပါတယ်။ 5 | ##### hashtable - http://bit.ly/2NCd4MH 6 | ##### linked list - http://bit.ly/33LGBsA 7 | 8 | Data structure ကိုတစ်ဖြည်းဖြည်းလေ့လာရင်းနဲ့ သိလာရမှာက data structure တစ်ခုနဲ့ တစ်ခုမှာ မှီခိုနေတာကိုတွေ့လာရပါလိမ့်မယ်။ ဥပမာအနေနဲ့ပြောရရင် priority queue မှာ hash table ကိုထည့်သုံးသလို အခုရေးမယ့် separate chaining မှာလည်း linked list ကိုသုံးထားတယ်၊ စသည်ဖြင့် တစ်ခြား အများကြီးရှိပါသေးတယ်။ 9 | 10 | စကားဦးတွေလည်းများပြီမို့ separate chaining စလိုက်ရအောင်၊ hash table မှာဖြစ်လေ့ရှိတဲ့ collision issue ကိုဖြေရှင်းနိုင်မယ့် strategy တွေထဲကတစ်ခုပဲ ၊ သူ့ရဲ့ ထူးခြားချက်က ဝင်လာသမျှ data node အားလုံးကို တစ်ခုမှဖျက်မပစ်ဘဲနဲ့ collision လည်းမဖြစ်အောင် hash table ရဲ့ data structure လည်းမပျက်အောင် ဖန်တီးပေးထားနိုင်တယ်၊ linked list algorithm ကို အခြေခံပြီး ဖြေရှင်းပေးထားပါတယ်။ 11 | 12 | ဖြေရှင်းနည်းကတော့ ရှင်းတယ်။ ကျနော်တို့ ပုံမှန်အတိုင်း hash table ထဲကို hash လုပ်တယ်၊ value တွေထည့်တယ်။ hash လုပ်လိုက်တဲ့ result က table ထဲမှာရှိပြီးသားဆိုရင် collision ဖြစ်တော့မယ်ပေါ့၊ အဲ့အချိန်ကျရင်လည်း table ထဲက hash result တူတဲ့ node ရဲ့ နောက်မှာပဲ link တွဲပြီးတော့ ထည့်လိုက်တယ်၊ linked list က data insertion လုပ်ပုံနဲ့ အတူတူပါပဲ။ insertion လုပ်တဲ့ case အတွက် ပုံနှစ်ပုံ attach တွဲပေးထားပါတယ်။ ကြည့်ကြည့်ပါ။ 13 | 14 | ### fig 1 example 15 | ![Images of hastable](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/hashtable/separate%20chaining/fig1.%20insertion%20as%20linked%20list.png) 16 | 17 | ### fig 2 example 18 | 19 | ![Images of hastable](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/hashtable/separate%20chaining/fig2.%20insertion%20as%20linked%20list.png) 20 | 21 | Insert လုပ်ပြီးသား data node တွေကို ပြန် ဆွဲထုတ်မယ် (lookup) လုပ်တော့မယ်ဆိုလဲရှင်းတယ်၊ data ကို hash လုပ်မယ်၊ hash result က 4 လို့ရလာပြီပဲဆိုပါတော့၊ no 4 slot မှာသွားကြည့်မယ်၊ သွားကြည့်တာတော့ ဟုတ်ပါပြီ၊ ကျနော်တို့ လိုချင်တဲ့ node မှန်းဘယ်လိုသိနိုင်မလဲပေါ့၊ hash value ကလည်းတူနေတာဆိုတော့ ၊ ကြည့်လို့ရပါတယ်၊ ဘာလို့လဲဆိုတော့ insert သွင်းတုန်းက hash value တစ်ခုတည်းသွင်းလိုက်တာ မဟုတ်ပါဘူး၊ တစ်ခြားတန်ဖိုးတွေလဲပါပါတယ်၊ ဥပမာ- လူတစ်ယောက်ရဲ့ data ဆို name, age, nrc စသည်ဖြင့် ရှိနိုင်တဲ့အတွက် အဲ့ဒီ param တွေနဲ့ပါတိုက်စစ်လို့ရပါတယ်။ ပုံတွဲပေးထားပါတယ်။ 22 | 23 | ### fig 1 example 24 | 25 | ![Images of hastable](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/hashtable/separate%20chaining/fig1.%20selecting%20the%20node.png) 26 | 27 | ### fig 2 example 28 | 29 | ![Images of hastable](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/hashtable/separate%20chaining/fig2.%20selecting%20the%20node.png) 30 | 31 | Remove လုပ်မယ်ဆိုလဲ lookup လုပ်တဲ့အတိုင်းပဲ သွားပြီးတော့ lookup လုပ်မယ့် option အစား linked list ကို ဖျက်ချလိုက်ရုံပါပဲ။ separate chaining မှာ linked list မှရယ်မဟုတ်ဘူး၊ တစ်ခြား algorithm တွေနဲ့လဲ အစားထိုးလို့ရတယ်၊ like array, binary tree စသည်ဖြင့် သုံးလို့ရတယ်၊ ဒါပေမဲ့ complexity level က linked list ထက်စာရင် ပိုရှုပ်တဲ့ အတွက် linked list ကိုပဲ အသုံးပြုကြတာ များပါတယ်။ 32 | 33 | photos credit to udemy 34 | -------------------------------------------------------------------------------- /articles/hashtable_hashing.md: -------------------------------------------------------------------------------- 1 | ## Hash table (hash function) 2 | 3 | Hash table အကြောင်းပြောတော့မယ်ဆိုတော့ hash table ဆိုတာ ဘာလဲကနေစတာပေါ့။ 4 | Hash table ဆိုတာ hashing ဆိုတဲ့ technique တစ်ခုကိုသုံးထားပြီးတော့ key နဲ့ value ကို mapping (တွဲ) ထားပေးတဲ့ structure တစ်ခုလို့ ဆိုနိုင်ပါတယ်။ frequency value တွေကို သူ့ရဲ့ associated key တွေနဲ့ တွဲပြီးတော့လည်း သိမ်းပါတယ်။ ကျနော်အရင်က priority queue article ရေးတုန်းက priority queue တွေကို hash table နဲ့ တွဲပြီးအလုပ်လုပ်ပုံကိုလည်းရေးပေးထားပါသေးတယ်။ အောက်က link မှာဝင်ဖတ်ကြည့်လို့ရပါတယ်။ hash table ဘာကြောင့်သုံးရတာလဲ ၊ ဘယ်လိုအသုံးဝင်လဲဆိုတာတွေကို အဲ့ဒီ article ဖတ်လိုက်ရင်နားလည်သွားပါလိမ့်မယ်။ 5 | http://bit.ly/2Nfd5Wl 6 | 7 | ဒီနေ့တော့ hash table မှာသုံးတဲ့ technique တစ်ခု ဖြစ်တဲ့ hashing အကြောင်းကို ဆွေးနွေးပေးသွားမှာပဲဖြစ်ပါတယ်။ 8 | 9 | Hash table မှာ key & value map လုပ်မသွားခင်မှာ hashing အရင်လုပ်ရပါတယ်။ ပြောရမယ်ဆိုရင်တော့ key ကို hash လုပ်တာပေါ့၊ hash လုပ်တဲ့နေရာမှာ modulus နဲ့ hash လုပ်ကြည့်တာပေါ့၊ size 10 ခုရှိတဲ့ table မှာဆို hash ကိုတွက်တဲ့ formula ပြီးတိုင်း mod by 10 ဆိုပြီးလုပ်ပြီး တွက်တာပေါ့။ ဥပမာ - key of x ကို hash မယ်ဆိုရင် 10 | F(x) = (square of x - 6x + 9) mod 10 ဆိုပြီး ိhash လုပ်ကြည့်လို့ရပါတယ်။ x နေရာမှာ integer value တွေထည့်ပြီးတွက်ထုတ်ကြည့်မယ်ဆို ၁ ကနေ ၁၀ အတွင်း value တွေထွက်လာလိမ့်ပါမယ်။ တစ်ကယ်တော့ integer မှရယ် hash လုပ်လို့ရတာ မဟုတ်ပါဘူး၊ တစ်ခြား data type တွေကိုလည်း hash လို့ရပါတယ်၊ ဥပမာ string ဆိုရင် သူ့ရဲ့ ASCII value ထုတ်လိုက်မယ်ဆို integer value ပြန်ရပါမယ်၊ hashing function ထဲ ထည့်တွက်လို့ရပါတယ်။ 11 | 12 | Hash function မှာလည်း သူ့ရဲ့ ကိုယ်ပိုင် properties တွေရှိပါတယ်။ 13 | - အကယ်လို့ F(x) နဲ့ F(y) ရဲ့ result တွေက တူတယ်ဆိုရင် x နဲ့ y ရဲ့ တန်ဖိုးတွေက တူကောင်းတူနိုင်ပါတယ်လို့ ဆိုနိုင်ပေမဲ့ f(x) နဲ့ f(y) result ကမတူဘူးဆိုရင် x and y ရဲ့ value တွေက လုံးဝတူမှာမဟုတ်ပါဘူး။ (ဒီ property ကဘာအသုံးဝင်လဲဆိုတော့ ထားပါတော့ x and y က size ကြီးတဲ့ ဖိုင်တွေပဲထားပါတော့ compare လုပ်ဖို့လိုလာပြီဆို x and y ကိုတိုက်ရိုက် ထိမယ့်အစား သူတို့ရဲ့ hash value ကို compare လုပ်လိုက်တာ ပိုမြန်ပါတယ်။) 14 | - Hash လုပ်လိုက်တဲ့ value က အမြဲတမ်း deterministic ဖြစ်ရပါမယ်။ ဆိုလိုချင်တာက f(x) ရဲ့ hash value က y ထွက်တယ်ဆို အမြဲတမ်း y ပဲထွက်ရပါမယ်၊ တစ်နည်းအားဖြင့်ဆို constant ဖြစ်ရမယ်လို့လဲဆိုလိုပါတယ်။ 15 | 16 | ဒါပေမဲ့ တစ်ခုရှိတာက collision ဖြစ်နိုင်တဲ့ case ပါ၊ အပေါ်က ကျနော်ပြထားတဲ့ hash တွက်တဲ့ function မှာဆို (F(x) = (square of x - 6x + 9)) , x ရဲ့ တန်ဖိုးကို 4 နဲ့ 2 နဲ့ ထည့်မယ်ဆို ရလာမယ့်အဖြေက 1 ချင်းတူနေပါတယ်။ ဒီလို case မျိုးဆို collision ဖြစ်တယ်လို့ ပြောရမယ်ပေါ့။ ဒီလိုမျိုး collision တွေဖြစ်လာပြီဆိုရင် ဖြေရှင်းနိုင်ဖို့အတွက်လည်း solution တွေထုတ်ထားပါတယ်။အဲ့ထဲကမှ popular ဖြစ်တာတွေက တော့ separate chaining နဲ့ open address ဆိုပြီးရှိပါတယ်။ နောက် article တွေမှာ အဲ့ဒီ solution အကြောင်းတွေရေးပေးသွားပါမယ်။ 17 | 18 | Stay Tune! 19 | 20 | ![Images of hastable](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/hashtable/hash%20function/fig1.%20hash%20function.png) 21 | 22 | ![Images of hastable](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/hashtable/hash%20function/fig2.%20hash%20function.png) 23 | 24 | 25 | photos credit to tutorialpoint 26 | -------------------------------------------------------------------------------- /articles/hastable-openaddressing-doublehashing.md: -------------------------------------------------------------------------------- 1 | ## Hash table - Open addressing (Double Hashing) 2 | 3 | Hash table အကြောင်းရေးနေတဲ့ series ထဲ က open addressing မှာသုံးတဲ့ probing function တစ်ခုဖြစ်ပါတယ်။ အရင် article တွေ ဖတ်ပြီးမှ ဒီ article ဖတ်တာ ပိုအဆင်ပြေပါမယ်။ 4 | 5 | Hash table (hashing) 6 | http://bit.ly/2NCd4MH 7 | 8 | Hash table (Separate Chaining) 9 | http://bit.ly/2KSdJaN 10 | 11 | Hash table (Open Addressing) 12 | http://bit.ly/2ZkEdL8 13 | 14 | Hash table – Open addressing (Linear Probing) 15 | http://bit.ly/2ZCjbTx 16 | 17 | Hash table – Open addressing (Quadratic Probing) 18 | http://bit.ly/2HDVYKe 19 | 20 | double hashing လို့ဆိုပေမဲ့ အရှေ့က article တွေလိုမျိုးဖြစ်တဲ့ probing function တစ်ခုပဲဖြစ်ပါတယ်။ သူကတော့ probing formula ထုတ်တဲ့ အချိန်မှာ hashing နောက်တစ်ခုထပ်ထည့်ပြီး probing လုပ်လိုက်သလိုပေါ့။ ဥပမာ 21 | P(key,value) = value*H(key) . H(key)ဆိုတာကတော့ ကျနော်တို့အခုပြောတဲ့ secondary function ပဲဖြစ်ပါတယ်။ 22 | Hash table နဲ့သူ့နဲ့ ပတ်သတ်တဲ့ အကျိုးအကြောင်းတွေကိုတော့ ရှေ့ က article တွေမှာ တော်တော်များများပြောပြီးသွားပြီဆိုတော့ ဒီ double hashing article မှာ cycle issue ဖြစ်တဲ့အချိန် ဘယ်လိုကိုင်တွယ်မလဲ နဲ့ အခုသုံးတဲ့ double hasing ကိုဘယ်လိုလုပ်လဲဆိုတာပါပဲ။ ကျန်တာတွေကတော့ ရှေ့ က probing function တွေလုပ်ထုံးလုပ်နည်းနဲ့ အတူတူပါပဲ 23 | 24 | Cycle issue ကိုဖြေရှင်းနည်းက linear probing မှာ ရှင်းတာနဲ့ဆင်ပါတယ်။ GCD အားကိုးနဲ့ပါပဲ။ အရင်ဆုံး delta value တစ်ခုထုတ်တယ်။ 25 | Delta = 2ndhashfunction mod N , ဒီနေရာမှာ table size N က prime number ဖြစ်နေရပါမယ်။ delta ကို 0 ထွက်လို့မရပါဘူး။ 0 ထွက်ရင် equation ထဲ ထည့်သုံးလိုက်ရင် cycle issue ထဲရောက်မှာကျိန်းသေပါတယ်။ ဆိုတော့ delta value က greater than or equal to 1 and less than N ဖြစ်ရပါတယ်။ ဆိုတော့ နောက်တစ်ဆင့် အနေနဲ့ GCD တန်ဖိုးကိုတွက်တော့မယ်ဆို GCD(delta,N) နဲ့တွက်ပါမယ်။ table size N က prime number ဖြစ်နေတဲ့အတွက် ရလဒ်က 1 ထွက်ပါမယ်။ GCD တန်ဖိုး 1 ရမယ်ဆိုရင် cycle issue ကိုဖြေရှင်းပြီးသားဖြစ်သွားပါလိမ့်မယ်။ 26 | 27 | Hashing ကိုပြောရမယ်ဆိုရင် double hash လုပ်တဲ့နေရာမှာ လုပ်ရမယ့် value တွေက fundamental blocks တွေပဲဖြစ်ပါတယ်။ ဥပမာ integer, strings, real number စသည်ဖြင့်ပေ့ါ။ fundamental blocks တွေအတွက် hash function သုံးတော့မယ်ဆိုရင် universal hash functions တွေထဲက လှမ်းဆွဲသုံးပါတယ်။ အောက်မှာ wiki link ပါပါတယ်။ 28 | https://en.wikipedia.org/wiki/Universal_hashing 29 | 30 | ![Images of hashtable](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/hashtable/open%20addressing/doublehashing.jpg) 31 | photo credits to udemy 32 | 33 | resizing လုပ်တဲ့ technique ကလည်း ကျန်တဲ့ probing function တွေနဲ့အတူတူပါပဲ။ ဒါဆိုရင်တော့ hash table ရဲ့ open addressing မှာ popular ဖြစ်တဲ့ probing function သုံးခုလုံးပြီးသွားပြီ။ လက်ရှိမှာတော့ hash table ထဲကို key value တွေ insert လုပ်တဲ့ case နဲ့ပဲပြောထားတာဆိုတော့ နောက် article မှာ removing case ကိုရေးပေးသွားပါမယ်။ 34 | -------------------------------------------------------------------------------- /articles/introduction.md: -------------------------------------------------------------------------------- 1 | ## Data Structures & Algorithms 2 | 3 | Applications တွေ system တွေက တစ်ဖြည်းဖြည်းနဲ့ ကျယ်ပြန့်လာတဲ့ အချိန်၊ data တွေများပြားလာတဲ့အချိန်မှာ အဲ့ဒီ များပြားလာတဲ့ data တွေကို manage လုပ်ဖို့ဆိုတာကလဲ challenging တစ်ခုဖြစ်လာပါတယ်။ manage လုပ်တယ်ဆိုတာထက် ဒီလို million , billion, trillion ချီတဲ့ data တွေကို performance ကောင်းစွာ ဘယ်လို handle လုပ်မလဲ process လုပ်မလဲဆိုတာက တစ်ကယ်ကို အရေးကြီးတဲ့ အပိုင်းတစ်ခုအနေနဲ့ ရှိလာပါတယ်။ ဒါကြောင့်မို့လဲ data structures and algorithms ဆိုပြီးတော့ ဖြစ်ပေါ်လာတာပါ။ 4 | 5 | Data structures and algorithms တွေကိုအသုံးပြုပြီးတော့ data တွေအများကြီးကို ကောင်းမွန်စွာ handle ပြုလုပ်လာနိုင်ပါတယ်။ ကျနော်တို့ လက်ရှိအသုံးပြုနေတဲ့ systems တွေ applications တွေအားလုံးက data structures တွေ algorithms တွေနဲ့ ဖွဲ့စည်းထားတာပဲဖြစ်ပါတယ်။ 6 | 7 | Algorithms ဆိုတာက အရှင်းဆုံးပြောရရင် step by step procedure ပဲ။ operation တစ်ခု run နိုင်ဖို့အတွက် တစ်ဆင့်ခြင်းဆီ instructions တွေနဲ့ တည်ဆောက်ထားတဲ့ သဘောတရားပါပဲ။ ဥပမာ ကျနော် facebook ပေါ် article တွေတင်တာကို algorithm အနေနဲ့ ပြောရရင် 8 | 9 | 1. ကိုယ်ရေးချင်တဲ့စာကို သေချာအောင် research လုပ်တယ်။ 10 | 2. Short notes တွေပြန်ထုတ်တယ်။ 11 | 3. စာစီတယ် ၊ စာရေးတယ် 12 | 4. အမှားစစ်တယ် 13 | 5. Facebook ပေါ်တင်တယ်။ 14 | ဒါဆို ရင် facebook ပေါ်ကျနော့် article ရောက်သွားဖို့ အတွက် ဒီ instructions တွေကို တစ်ဆင့်ခြင်းဆီ ကျနော်လုပ်ပါတယ်။ ခြွင်းချက်ရှိတာကတော့ အမြဲတမ်း step by step ကြီးသွားနေတာမျိုးလဲမဟုတ်ဘူး၊ တစ်ခါတစ်လေကျ problem concept ပေါ်မူတည်ပြီး ပြောင်းလဲရတာလဲရှိနိုင်ပါတယ်။ 15 | 16 | Algorithm တွေကို ဘယ် programming နဲ့မှ ရေးလို့ရမယ်ဆိုပြီး ကန့်သတ်ထားတာမရှိဘူး၊ programming တိုင်းမှာ fundamental code construction တွေပါပြီးသားဖြစ်တဲ့အတွက် ဘာနဲ့ဖြစ်ဖြစ်ဆောက်လို့ရပါတယ်။ 17 | 18 | Algorithm တွေရဲ့ complexity ကိုကြည့်မယ်ဆို ၂ မျိုးခွဲခြားထားလို့ရတယ်။ 19 | - Number of operation ပေါ်မူတည်ထားတဲ့ time complexity နဲ့ 20 | - Memory space ပေါ်မူတည်ထားတဲ့ space complexity ဆိုပြီးတော့ပါ။ 21 | Time complexity ကတော့ algorithm တစ်ခု run ပြီဆို operation ဘယ်နှစ်ကြိမ်လုပ်သွားလဲဆိုတာပေါ်မူတည်ပြီးတွက်တယ်။ space complexity ဆိုတာကတော့ algorithm runtime မှာ system ရဲ့ memory အသုံးပြုပုံမူတည်ပြီးတွက်ပါတယ်။ 22 | 23 | နောက် article မှာ BigO နဲ့အတူ complexity အကြောင်းထပ်ရေးပေးထားပါတယ်။ 24 | -------------------------------------------------------------------------------- /articles/linkedlist.md: -------------------------------------------------------------------------------- 1 | ## Linked lists Algorithm 2 | 3 | Linked list ဆိုတာ ကကျ data node တွေကို sequence အတိုင်း link လုပ်ထားတာ။ မြင်အောင် ပြောရမယ်ဆိုရင် list စစချင်းမှာ head ရှိမယ်၊ အဆုံးမှာ tail ရှိမယ်၊ ကြားထဲမှာ data node တွေနဲ့ သူတို့ကို ချိတ်ဆက်ထားတဲ့ link တွေရှိမယ်။ attach တွဲထားတဲ့ ပုံတွေ ကြည့်လိုက်ရင်တော့ ပိုရှင်းသွားလိမ့်မယ်။ 4 | 5 | Linked lists တွေကိုပြန်ခွဲကြည့်မယ်ဆို 6 | - Singly linked list 7 | - Doubly linked list 8 | - Circular linked list 9 | ဆိုပြီးရှိတယ်။ 10 | 11 | Singly linked list ကကျ တော့ data node တွေကြားမှာ ချိတ်ဆက်ထားတဲ့ link တွေက node တစ်ခုခြင်းဆီရဲ့ forward ကိုပဲ ချိတ်လို့ရတယ်၊ backward (previous node) ကို link ပြန်လုပ်ထားတာမရှိဘူး။ 12 | 13 | Doubly linked list ကတော့ node တွေအကုန်လုံးကို forward ရော backward ရော link လုပ်ထားတယ်၊ ဆိုတော့ ပိုပြီးတော့ အသုံးဝင် တယ်လို့ဆိုရမယ်။ previous data ကို ပါ လှမ်း access လုပ်လို့ရတာကိုး။ 14 | 15 | Circular linked list က သူ့ နာမည်အတိုင်းပဲ circular ပြန်လုပ်ပြီး link တယ်၊ singly linked list မှာဆို tail ကနေ head ဆီကို လှမ်းပြီး link လုပ်ထားတယ်။ doubly linked မှာက ကျ tail ကနေ head ကိုလည်း link တယ်၊ doubly ရဲ့ ထုံးစံအတိုင်း head ကနေလည်း tail ကို ပြန်ပြီး link လုပ်တယ်။ 16 | 17 | Singly Linked List 18 | ![Images of linked list](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/linked%20lists/singly%20linked%20list.png) 19 | 20 | Doubly Linked List 21 | ![Images of linked list](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/linked%20lists/doubly%20linked%20list.png) 22 | 23 | 24 | Operation လုပ်ပုံလုပ်နည်း ကလည်း နည်းနည်းဆီကွာတယ်။ insert လုပ်တဲ့ပုံကို အရင်ပြောကြည့်ရမယ်ဆိုရင် 25 | 26 | Singly linked list မှာ 3rd node မှာ node အသစ်တစ်ခုထည့်မယ်ဆိုပါစို့။ node တစ်ခုခြင်းဆီကို traverse လုပ်တယ်၊ ဒုတိယမြောက်မှာ ရပ်လိုက်တယ်၊ထည့်မယ့် value node ကို create လုပ်တယ်၊ တတိယမြောက် node ကို pointer ထောက်တယ်၊ traverser ရပ်ထားတဲ့ ဒုတိယမြောက် element ကို သူနဲ့ ချိတ်တယ်၊ ပြီးတာနဲ့ insert လုပ်လိုက်တယ်။ 27 | 28 | Doubly linked list မှာလည်း insert operation မှာ singly နဲ့အတူတူပဲ ကွာသွားတာ က singly က link ချိတ်တဲ့ နေရာမှာ forward link ပဲချိတ်ရပေမဲ့ doubly မှာ previous ရော forward အတွက်ပါချိတ်ပေးရတယ်။ 29 | 30 | Singly Linked List Inserting Operation 31 | ![Images of linked list](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/linked%20lists/singly%20linked%20list%20inserting%20operation.png) 32 | 33 | Doubly Linked List Inserting Operation 34 | ![Images of linked list](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/linked%20lists/doubly%20linked%20list%20inserting%20operation.png) 35 | 36 | Remove operation မှာတော့ ပိုပြီးကွာတယ်။ singly မှာ remove operation လုပ်တော့မယ်ဆို traverser နှစ်ခုနဲ့သွားရတယ်။ trav1 & trav2 ပေါ့၊ remove လုပ်ရမယ့် node ကို trav2 ကတွေ့သွားပြီးဆို တွေ့သွားတဲ့ node ကို memory ထဲမှာ temporary allocate လုပ်လိုက်တယ်။ allowcate လုပ်ပြီးတာနဲ့ trav2 က နောက် node တစ်ခုကို ထပ်သွားတယ်၊ ပြီးတော့မှ temp allocate ထားတယ့် node ကို ဖြတ်ချပြီး deallocate ပြန်လုပ်လိုက်တယ်။ trav1 & 2 ကို လည်း linked ပြန်လုပ်လိုက်တယ်။ 37 | 38 | Doubly မှာတော့ traverser နှစ်ခုမလိုဘူး။ တစ်ခုနဲ့ ဆိုရတယ်။ ဘာလို့လဲဆိုတော့ သူ့မှာက previous ရော forward ရောချိတ်လို့ရတယ်။ singly မှာက မရှိတဲ့အတွက် reference key လိုလို့ traverser နှစ်ခုနဲ့ သွားရတာ။ ဖြတ်ရမယ့် node ရောက်ပြီဆို သူ့ရဲ့ ရှေ့ node နဲ့ နောက် node ကို forward & backward link ချိတ်ပေးပြီး ဖြတ်လိုက်တယ်။ 39 | 40 | Singly Linked List Removing Operation 41 | ![Images of linked list](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/linked%20lists/singly%20linked%20removing%20operation.png) 42 | 43 | Doubly Linked List Removing Operation 44 | ![Images of linked list](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/linked%20lists/doubly%20linked%20removing%20operation.png) 45 | 46 | နှစ်ခုလုံးမှာတော့ draw back တွေရှိတယ်။ singly က memory use တာနည်းပေမဲ့ previous element ကိုပြန်သွားလို့မရဘူး။ doubly က previous node ပြန်သွားလို့ရတယ်၊ memory လည်း နှစ်ဆပိုကုန်တယ်။ 47 | 48 | ဘယ်လိုနေရာတွေမှာ သုံးလည်း ဆိုတော့ sequentially linked လုပ်ထားတဲ့ process တော်တော်များများမှာ သုံးတယ်။ ဥပမာ file system တစ်ချို့ မှာ file locations တွေကို linked လုပ်ပြီး သိမ်းထားတာတို့ ၊ browser history မှာ သိမ်းထားတဲ့ page တွေမှာ back ပြန်သွားလို့ရတာမျိုးတို့ ၊ memory block တွေကို linked လုပ်ထားတဲ့ low level memory management system တို့မှာတို့ အစရှိတဲ့ နေရာတော်တော်များများမှာ သုံးထားတယ်။ linked list ရဲ့ သဘောတရားကို နားလည်သွားပြီဆိုရင် ဘယ်လို technology မှာ linked list algorithm သုံးထားလည်းဆိုတာ ခန့်မှန်းလို့ရသွားနိုင်မယ့် အပြင် ကိုယ်ကိုတိုင်လည်း develop လုပ်သွားနိုင်မှာပါ။ 49 | 50 | photos credit to Udemy 51 | -------------------------------------------------------------------------------- /articles/priority_queue.md: -------------------------------------------------------------------------------- 1 | ## Priority Queue In Data Structure & Algorithm 2 | 3 | Priority Queue ဆိုတာကတော့ ပုံမှန် regular queue data structure ကိုပဲ အခြေခံပြီးလုပ်ထားတဲ့ structure တစ်ခုပဲ၊ process တော်တော်များများကလည်း ပုံစံအတူတူပဲ၊ မတူပဲ ကွဲပြားသွားတာက ဘာလဲဆိုတာ Priority Queue (PQ လို့ပဲခေါ်သွားပါမယ်) မှာက သူ့ထဲမှာ ပါတဲ့ data node တစ်ခုခြင်းဆီ က priority order လေးတွေပါတယ်။ ဆိုလိုချင်တာက ဘယ် node က ဘယ် node ထက် အရေးကြီးတယ်ဆိုတာမျိုးကို ပြောနိုင်ဖို့အတွက် ကိုယ်ပိုင် priority value လေးတွေပါတယ်။ PQ ကိုယ်တိုင်ကလည်း comparable model ဖြစ်တယ်၊ အဲ့လို compare လုပ်နိုင်ဖို့အတွက် က data node တွေမှာ priority value တွေမဖြစ်မနေပါရမယ်၊ ဒါမှလည်း PQ က ဘယ် node က ပိုအရေးကြီးတယ်ဆိုတာခွဲလို့ရမှာဖြစ်တယ်။ queue algorithm ရဲ့ article ကိုတော့ အောက်က link မှာဖတ်နိုင်ပါတယ်။ 4 | 5 | https://www.facebook.com/permalink.php?story_fbid=855508051471907&id=100010381592688 6 | 7 | PQ အလုပ်လုပ်ပုံက လွယ်မယောင်နဲ့ နည်းနည်းတော့ ခက်ပါတယ်။ ဘာလို့လွယ်တာလဲ ဆိုတော့ သူ့ရဲ့ အလုပ်လုပ်ပုံကရှင်းပါတယ်။ queue တစ်ခုထည့်တော့မယ်ဆို queue ရဲ့ data node နဲ့အတူ သူ့ရဲ့ priority value လည်းပါလာပါတယ်။ PQ က priority value အမြင့်ဆုံး data node ကို အရင် process လုပ်ပေးပါတယ်။ ဥပမာ ပြောရမယ်ဆိုရင် data node တွေရဲ့ priority value တွေက ဒီလိုတွေရှိမယ်ဆိုပါစို့ ၊ 8 | 9 | 4,5,1,3,8,2,1,3,6,9 priority ဂဏန်း အနည်းဆုံး node ကို priority value အမြင့်ဆုံးလို့ သတ်မှတ်ပြီး process လုပ်ကြည့်လိုက်မယ်ဆို အောက်မှာရေးထားသလိုဖြစ်သွားမှာပါ။ 10 | 11 | 1,1,2,3,3,4,5,6,8,9 . PQ က အဲ့လိုပြန် order လုပ်ပြီး run သွားမှာပါ။ ပြောချင်တာက priority value အများဆုံး node တွေကို အရင် run သွားတာပါ။ ဘာလို့ခက်တယ် ပြောတာလဲဆိုတော့ ဒီလိုပါ၊ ကျနော်တို့ က အခု ဘယ် priority value က မြင့်တယ် ဘာညာ ဆိုတာကို မျက်စိနဲ့ ကြည့်ပြီး စီလိုက်လို့ပါ၊ 1 က အမြင့်ဆုံး 9 က အနိမ့်ဆုံး ဆိုတာကို မျက်စိနဲ့ ကြည့်ပြီး တော့ ပဲဆုံးဖြတ်လိုက်တာပါ။ ဒါပေမဲ့ PQ မှာ ဘယ်သူ က မြင့်တယ် ၊ နိမ့်တယ် ဆိုတဲ့ order ကို ဘယ်လိုဆုံးဖြတ်မှာလဲ။ အဲ့လိုဆုံးဖြတ်ဖို့အတွက် data structure နောက်တစ်ခုကိုသုံးပါတယ်။ Heap လို့ခေါ်ပါတယ်။ 12 | 13 | PQ ဆောက်ဖို့အတွက် heap မှရယ် မဟုတ်ပါဘူး။ တစ်ခြား structure တွေနဲ့လည်း အသုံးပြုပြီး ဆောက်လို့ရတယ်၊ ဒါပေမဲ့ commonly အသုံးများတာကတော့ Heap ပါပဲ။ Heap ဆိုတာဘာလည်း ဆိုတော့ သူက tree based structure တစ်ခုပဲ၊ အဲ့ဒီ tree based structure မှာကိုမှ သူ့ရဲ့ rules တွေရှိတယ် (သူကတော့ heap invariant) လို့ခေါ်တယ်။ ဘာကိုဆိုလိုချင်တာလဲဆိုတော့ သူ့မှာ Min Heap & Max Heap ဆိုပြီး နှစ်မျိုးရှိတယ်။ min heap ဆိုရင်လဲ root node ကအသေးဆုံးဖြစ်ပြီး သူ့အောက် က child node တွေက သူ့ထက် ထပ်သေးသွားလို့မရတော့ဘူး။ max heap လည်း ထိုနည်းလည်းကောင်းပဲ အောက်က child nodes တွေက root ထက် ထပ်ကြီးသွားလို့မရတော့ဘူး။ 14 | 15 | ဒါဆိုလို့ရှိရင် heap ရဲ့ order အလိုက်စီထားတဲ့ structure နဲ့ PQ ရဲ့ priority value ဆက်စပ်ပုံကို တွေးမိလို့ရမယ်ထင်ပါတယ်။ heap ကလည်း min ဆိုရင် min အတိုင်းစီတယ်။ max ဆို max အတိုင်းစီတယ်။ PQ မှာလည်း priority value ရဲ့ အစဉ်အတိုင်း process လုပ်တယ်။ 16 | 17 | PQ ကိုသုံးပြီးတော့ implement လုပ်ထားတဲ့ algorithm တွေလည်း ရှိတယ်။ sorting algorithm ဖြစ်တဲ့ heapsort တို့ min key node တွေကို extract လုပ်တဲ့ prim algorithm တို့ load balancing မှာ traffic တွေ manage လုပ်တဲ့ နေရာတို့ စသည်ဖြင့်အသုံးပြုထားတာတွေအများကြီးလည်းရှိတယ်။ တစ်ကယ်လည်း strong ဖြစ်တယ်။ 18 | 19 | ဒီ article မှာတော့ PQ ကိုအဓိကထားပြီးပြောသွားတဲ့အတွက်ကြောင့် Heap အကြောင်းက Introduction အနေနဲ့ပဲပါသေးတယ်။ Heap ရဲ့ data operation အပိုင်းက နည်းနည်းလေး သေချာကြည့်ရတယ်။ နောက် article မှာ PQ မှာသုံးတဲ့ Heap အကြောင်းကို ထပ်ရေးပေးသွားပါမယ်။ 20 | 21 | photos credit to Udemy 22 | 23 | Priority Queue & Its Instructions 24 | ![Images of priority queue](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue/what%20is%20pq%20and%20its%20instruction.png) 25 | 26 | What Is A Heap 27 | ![Images of priority queue](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue/what%20is%20a%20heap.png) 28 | -------------------------------------------------------------------------------- /articles/priority_queue_with_heap_part1.md: -------------------------------------------------------------------------------- 1 | ## Priority Queue With Heap (Part 1) 2 | 3 | Priority Queue ကို heap နဲ့ ဆောက်ရတဲ့ အကြောင်းအရင်းက လောလောဆယ်မှာ time complexity အတွက် အသင့်တော်ဆုံးဖြစ်နေသေးလို့ပါ။ တစ်ခြား ဆောက်လို့ရတဲ့ algorithm တွေလဲရှိတယ်၊ ဥပမာ unsorted list တို့ဘာတို့နဲ့ ဆောက်လို့ရတယ် ဒါပေမဲ့ time complexity အတွက်အဆင်မပြေသေးဘူး။ ဒါကြောင့်မို့ heap ကိုပဲ သုံးဖြစ်နေကြတာပါ။ 4 | 5 | ဒီ article ကိုမဖတ်ခင်မှာ Priority Queue ရဲ့ article ကိုအရင်သွားဖတ်ဖို့လိုအပ်ပါတယ်(must)။ Heap အကြောင်းကို Introduction လုပ်ထားတာလဲပါပါတယ်၊ ဒီ article ရှည်သွားမှာဆိုးလို့ထပ် မထည့်တော့ပါဘူး။ အောက်က link မှာသွားဖတ်နိုင်ပါတယ်။ 6 | https://www.facebook.com/permalink.php?story_fbid=856781714677874&id=100010381592688 7 | 8 | ဒီ article မှာ ပုံတွေလည်း တစ်ဆင့်ခြင်းဆီအတွက် attach တွဲပေးထားတယ်။ စာချည်းပဲ ဖတ်ရင် နားလည်ရခက်မှာဆိုးတဲ့ အတွက် ပုံတွေနဲ့ တွဲကြည့်ဖို့ suggest လုပ်ပါတယ်။ 9 | 10 | Priority Queue ဆောက်ဖို့ အတွက် Heap ထဲမှာလည်း 11 | - Binary heap 12 | - Fibonacci heap 13 | - Binomial heap 14 | - Pairing heap အစရှိသည်ဖြင့် အမျိုးအစား အမျိုးမျိုး ရှိတယ်။ လောလောဆယ်တော့ Binary heap ကိုသုံးပြီးတော့ ရှင်းပြပေးသွားပါမယ်။ 15 | 16 | Heap တိုင်းကတော့ tree structure ပဲ သူ့ရဲ့ heap rules တွေကိုလည်းလိုက်နာတယ်။ Binary heap ဆိုတော့ သူ့နာမည်အတိုင်းပဲ binary tree structure ဖြစ်တယ်။ Node တစ်ခုခြင်းဆီတိုင်းမှာလည်း child element နှစ်ခုစီနဲ့ tree structure ဆောက်ထားတယ်။ 17 | 18 | ### What Is Binary Heap 19 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%201/fig%201.%20what%20is%20binary%20heap.png) 20 | 21 | ကျနော် အောက်မှာပုံတွေလည်း attach တွဲပေးထားတယ်၊ တစ်ချို့ စာတွေက ကျပုံတွေနဲ့ တွဲပြီးကြည့်မှ ပိုပြီးထင်သာမြင်သာရှိမှာမို့လို့ပါ။ အခု အရင်ဆုံးအနေနဲ့ binary heap ရဲ့ data represent လုပ်ပုံကို ကြည့်ရမယ်ဆိုရင် သူ့ရဲ့ data node တွေကို array index တွေအတိုင်းမှတ်ထားလို့လည်း ရတယ်၊ ဥပမာ data node value 6 က array index key number 3 မှာရှိတယ် ၊ အဲ့လိုမျိုး present လုပ်လို့လဲရပါတယ် 22 | 23 | ### Binary Heap Representation 24 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%201/fig%202.%20binary%20heap%20representation.png) 25 | 26 | နောက်တစ်ခုအနေနဲ့ parent node တစ်ခုရဲ့ အောက် က child element တွေရဲ့ array index key ကိုလည်း တွက်ထုတ်လို့ရတယ်၊ parent node ရဲ့ array key က 2 လို့ဆိုပါစို့ ၊ child element တွေ ဆွဲထုတ်မယ်ဆို binary tree ဖြစ်တဲ့အတွက် left & right child element ဆိုပြီးရှိမယ်။ left child အတွက်ဆို (2(current_node_key) + 1) = 5 ရမယ်၊ right child အတွက်ဆို (2(current_node_key)+2)=6 ရပါမယ်။ 27 | 28 | ### Binary Heap Representation 29 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%201/fig%203.%20binary%20heap%20representation.png) 30 | 31 | Binary heap မှာ data element insert လုပ်တော့မယ်ဆိုရင် သူ့ရဲ့ tree structure အရ အမြဲတမ်း left to right သွားပါတယ်။ insert လုပ်ပြီဆို အောက်ခြေ row ကနေ စပါတယ်။ အောက်ဆုံးအတန်းကနေ left to right ပေါ့။ တစ်ခုရှိတာက ထည့်ပြီးတာနဲ့ ပြီးမသွားဘူး၊ သူ့ရဲ့ heap invariant (အရင် article မှာရေးထားပါတယ်) အတွက်စစ်ရသေးတယ်။ အဆင်မပြေဘူးဆိုရင် တစ်ဆင့်ခြင်းဆီ heap invariant satisfy ဖြစ်တဲ့အထိ parent node နဲ့ replace လုပ်လုပ်သွားတယ်။ အဲ့လို တစ်ဆင့်ခြင်းဆီ တတ်တတ်သွားပြီး heap invariant satify လုပ်တာကို bubbling up လုပ်တယ်လို့လဲ ခေါ်ပါတယ်။ 32 | 33 | ### Adding Elements To Binary Heap 34 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%201/fig%204.1.%20adding%20elements%20to%20binary%20heap.png) 35 | 36 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%201/fig%204.2.%20adding%20elements%20to%20binary%20heap.png) 37 | 38 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%201/fig%204.3.%20adding%20elements%20to%20binary%20heap.png) 39 | 40 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%201/fig%204.4.%20adding%20elements%20to%20binary%20heap.png) 41 | 42 | Remove လုပ်တာကတော့ နှစ်မျိုးရှိတယ်။ ရိုးရိုး poll function နဲ့ ဖျက်ချင်တဲ့ value ကို ထည့်ပေးပြီး ဖျက်ရတဲ့ remove 43 | Function ဆိုပြီး ရှိတယ်။ Poll function ကိုအရင်ပြောကြည့်ရအောင်။ ထည့်တုန်းက left to right order နဲ့သွားခဲ့ တာဆိုတော့ ဖျက်မယ်ဆိုရင် right to left ဖြစ်သွားမယ်။ မဖျက်ခင်မှာ ဖျက်ရမယ့် element နဲ့ root node နဲ့ ကို အရင် swap လုပ်တယ်။ ပြီးတော့မှ ဖျက်ချလိုက်တယ်။ root node နေရာမှာ ရောက်သွားတဲ့ element ကို တစ်ဆင့်ခြင်းဆီ heap invariant ဖြစ်အောင် child node တွေနဲ့ replace ပြန်လုပ်တယ်။ bubbling down လုပ်တယ်လို့လဲခေါ်တယ်။ invariant ဖြစ်ပြီးသားဆိုရင်တော့ လုပ်စရာမလိုဘူး။ bubbling down လုပ်ရင်တစ်ခု သတိထားရမှာက parent element တစ်ခုမှာ child ၂ ခုစီ ရှိတယ်။ child ၂ ခုမှာ ငယ်တဲ့ ဘက်ကိုပဲ ရွေးပြီး replace လုပ်ပါတယ်။ အကယ်လို့ နှစ်ခုလံးုက တန်ဖိုးတူနေတယ်ဆို ဘယ်ဘက်ကို ရွေးပါတယ်။ 44 | 45 | ### Removing Elements From Binary Heap(Polling) 46 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%201/fig%205.1%20polling%20elements%20from%20binary%20heap.png) 47 | 48 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%201/fig%205.2%20polling%20elements%20from%20binary%20heap.png) 49 | 50 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%201/fig%205.3%20polling%20elements%20from%20binary%20heap.png) 51 | 52 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%201/fig%205.4%20polling%20elements%20from%20binary%20heap.png) 53 | 54 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%201/fig%205.5%20polling%20elements%20from%20binary%20heap.png) 55 | 56 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%201/fig%205.6%20polling%20elements%20from%20binary%20heap.png) 57 | 58 | Remove(value param) ကကျတော့ သူ့မှာ ဖျက်ချင်တဲ့ value parameter ပါလာပြီဖြစ်တဲ့ အတွက် အဲ့ဒီ value ကို tree မှာတစ်ဆင့်ခြင်းဆီ လိုက်ရှာရပါတယ်၊ အပေါ်ဆုံးအတန်းကနေပြီးတော့ အောက်အထိ တစ်ဆင့်ခြင်းဆီ left to right ရှာပါတယ်။ အဲ့လို ရှာရတဲ့အတွက် Linear time ကြာတယ်လို့ဆိုရမှာပေါ့။ တွေ့ပြီဆိုရင် အဲ့ဒီ element နဲ့ လက်ရှိနောက်ဆုံး မှာရှိနေတဲ့ element ကို swap လုပ်တယ်။ swap လုပ်ပြီး နောက်ဆုံး element ကိုပဲဖြတ်တယ်။ ပြီးရင် heap invariant ဖြစ်အောင် ပြန်စီတယ်။ bubbling up or down ပြန်လုပ်တယ်ပေါ့။ 59 | 60 | ### Removing Elements From Binary Heap 61 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%201/fig%206.1%20removing%20elements%20from%20binary%20heap%20with%20value%20parameter.png) 62 | 63 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%201/fig%206.2%20removing%20elements%20from%20binary%20heap%20with%20value%20parameter.png) 64 | 65 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%201/fig%206.3%20removing%20elements%20from%20binary%20heap%20with%20value%20parameter.png) 66 | 67 | Part 2 မှာ hashtable ကို သုံးပြီးတော့ heap မှာ data ထည့်တာထုတ်တာတွေထပ်ပြောပြပေးသွားပါမယ်။ လက်ရှိမှာ တစ်ချို့ process တွေ က linear of time ကြာပါတယ်။ ဥပမာ remove operation ဆို ဖျက်ရမယ့် value ကို လိုက်ရှာနေရတယ်။ hashtable မှာတော့ အဲ့လို လိုက်ရှာနေစရာမလိုတော့ပဲနဲ့ manage လုပ်သွားနိုင်မှာပါ။ 68 | 69 | စစဖတ်ဖတ်ခြင်းတော့ နည်းနည်းရှုပ်နိုင်တယ် ၊ ၂ ခေါက် လောက်သေချာလေးဖတ်လိုက်ရင်ရှင်းသွားမှာပါ။ 70 | 71 | photos credit to Udemy 72 | -------------------------------------------------------------------------------- /articles/priority_queue_with_heap_part2.md: -------------------------------------------------------------------------------- 1 | ## Priority Queue With Heap (Part 2) 2 | 3 | ဒီ part 2 article ကို မဖတ်ခင် part 1 ကို အရင်ဖတ်ထားမှ အဆင်ပြေပါလိမ့်မယ်။ အောက်က link မှာသွားဖတ်လို့ရပါတယ်။ 4 | 5 | http://bit.do/e3KCv 6 | 7 | Part 1 မှာရေးခဲ့တဲ့ မူလ remove algorithm က key တစ်ခုရှာပြီဆို tree တစ်ခုလုံးပတ်ရှာနေတဲ့အတွက် efficiency မကောင်းဘူးလို့ဆိုရမယ်။ အဲ့အတွက်ကြောင့် hash table ကို သုံးပြီး lookup table ပုံစံမျိုးတစ်ခုဖန်တီးမယ်။ အရှေ့ article မှာတုန်း က heap data represent လုပ်ခဲ့တုန်းက ပြောခဲ့သလိုပဲ element node value တွေကို array index (position value) တွေနဲ့ တွဲပြီးဆွဲထုတ်ပြခဲ့သေးတယ်။ အဲ့လိုပုံစံမျိုးပါပဲ။ 8 | 9 | Table မှာ column နှစ်ခုရှိမယ်၊ တစ်ခု က element တွေရဲ့ actual value ကိုပြမယ်။ နောက်တစ်ခုကသူ့တို့ရဲ့ position key (array index value) တွေပြထားမယ်။ ဆိုတော့ ကျနော်တော့ element တစ်ခု ဖျက်ချင်ပြီဆို table ထဲမှာ သူ့ရဲ့ position key ကိုသွားရှာလိုက်ခြင်းအားဖြင့် element ဘယ်နေရာမှာရှိတယ်ဆိုတာသိလိုက်ရပြီ၊ tree တစ်ခုလုံးတစ်ဆင့်ခြင်းလိုက်ရှာနေစရာမလိုတော့ပါဘူး။ 10 | 11 | ဒီနေရာမှာ စဉ်းစားစရာတစ်ခု ရှိလာတာက element value တူတာတွေရှိလာရင်ရော ဘယ်လို select လုပ်မလဲပေါ့။ လောလောဆယ် ကျနော်တို့လုပ်ထားတဲ့ lookup က element value တစ်ခု ကို position array value တစ်ခု လုပ်ထားတယ်။ ဒီလို scenario မျိုးအတွက် ဆိုရင်တော့ ကျနော်တို့ element value တစ်ခုအတွက် multiple position value ထားလို့ရပါတယ်။ element value က 7 လို့ပဲဆိုပါစို့ ။ 7 => 4,5,9 အဲ့လို table ထဲမှာ store လုပ်ထားလို့ရပါတယ်။ (fig 1 မှာ sample image ပါပါတယ်)။ 12 | 13 | ### Heap Data Presentation With Hash Lookup table 14 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%202/fig%201%20heap%20data%20presentation%20with%20hashtable%20lookup.png) 15 | 16 | 17 | Hash table အကြောင်းလဲ နားလည်သွားပြီဆိုတော့ သူ့ကိုသုံးပြီးတော့ data operation ဘယ်လိုလုပ်လဲပြောကြည့်ရအောင်။ process တော်တော်များများကတော့ အတူတူပဲဖြစ်တဲ့အတွက်အရမ်းကြီးတော့ စိမ်းမှာမဟုတ်လောက်ပါဘူး။ 18 | 19 | Insert ထည့်တော့မယ်ဆို ပုံမှန်အတိုင်းပဲ အောက်ဆုံးအတန်းက နေ left to right သွားတယ်။ ထည့်လိုက်ပြီဆိုတာနဲ့ lookup table မှာလည်း သူ့ရဲ့ element value နဲ့ position value ဝင်သွားမယ်။ နောက်တစ်ဆင့် အနေနဲ့ heap invariant ဖြစ်အောင် bubbling up လုပ်တယ်။ tree မှာ bubbling up လုပ်နေတိုင်းမှာ lookup table မှာလည်း position value တွေ swap လုပ်လုပ်သွားတယ်။ (fig 2.1 to fig 2.4 inserting data using lookup ကပုံတွေနဲ့ တွဲကြည့်ပါ)။ 20 | 21 | ### Inserting Data With Lookup Table 22 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%202/fig%202.1%20inserting%20data%20using%20lookup.png) 23 | 24 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%202/fig%202.2%20inserting%20data%20using%20lookup.png) 25 | 26 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%202/fig%202.3%20inserting%20data%20using%20lookup.png) 27 | 28 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%202/fig%202.4%20inserting%20data%20using%20lookup.png) 29 | 30 | Remove operation ကလဲထုံးစံအတိုင်းပဲ ဖျက်မယ့် key ကို lookup table ထဲမှာသွားရှာတယ်။ ဒါပေမဲ့ မေးစရာတစ်ခုရှိတာက same value , multiple position ဖြစ်တဲ့ကောင်တွေအတွက်ဆိုရင်ရော ဘယ်လိုလုပ်မလဲပေါ့။ အဖြေက တော့ ကြိုက်တဲ့ position ကကောင်ကို ယူဖျက်လိုက်လို့ရပါတယ်၊ ဖျက်ပြီး နောက်ဆုံးမှာ heap invariant ဖြစ်အောင် လုပ်နိုင်ရင်ရပါပြီ။ position key ရပြီဆိုရင် ပုံမှန်လုပ်နည်းအတိုင်းပဲ ဖျက်ရမယ့် value နဲ့ tree ရဲ့ နောက်ဆုံး value ကို swap လုပ်တယ်၊ ပြီးတော့ နောက်ဆုံး value ကို ဖျက်တယ်။ swap လုပ်လိုက်တဲ့ value ကို heap invariant ဖြစ်အောင် bubbling up or down ပြန်လုပ်တယ်။ (fig 3.1 to fig 3.4 removing data using lookup ကပုံတွေနဲ့ တွဲကြည့်ပါ)။ 31 | 32 | ### Removing Data With Lookup Table 33 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%202/fig%203.1%20removing%20data%20using%20lookup.png) 34 | 35 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%202/fig%203.2%20removing%20data%20using%20lookup.png) 36 | 37 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%202/fig%203.3%20removing%20data%20using%20lookup.png) 38 | 39 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%202/fig%203.4%20removing%20data%20using%20lookup.png) 40 | 41 | Polling ကတော့ ဘာမှပြောင်းလဲတာသိပ်မရှိဘူး။ နောက်ဆုံး value ကို ထိပ်ဆုံးက root value နဲ့ swap လုပ်တယ်။ ပြီးတော့ ဖျက်တယ်၊ ထိပ်ဆုံးရောက်သွားတဲ့ value ကို bubble down ပြန်လုပ်တယ်။ tree မှာလုပ်သွားတဲ့ step တွေအတိုင်း lookup မှာလိုက်ပြောင်းတယ်။ (fig 4.1 to fig 4.3 polling data using lookup ကပုံတွေနဲ့ တွဲကြည့်ပါ)။ 42 | 43 | ### Polling Data With Lookup Table 44 | 45 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%202/fig%204.1%20polling%20data%20using%20lookup.png) 46 | 47 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%202/fig%204.2%20polling%20data%20using%20lookup.png) 48 | 49 | ![Images of heap](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/priority%20queue%20with%20heap%20part%202/fig%204.3%20polling%20data%20using%20lookup.png) 50 | 51 | ဒီလောက်ဆိုရင်တော့ heap အကြောင်းလည်း တော်တော်ရှင်းသွားပြီ။ hashtable အကြောင်းကိုလဲ intro ဝင်ပြီးသားဖြစ်သွားပါပြီ။ နောက် article တွေမှာ hashtable အကြောင်းထပ်ရေးပေးသွားပါမယ်။ 52 | 53 | photos credit to Udemy 54 | -------------------------------------------------------------------------------- /articles/queue.md: -------------------------------------------------------------------------------- 1 | ## Queue In Data Structure & Algorithm 2 | 3 | Queue ကတော့ stack နဲ့ဆင်တယ်။ stack နဲ့မတူတာကကျ stack က one ended ကိုပဲ data အသွင်းအထုတ်ရတယ်။ queue ကကျတော့ တစ်ဖက်ကဝင် တစ်ဖက်ကထွက်ပုံစံမျိုး။ insert လုပ်ဖို့အတွက်ကို enqueue လို့ခေါ်ပြီးတော့ remove လုပ်ဖို့ကိုကျ dequeue လို့ခေါ်တယ်။ stack တုန်းက LIFO (last in first out) structure အတိုင်း ဆိုပေမဲ့ queue မှာတော့ FIFO(first in first out) ပဲ၊ အရင်ဝင်လာတဲ့ process က အရင်ပြန်ထွက်တယ်၊ နောက်မှဝင်လာတဲ့ ကောင်က နောက်မှ ထွက်ရမယ်။ real world example အနေနဲ့ ပြောရရင် starbucks မှာ ကော်ဖီ မှာဖို့တန်းစီ ပြီး စောင့်နေတဲ့ လူတွေမျိုး၊ အရင်ရောက်တဲ့ လူက အရင်မှာတယ်။ ပြီးရင် ထွက်သွားတယ်။ 4 | 5 | ဒီ article မဖတ်ခင် stack algorithm ရဲ့ article ကိုအရင်ဖတ်ဖို့ recommend လုပ်ချင်ပါတယ်။ 6 | 7 | Stack လိုပဲ queue ကို array တွေ linked lists တွေသုံးပြီးတော့ ဆောက်လို့ရတယ်။ queue process မှာ queue ဆောက်တာတို့ stack မှာလိုပဲ ထိပ်ဆုံး element ကို access လုပ်ဖို့ဆို peek ဆိုတာကိုသုံးတာတို့၊ queue က ပြည့် နေပြီးလား empty ဖြစ်နေလားစတာတွေကို စစ်တဲ့ function တွေလဲရှိတယ်။ အဓိက အသုံးများတာကတော့ အပေါ်မှာပြောထားတဲ့ function နှစ်ခုဖြစ်တဲ့ enqueue နဲ့ dequeue ပဲ။ queue အတန်းကြီးတစ်ခုရှိတယ်ဆိုပါစို့၊ ညာဘက်(အနောက်ဘက်) ကို queue ထည့်ဖို့ (enqueue) လုပ်ဖို့သုံးတယ်၊ queue ရဲ့ ဘယ်ဘက်(အရှေ့ဘက်)ကို queue remove လုပ်ဖို့သုံးတယ်၊ attach လုပ်ထားတဲ့ပုံနဲ့ တွဲကြည့်လိုက်ရင်တော့ ပိုမြင်သွားပါလိမ့်မယ်။ 8 | 9 | ### A Queue 10 | ![Images of queue](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/queue/understanding%20queue/whatisqueue.png) 11 | 12 | ### Enqueue 13 | ![Images of queue](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/queue/understanding%20queue/enqueue.png) 14 | 15 | ### Dequeue 16 | ![Images of queue](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/queue/understanding%20queue/dequeue.png) 17 | 18 | Queue တွေဘယ်လိုထည့်လဲဆိုတော့ (enqueue operation) 19 | - အသစ်ထည့်တော့မယ်ဆို queue ပြည့်နေပြီလားစစ်တယ် 20 | - ပြည့်နေတယ်ဆို သက်ဆိုင်တဲ့ msg ပြန်ပြီးတော့ exit လုပ်တယ် 21 | - ထပ်ထည့်လို့ရသေးတယ်ဆို stack မှာလိုမျိုးပဲ top element ကို access လုပ်တဲ့ top pointer queue မှာလဲ access လုပ်လို့ရတဲ့ rear pointer ဆိုတာရှိတယ်၊ အဲ့ဒီ pointer ကို +1 လုပ်ပြီး နောက်ဝင်လာမယ့် process အတွက် empty space ကို ထောက်ပေးထားတယ် 22 | - နောက်တစ်ဆင့် အနေနဲ့ rear pointer ထောက်ထားတဲ့ empty space ကို value ထည့်တယ် 23 | - Operation success ဖြစ်တဲ့ အကြောင်း return ပြန်တယ် 24 | 25 | ### Adding Queue 26 | ![Images of queue](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/queue/understanding%20queue/adding%20queue%20instruction.png) 27 | 28 | ### Removing Queue 29 | ![Images of queue](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/queue/understanding%20queue/removing%20queue%20instruction.png) 30 | 31 | ဒီနေရာမှာ stack နဲ့ မတူတာကျ stack က one ended ဆိုတော့ ထည့်တာရောထုတ်တာရော တစ်ဖက်တည်းကသွားတာဖြစ်တဲ့ အတွက်ကြောင့် pointer က တစ်ခုပဲရှိစရာလိုတယ်။ နှစ်ဖက်လုံးအလုပ်လုပ်တဲ့ queue မှာတော့ enqueue အတွက် ဆို rear (back pointer) နဲ့ dequeue အတွက် front pointer ဆိုပြီး ခွဲထားတယ်။ 32 | 33 | Queue တွေဘယ်လိုထုတ်လဲဆိုတော့ (dequeue operation) 34 | - queue က empty ဖြစ်နေလားအရင်ကြည့်တယ် 35 | - Empty ဖြစ်နေတယ်ဆို သက်ဆိုင်တဲ့ msg ပြန်ပြီးတော့ exit လုပ်တယ် 36 | - Empty မဖြစ်ဘူးဆိုရင် လက်ရှိ front pointer ထောက်ထားတဲ့ data ကို access လုပ်တယ်။ 37 | - နောက်တစ်ဆင့် အနေနဲ့ front pointer ကနေ backward သွားပြီး နောက် data element တစ်ခုကို access လုပ်ပြီး ရှေ့ ကဟာကို queue ထဲကနေ ထုတ်လိုက်တယ် 38 | - Operation success ဖြစ်တဲ့ အကြောင်း return ပြန်တယ် 39 | 40 | Queue algorithm ကိုဘယ်နေရာတွေမှာသုံးလဲဆိုတော့ ဥပမာ အနေနဲ့ ပြောရမယ်ဆိုရင် web server ကိုလာတဲ့ request တွေ handle လုပ်တဲ့ နေရာမှာသုံးလို့ရတယ်၊ request တစ်သိန်းလာတယ်၊ ဒါပေမဲ့ server က တစ်ခါ process လုပ်ရင် တစ်ထောင်ပဲရတယ်၊ ကျန်တဲ့ request တွေကို queue ထဲထည့်ထားပြီးတော့ first come first serve ပုံစံမျိုးနဲ့ အလုပ်လုပ်သွားတယ်၊ web server request မှရယ်မဟုတ်ဘူး၊ ကျန်တဲ့ batch request တွေကို လည်း queue သုံးပြီး manage လုပ်လို့ရပါတယ်။ တစ်ခြားသော scheduling case တွေမှာလဲ သုံးလို့ရတယ်၊ round robin scheduling တို့ Job scheduling တို့ စသည်ဖြင့် FIFO (first in first out) order နဲ့ သွားတဲ့ logic မှန်သမျှကို queue နဲ့ implement လုပ်လို့ရတယ်။ အခုနောက်ပိုင်းဆို Redis queue ဆိုရင် program တွေ တော်တော်များများ ထဲမှာ integrate လုပ်လာကြပါတယ်။တစ်ခြား multitasking လုပ်တဲ့ feature တွေမှာလည်း queue ကိုအသုံးပြုလို့ရပါတယ်။ 41 | 42 | photos credit to Udemy 43 | -------------------------------------------------------------------------------- /articles/sorting.md: -------------------------------------------------------------------------------- 1 | ## Sorting 2 | 3 | Sorting ဆိုတဲ့ သဘောတရားကိုတော့ အားလုံးလည်း သိကြမယ်လို့ထင်ပါတယ်။ data structures series ရေးနေပေမဲ့ sorting နဲ့ ပတ်သတ်တဲ့ article မရှိသေးတာနဲ့ ရေးပေးလိုက်ပါတယ်။ sorting ရဲ့ အဓိက ရည်ရွယ်ချက်ကတော့ data တွေကို အစီအစဉ်တကျ နေရာချထားဖို့ပါပဲ။ ဘာကြောင့် sorting လုပ်ရလဲဆိုတော့ searching algorithm တွေပိုပြီးတော့ strong ဖြစ်စေဖို့ (ဥပမာ. Binary search) ၊ ပိုပြီးတော့ ဖတ်လို့အဆင်ပြေတဲ့ format တွေချထားဖို့အတွက်ပဲဖြစ်ပါတယ် (ဥပမာ dictionary မှာဆို alphabet နဲ့ စီထားသလိုပေါ့)။ 4 | 5 | Sorting စီတဲ့နေရာမှာလည်း သူ့ဟာနဲ့သူ type တွေအမျိုးမျိုးရှိတယ်။ 6 | Sorting စီပြီးတဲ့အချိန်မှာ data value တွေက မစီခင်က sequence အတိုင်းရှိရင် stable sorting . sequence ပျက်သွားရင် unstable sorting ၊ ဒါမျိုးတွေရှိမယ်။ ဥပမာ 3 ပါတဲ့ index က နှစ်ခုရှိတယ်ဆိုပါစို့၊ index3 မှာလဲ 3 ၊ index 6 မှာလဲ 3။ sorting စီပြီးတဲ့ အချိန်မှာ index 3 ရဲ့ 3 ကအရင်လာပြီးမှ index 6 ရဲ့ 3 လာတယ်ဆို sequence အတိုင်းဖြစ်တယ် ဒါဆို stable sorting , index6 က အရင်ရှေ့ရောက်နေတယ်ဆို unstable sorting ပေါ့။ 7 | 8 | In place နဲ့ out place ကွာတဲ့ sorting သဘောတရားလည်းရှိတယ်။ ဘာကွာသွားလဲဆိုတော့ in place က sorting စီတဲ့နေရာမှာ သူ့ရဲ့ structure ထဲမှာပဲလုပ်တယ်။ ဆိုလိုချင်တာ သူ့အတွက် allocate လုပ်ထားတဲ့ memory space မှာပဲ run လို့ရတယ်။ ဥပမာ bubble sort. out place ဆိုတာကတော့ sorting စီဖို့အတွက် လိုအပ်တာထက်ပိုပြီးတော့ memory ယူရတယ်။ ဥပမာ tree sort လိုမျိုးပေါ့။ 9 | 10 | sorting algorithm တွေကတော့ တော်တော်များများကိုရှိပါတယ်။ အဲ့ထဲကမှ bubble sort , quick sort, merge sort , selection sort, insertion sort စသဖြင့် အသုံးများတဲ့ sorting တွေလည်းရှိပါတယ်။ sorting algorithm တော်တော်များများကို geeksforgeeks မှာသွားဖတ်လို့ရပါတယ်။ တော်တော်စုံပါတယ်။ sorting algorithm အခု 40 လောက်ပါမယ်ထင်တယ်။ အောက်မှာ link ပေးထားပါတယ်။ 11 | 12 | https://www.geeksforgeeks.org/sorting-algorithms/ 13 | -------------------------------------------------------------------------------- /articles/stack.md: -------------------------------------------------------------------------------- 1 | ## Stack Algorithm 2 | 3 | Stack ဆိုတာက သူ့ကို ပေးထားတဲ့နာမည် အတိုင်းပဲ အစုလိုက်ထပ်ထပ်ဆင့်ထားတဲ့ ပုံစံမျိုးကို ဆိုလိုတဲ့ structure တစ်ခုပဲ၊ LIFO (last in first out) or FILO(first in last out) ဆိုတဲ့ order အတိုင်းအလုပ်လုပ်တယ်။ ပြောရမယ်ဆိုရင် စာအုပ်တွေထပ်ပြီးတင်ထားတယ်၊ နောက်ဆုံးတင်တဲ့ တစ်အုပ်ကိုပဲ အရင်ပြန်ယူတယ် (last in first out) ၊ ပထမဆုံး ထားလိုက်တဲ့စာအုပ်ကို နောက်ဆုံးမှ ထုတ်လို့ရတယ် (first in last out) ၊ အဲ့ဒီ သဘောတရားပါပဲ။ 4 | 5 | stack ကို array နဲ့ပဲဖြစ်ဖြစ် linked list နဲ့ပဲဖြစ်ဖြစ် ဆောက်လို့ရတယ်၊ fixed sized ရော dynamic size ရော ကြိုက်သလိုဆောက်လို့ရတယ်၊ ဆောက်တဲ့ program ပေါ်ပဲမူတည်တယ်။ stack မှာ operations တွေအမျိုးမျိုးရှိပေမဲ့ အဓိက သုံးတာက တော့ push နဲ့ pop ပဲ။ push ဆိုရင် stack ထဲကို data လာထည့်မယ်။ pop ဆို ထုတ်မယ်၊ push လုပ်လုပ် pop လုပ်လုပ် အပေါ်ဆုံးက data value ကိုပဲ လုပ်လို့ရမယ်။ တစ်ခြား သုံးတဲ့ function တွေလည်း ရှိတယ်၊ ဥပမာ ထိပ်ဆုံး ကို element ကို access လုပ်ဖို့ဆို peek ဆိုတာကိုသုံးတာတို့၊ stack က ပြည့် နေပြီးလား empty ဖြစ်နေလားစတာတွေကို စစ်တဲ့ function တွေလဲရှိတယ်။ ဒီနေရာမှာတော့ ကျနော် push နဲ့ pop ကိုပဲ အဓိက ထားပြီး ပြောလိုက်မယ်၊ ဒါဆိုရင် ကျန်တဲ့ဟာတွေလဲ ခြုံငုံပြီးတစ်ခါတည်း ပြောပြီးသားဖြစ်သွားပါလိမ့်မယ်။ 6 | 7 | stack တစ်ခုထဲကို data တစ်ခု push (ထည့်) လုပ်တော့မယ်ဆိုရင် 8 | - အရင်ဆုံး stack က ပြည့်နေလားအရင်ကြည့်တယ် 9 | - Stack က ပြည့်နေတယ်ဆို သက်ဆိုင်တဲ့ msg ပြန်ပြီးတော့ exit လုပ်တယ် (dynamic size အတွက်ဆိုရင်တော့ သူ့ဘာသာ resizing လုပ်သွားတယ်) 10 | - Stack က ထည့်လို့ရသေးတယ်ဆိုရင် top pointer ကို နောက်ထပ်ဝင်လာမယ့်နေရာအတွက်ဦးထားပေးလိုက်တယ် (top pointer ဆိုတာလက်ရှိ stack ထဲမှာ အပေါ်ဆုံးမှာရှိနေတဲ့ data ကိုထောက်ထားတဲ့ pointer, push operation လုပ်တော့မယ်ဆို top pointer ကို +1 ပုံစံယူပြီး နောက်ဝင်လာမယ့် နေရာအတွက် empty space ကိုထောက်ပေးထားတယ်။) 11 | - နောက်တစ်ဆင့်အနေနဲ့ top pointer ထောက်ထားတဲ့ နေရာကို data ဝင်လာတယ် 12 | - Operation success ဖြစ်တဲ့ အကြောင်း return ပြန်တယ် 13 | 14 | Stack Pushing 15 | ![Images of stack](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/stacks/stack%20pushing.png) 16 | 17 | Stack Popping 18 | ![Images of stack](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/stacks/stack%20poping.png) 19 | 20 | Stack ထဲကနေ pop operation (stack ထဲကနေ data ထုတ်တော့မယ်ဆိုရင်) 21 | - Stack က empty ဖြစ်နေလားအရင်ကြည့်တယ် 22 | - Empty ဖြစ်နေတယ်ဆို သက်ဆိုင်တဲ့ msg ပြန်ပြီးတော့ exit လုပ်တယ် 23 | - Empty မဖြစ်ဘူးဆိုရင် လက်ရှိ top point ထောက်ထားတဲ့ data ကို access လုပ်တယ်။ 24 | - Top pointer ကို အောက်တစ်ထစ်ဆင်းလိုက်ပြီး ခုနက access လုပ်ထားတဲ့ data ကို stack ထဲကနေထုတ်လိုက်တယ် 25 | - Operation success ဖြစ်တဲ့ အကြောင်း return ပြန်တယ် 26 | 27 | ဒီ algorithm ကို ဘယ်လို နေရာတွေမှာ အသုံးချလဲဆိုတော့ LIFO သဘောတရားရှိနိုင်တဲ့ နေရာမှန်သမျှမှာ apply လုပ်လို့ရတယ်။ ဥပမာ ပြောရမယ်ဆိုရင် IDE တွေမှာ undo လုပ်တဲ့ process တို့ ၊ browser တွေမှာ back သွားတဲ့ process တို့ ၊ expressions တွေ convert လုပ်တဲ့နေရာ စတဲ့ နေရာတွေမှာသုံးလို့ရတယ်၊ ဘယ်လိုနေရာတွေမှာ ထပ်သုံးထားလဲသိချင်ရင် အောက်က link မှာ ဝင်ကြည့်လို့ရပါတယ်။ 28 | http://jcsites.juniata.edu/faculty/kruse/cs240/stackapps.htm 29 | 30 | photos credit to Udemy 31 | -------------------------------------------------------------------------------- /articles/static-dynamic-arrays.md: -------------------------------------------------------------------------------- 1 | ## Static & Dynamic Arrays 2 | 3 | Static တွေ dymanic တွေ မပြောခင် မှာ array အကြောင်းကို အရင်ပြောရအောင်။ array ကတော့ အားလုံးနဲ့ လည်း မစိမ်းလောက်ဘူး ၊ data value တွေကို collection လုပ်ထားတဲ့ sequence လို့လဲပြောလို့ရတယ်။ ဆိုလိုချင်တာ က data တွေ store လုပ်ဖို့ ပြန်ပြီး retrieve လုပ်ဖို့အတွက် အဆင်ပြေ အောင်ဖန်တီးထားတဲ့ data structure တစ်ခုလို့ဆိုနိုင်တယ်။ array တစ်ခုမှာ element ရှိတယ် ၊ index ရှိတယ်။ element ဆိုတာကတော့ array ထဲမှာ သိမ်းထားတဲ့ data value၊ အဲ့ array ထဲမှာ သိမ်းထားတဲ့ element တစ်ခုခြင်းရဲ့ memory ထဲမှာ numeric key တစ်ခု တွဲပေးထားတယ်၊ အဲ့ဒီ key ကို index လို့ခေါ်တယ်။ element value ကို index key သုံးပြီး လှမ်းဆွဲထုတ်လို့ရတယ်။ 4 | 5 | Array နဲ့ မသိမ်းဘဲ value တစ်ခု ခြင်းဆီ ကို variable တစ်ခုပေးပြီးလည်း သိမ်းလို့ရတယ်။ ဒါပေမဲ့ value တွေများလာတဲ့ အခါ တစ်ခုခြင်းဆီကို variable set လုပ်ပေးဖို့လည်း မလွယ်ဘူး၊ space လည်း ပိုယူတယ်။ တစ်ဖက်က coding ပိုင်းက ကြည့်မယ်ဆိုရင်လည်း data တွေ manage လုပ်ရတာ အဆင်မပြေတော့ဘူး။ array ထဲကို value တွေအများကြီး ထည့် set လုပ်လိုက်ခြင်းအားဖြင့် declare လုပ်ရတာ က လည်း တစ်ခါပဲ လုပ်ရမယ်။ ပြီးရင် data တွေ ပြန်ဆွဲထုတ် တဲ့ နေရာမှာလည်း index key နဲ့ အဆင်ပြေပြေဆွဲထုတ်လို့ရတယ်။ 6 | 7 | Static array ကတော့ fixed length ဖြစ်တယ်၊ ပြောချင်တာက array အခန်း ၄ ခု ဆို ၄ခုကိုပဲ memory မှာ preset လုပ်ထားလိုက်တယ်။ value တွေဆွဲထုတ်တဲ့နေရာမှာ ထုံးစံအတိုင်းပဲ index key သုံးပြီးဆွဲထုတ်တယ်။ static array မှာ element value တွေကို manage လုပ်လို့ မရဘူးတော့ မဟုတ်ဘူး၊ လုပ်လို့ရတယ်။ ဒါပေမဲ့သူအလုပ်လုပ်တဲ့ ပုံစံက၊ ဆိုပါတော့ element value ၄ ခုပါတဲ့ array တစ်ခုရှိတယ်၊ နောက်ထပ် value တစ်ခုထပ်ထည့်ချင်တယ်ဆိုရင် fixed length ဖြစ်နေတဲ့အတွက်ကြောင့် direct သွားထည့်လို့မရဘူး၊ memory ပေါ်ကို static array အသစ် တစ်ခုထပ်ကြေညာတယ်၊ ထပ်ထည့်ချင်တဲ့ value အတွက် array တစ်ခန်းအပိုနဲ့ပေါ့၊ ပြီးတော့ မှ အရင် array ကို copy paste လာလုပ်တယ်၊ နောက်ထပ် value တစ်ခု ကို တစ်ခါတည်း ထပ်ထည့်တယ်၊ အဲ့ဒီ process ပြီးမှ previous array ကို remove လုပ်တယ်။ ဆိုလိုချင်တာက static array ပေါ်မှာ element value တွေကို manage လုပ်လာပြီဆို memory consumption များလာတဲ့အတွက် မကောင်းဘူး။ အဲ့ဒီ issue ကိုဖြေရှင်းနိုင်ဖို့အတွက် dynamic array ကို သုံးလာကြတယ်။ 8 | 9 | Dynamic array ကလည်း စစချင်း တော့ static array လိုပဲ array တစ်ခု create လုပ်ရတာပဲ။ ဒါပေမဲ့ သူက assign လုပ်ထားတဲ့ element value တွေကို manage လုပ်နိုင်တယ်။ သူ manage လုပ်ပုံက array ၄ခန်းရှိတယ်။ assign လုပ်ထားတဲ့ element တွေကို ၄ ခုလုံးရှိတယ်။ အခန်းလွတ်မရှိဘူး။ နောက်တစ်ခုထပ်ထည့်ချင်တယ်ဆို နေရာလွတ်မရှိတော့တဲ့အတွက် လက်ရှိရှိပြီးသား array size ရဲ့ နှစ်ဆယူပြီး အရင် array ကို copy လုပ်တယ်။ element တွေထပ်ထည့်တယ်။ array resize လုပ်တယ်လို့လည်း ခေါ်တယ်။ array အခန်းပြည့် ပြီး နောက်ထပ် value assign လုပ်ချင်တဲ့ အချိန်ရယ်၊ assign value တွေ remove လုပ်ရင်း array အခန်းလွတ်တွေများပြီး space တွေယူနေတယ်လို့ ယူဆရတဲ့ အချိန်တွေရယ် resize လုပ်ပါတယ်။ 10 | 11 | Static array ကတော့ 12 | - လိုအပ်တဲ့ memory amount ကိုပဲသုံးပြီး data manage လုပ်တဲ့ နေရာမှာကောင်းတယ်။ 13 | - Dynamic array ထက်စာရင် element တွေ access လုပ်ရတာပိုမြန်တယ်။ 14 | - Data တွေ manage operation (CRUD) လုပ်ရမယ်ဆို resource waste ဖြစ်တယ်။ 15 | - Fixed size ဖြစ်ပြီးတော့ ၊ array စဆောက်တဲ့ အချိန်မှာ assign value တွေမပါသေးရင်တာင်မှ memory ယူထားရတယ်။ 16 | 17 | dynamic array က တော့ 18 | - data တွေ ခဏခဏ manage လုပ်တဲ့မယ်ဆို အသုံးဝင်တယ်။ 19 | - size က flexible ဖြစ်တယ်။ 20 | - array resize လုပ်တဲ့ အချိန်မှာ လိုအပ်တဲ့ resources တွေကို runtime မှာပဲ တစ်ခါတည်းသုံးသွားတဲ့အတွက် resources တွေ waste မဖြစ်တော့ဘူး။ 21 | - static array နဲ့ယှဉ်ရင်တော့ element တွေ access လုပ်ရတာပိုနှေးတယ်။ 22 | 23 | photos credit to Udemy 24 | ![Images of arrays](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/static%20%26%20dynamic%20arrays/static%20array.png) 25 | 26 | ![Images of arrays](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/static%20%26%20dynamic%20arrays/dynamic%20array.png) 27 | -------------------------------------------------------------------------------- /articles/unionfind.md: -------------------------------------------------------------------------------- 1 | ## Union Find Algorithm 2 | 3 | Union Find ကို ရှင်းရှင်းလင်းလင်း ဖွင့်ဆိုရမယ်ဆိုရင် တစ်ကွဲတစ်ပြားစီရှိနေတဲ့ object တစ်ခုခြင်းဆီ ဒါမှမဟုတ် object အစုလိုက်ကို find လုပ်ပြီးတော့ တစ်စုတစ်စည်းတည်း ဖြစ်အောင် ပေါင်းလိုက်တာကို union process လို့ ပြောလို့ရပါတယ်။ Union Find ကတော့ အများကြီးပြောစရာမရှိပါဘူး၊ သူ့မှာ အဓိက သုံးတဲ့ function နှစ်မျိုးရှိတယ်၊ သိထားတဲ့ အတိုင်း find & union ပါပဲ။ 4 | 5 | ### Find 6 | ပုံမှန်ဆို object အစုလိုက်ဆိုလို့ရှိရင် parent node တစ်ခုရှိတယ်။ object ကတစ်ခုတည်း ဆိုလို့ရှိရင်လည်း သူ့ကိုယ်တိုင်ကိုပဲ parent node အဖြစ် သတ်မှတ်ထားတယ်။ Find က ဘာလုပ်မလဲဆိုတော့ object အချင်းချင်း မပေါင်းခင်(merge) မှာ သူတို့ရဲ့ parent node ကို လိုက်ရှာတယ်။ Union လုပ်မှာက parent node ကို အခြေခံပြီးလုပ်မှာဖြစ်တဲ့အတွက်ကြောင့်ပါ။ 7 | 8 | ### Union 9 | Find လုပ်ပြီး parent node ကို ရပြီဆိုတာနဲ့ Union လုပ်ပါတယ်။ parent node နှစ်ခုမှာပါတဲ့ objects တွေအားလုံးကိုတစ်ခုတည်း အဖြစ်ပေါင်းလိုက်ပြီး parent node ကိုလဲ တစ်ခုတည်း အဖြစ်သတ်မှတ်လိုက်ပါတယ်။ နှစ်ခုထဲက ဘယ်တစ်ခုကိုဖြစ်ဖြစ်သတ်မှတ်လို့ရပါတယ်။ objects ပိုများများရှိတဲ့ parent node ကိုယူလိုက်တာကတော့ ပိုကောင်းပါတယ်။ 10 | 11 | ### Union Find With Magnet Examples 12 | ![Images of unionfind](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/union%20find/union%20find%20with%20magnet%20example%201.png) 13 | 14 | ![Images of unionfind](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/union%20find/union%20find%20with%20magnet%20example%202.png) 15 | 16 | ![Images of unionfind](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/union%20find/union%20find%20with%20magnet%20example%203.png) 17 | 18 | ဒါပေမဲ့ တိုင်ပတ်တာ တစ်ခုတော့ ရှိတယ်။ အခု လက်ရှိလုပ်နေတဲ့ operation က efficient မဖြစ်ဘူး။ ဘာလို့လဲဆိုတော့ ကျနော်တို့ object နှစ်ခုပေါင်းပြီဆိုပါစို့ A နဲ့ B ပေါင်းတယ်။ A က parent node ဖြစ်သွားတယ်။(A<-B) ပေါ့။ နောက်ထပ် C ဆိုတဲ့ object တစ်ခု ထပ်ပေါင်းမယ်။ ဒီလိုဖြစ်သွားမယ် (A<-B<-C)၊ ဆိုတော့ ကျနော်တို့ C object နဲ့ နောက်ထပ် object တွေ union လုပ်တဲ့အခါ C ရဲ့ parent node ကိုရှာတဲ့ အခါ C ကနေမှတစ်ဆင့် A အထိသွားရှာရပါတယ်။ ဒါက သုံးခုပဲ ရှိသေးလို့ပါ၊ တစ်ကယ်ဆို အများကြီး ရှိနေတဲ့ အချိန်ဆို တစ်ခါတစ်ခါ union လုပ်တော့ မယ်ဆို parent node ကို တစ်ဆင့်ခြင်းဆီ သွားရမယ်ဆိုရင်တော့ သိပ်မဟုတ်တော့ပါဘူး။ ဒီလိုဖြစ်လာတဲ့အတွက် path compression ဆိုတဲ့ အရာကို apply လုပ်ထားပါတယ်။ 19 | 20 | Path compression ဆိုတာက တော့ သူ့နာမည်အတိုင်းပဲ သွားရမယ့် path ကိုချုံ့ လိုက်မှာ။ ဆိုလိုချင်တာက ကျနော်တို့အရင် priority queue article ရေးတုန်းက lookup table နဲ့ node value & position value တွဲပြီးတော့ သိမ်းထားသလိုပဲ ၊ ဒီမှာလဲ follower node ကို join မလုပ်တော့ဘဲ parent node ကို တိုက်ရိုက်သွား Join လိုက်တယ်။ ဆိုလိုချင်တာက ဒီလို (A<-B<-C) join မယ့်အစား (A<-B),(A<-C) ဆိုပြီး parent node ကိုပဲတိုက်ရိုက် join လိုက်မယ်။ အဲ့ဒါဆိုရင် parent node ရှာရတော့မယ့်အချိန်မှာ တစ်ဆင့်ချင်းစီ လိုက်ရှာနေစရာမလိုတော့ ဘဲ parent node ကို အလွယ်တကူတွေ့ပြီး Union လုပ်နိုင်မှာပါ။ 21 | 22 | ### Union Find With Path Compression 23 | ![Images of unionfind](https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/master/assets/union%20find/union%20find%20with%20path%20compression.png) 24 | 25 | ဘယ်နေရာတွေမှာ apply လုပ်လို့ရလဲဆိုရင် connectivity တွေကို unionized လုပ်ထားတဲ့ architecture တွေ algorithm တွေမှာ သုံးလို့ရပါတယ်။ ဥပမာ Kurskal algorithm ဆို node တစ်ခုချင်းဆီကို ascending structure နဲ့ union လိုက်လုပ်ပြီး minimum path ကိုရှာတယ်။ တစ်ခြား Network connectivity infra တွေမှာလည်း Union Find ကိုသုံးတာတွေရှိပါတယ်။ 26 | 27 | ကျနော် pseudo code နဲ့ algorithm sample လေးပါထည့်ပေးလိုက်ပါတယ်။ 28 | 29 | ``` 30 | function find( x ) 31 | if(x != x.parent) 32 | x.parent = find(x.parent) 33 | return x.parent 34 | else 35 | return x 36 | ``` 37 | 38 | ``` 39 | function union(x,y) 40 | x = find( x ), y = find( y ) //find the root of each element 41 | if ( x is equal to y ) 42 | return success 43 | else 44 | set x as y’s parent 45 | ``` 46 | photos credit to Udemy 47 | -------------------------------------------------------------------------------- /assets/AVL tree/fig1.1 advantages of avl tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/AVL tree/fig1.1 advantages of avl tree.png -------------------------------------------------------------------------------- /assets/AVL tree/fig2.1 tree rotation sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/AVL tree/fig2.1 tree rotation sample.png -------------------------------------------------------------------------------- /assets/AVL tree/fig2.2 tree rotation sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/AVL tree/fig2.2 tree rotation sample.png -------------------------------------------------------------------------------- /assets/AVL tree/fig2.3 tree rotation sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/AVL tree/fig2.3 tree rotation sample.png -------------------------------------------------------------------------------- /assets/AVL tree/fig2.4 tree rotation sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/AVL tree/fig2.4 tree rotation sample.png -------------------------------------------------------------------------------- /assets/AVL tree/fig3.1 avl tree example.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/AVL tree/fig3.1 avl tree example.jpg -------------------------------------------------------------------------------- /assets/AVL tree/fig3.2 avl_left_rotation.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/AVL tree/fig3.2 avl_left_rotation.jpg -------------------------------------------------------------------------------- /assets/AVL tree/fig3.3 avl_right_rotation.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/AVL tree/fig3.3 avl_right_rotation.jpg -------------------------------------------------------------------------------- /assets/AVL tree/fig3.4 left_right_rotation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/AVL tree/fig3.4 left_right_rotation.png -------------------------------------------------------------------------------- /assets/AVL tree/fig3.5 right_left_rotation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/AVL tree/fig3.5 right_left_rotation.png -------------------------------------------------------------------------------- /assets/abstraction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/abstraction.png -------------------------------------------------------------------------------- /assets/big0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/big0.png -------------------------------------------------------------------------------- /assets/binary tree/Binary-Search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/binary tree/Binary-Search.png -------------------------------------------------------------------------------- /assets/binary tree/binary_tree.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/binary tree/binary_tree.jpg -------------------------------------------------------------------------------- /assets/binary tree/binarytree inorder traversal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/binary tree/binarytree inorder traversal.png -------------------------------------------------------------------------------- /assets/binary tree/binarytree insertion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/binary tree/binarytree insertion.png -------------------------------------------------------------------------------- /assets/binary tree/binarytree levelorder traversal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/binary tree/binarytree levelorder traversal.png -------------------------------------------------------------------------------- /assets/binary tree/binarytree postorder traversal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/binary tree/binarytree postorder traversal.png -------------------------------------------------------------------------------- /assets/binary tree/binarytree preorder traversal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/binary tree/binarytree preorder traversal.png -------------------------------------------------------------------------------- /assets/binary tree/binarytree removing case1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/binary tree/binarytree removing case1.png -------------------------------------------------------------------------------- /assets/binary tree/binarytree search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/binary tree/binarytree search.png -------------------------------------------------------------------------------- /assets/binary tree/fig 1.binary tree removing case2and3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/binary tree/fig 1.binary tree removing case2and3.png -------------------------------------------------------------------------------- /assets/binary tree/fig 1.binary tree removing case4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/binary tree/fig 1.binary tree removing case4.png -------------------------------------------------------------------------------- /assets/binary tree/fig 2.binary tree removing case2and3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/binary tree/fig 2.binary tree removing case2and3.png -------------------------------------------------------------------------------- /assets/binary tree/fig 2.binary tree removing case4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/binary tree/fig 2.binary tree removing case4.png -------------------------------------------------------------------------------- /assets/binary tree/fig 3.binary tree removing case4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/binary tree/fig 3.binary tree removing case4.png -------------------------------------------------------------------------------- /assets/binary tree/fig 4.binary tree removing case4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/binary tree/fig 4.binary tree removing case4.png -------------------------------------------------------------------------------- /assets/dividenconquer/dividenconquer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/dividenconquer/dividenconquer.png -------------------------------------------------------------------------------- /assets/dynamicprogramming/dynamicprogramming.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/dynamicprogramming/dynamicprogramming.png -------------------------------------------------------------------------------- /assets/fenwick(binary indexed tree)/fenwick tree construction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/fenwick(binary indexed tree)/fenwick tree construction.png -------------------------------------------------------------------------------- /assets/fenwick(binary indexed tree)/fenwick-point update.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/fenwick(binary indexed tree)/fenwick-point update.png -------------------------------------------------------------------------------- /assets/fenwick(binary indexed tree)/fig1. fenwick tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/fenwick(binary indexed tree)/fig1. fenwick tree.png -------------------------------------------------------------------------------- /assets/fenwick(binary indexed tree)/fig2. calculating range value.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/fenwick(binary indexed tree)/fig2. calculating range value.png -------------------------------------------------------------------------------- /assets/greedy/Screen Shot 2019-08-10 at 6.54.15 PM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/greedy/Screen Shot 2019-08-10 at 6.54.15 PM.png -------------------------------------------------------------------------------- /assets/hashtable/hash function/fig1. hash function.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/hashtable/hash function/fig1. hash function.png -------------------------------------------------------------------------------- /assets/hashtable/hash function/fig2. hash function.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/hashtable/hash function/fig2. hash function.png -------------------------------------------------------------------------------- /assets/hashtable/open addressing/Screen Shot 2019-08-26 at 11.25.04 AM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/hashtable/open addressing/Screen Shot 2019-08-26 at 11.25.04 AM.png -------------------------------------------------------------------------------- /assets/hashtable/open addressing/doublehashing.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/hashtable/open addressing/doublehashing.jpg -------------------------------------------------------------------------------- /assets/hashtable/open addressing/linear probing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/hashtable/open addressing/linear probing.png -------------------------------------------------------------------------------- /assets/hashtable/open addressing/quadratic probing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/hashtable/open addressing/quadratic probing.png -------------------------------------------------------------------------------- /assets/hashtable/open addressing/removing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/hashtable/open addressing/removing.png -------------------------------------------------------------------------------- /assets/hashtable/separate chaining/fig1. insertion as linked list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/hashtable/separate chaining/fig1. insertion as linked list.png -------------------------------------------------------------------------------- /assets/hashtable/separate chaining/fig1. selecting the node.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/hashtable/separate chaining/fig1. selecting the node.png -------------------------------------------------------------------------------- /assets/hashtable/separate chaining/fig2. insertion as linked list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/hashtable/separate chaining/fig2. insertion as linked list.png -------------------------------------------------------------------------------- /assets/hashtable/separate chaining/fig2. selecting the node.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/hashtable/separate chaining/fig2. selecting the node.png -------------------------------------------------------------------------------- /assets/linked lists/doubly linked list inserting operation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/linked lists/doubly linked list inserting operation.png -------------------------------------------------------------------------------- /assets/linked lists/doubly linked list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/linked lists/doubly linked list.png -------------------------------------------------------------------------------- /assets/linked lists/doubly linked removing operation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/linked lists/doubly linked removing operation.png -------------------------------------------------------------------------------- /assets/linked lists/singly linked list inserting operation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/linked lists/singly linked list inserting operation.png -------------------------------------------------------------------------------- /assets/linked lists/singly linked list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/linked lists/singly linked list.png -------------------------------------------------------------------------------- /assets/linked lists/singly linked removing operation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/linked lists/singly linked removing operation.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 1/fig 1. what is binary heap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 1/fig 1. what is binary heap.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 1/fig 2. binary heap representation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 1/fig 2. binary heap representation.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 1/fig 3. binary heap representation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 1/fig 3. binary heap representation.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 1/fig 4.1. adding elements to binary heap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 1/fig 4.1. adding elements to binary heap.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 1/fig 4.2. adding elements to binary heap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 1/fig 4.2. adding elements to binary heap.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 1/fig 4.3. adding elements to binary heap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 1/fig 4.3. adding elements to binary heap.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 1/fig 4.4. adding elements to binary heap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 1/fig 4.4. adding elements to binary heap.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 1/fig 5.1 polling elements from binary heap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 1/fig 5.1 polling elements from binary heap.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 1/fig 5.2 polling elements from binary heap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 1/fig 5.2 polling elements from binary heap.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 1/fig 5.3 polling elements from binary heap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 1/fig 5.3 polling elements from binary heap.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 1/fig 5.4 polling elements from binary heap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 1/fig 5.4 polling elements from binary heap.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 1/fig 5.5 polling elements from binary heap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 1/fig 5.5 polling elements from binary heap.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 1/fig 5.6 polling elements from binary heap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 1/fig 5.6 polling elements from binary heap.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 1/fig 6.1 removing elements from binary heap with value parameter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 1/fig 6.1 removing elements from binary heap with value parameter.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 1/fig 6.2 removing elements from binary heap with value parameter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 1/fig 6.2 removing elements from binary heap with value parameter.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 1/fig 6.3 removing elements from binary heap with value parameter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 1/fig 6.3 removing elements from binary heap with value parameter.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 2/fig 1 heap data presentation with hashtable lookup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 2/fig 1 heap data presentation with hashtable lookup.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 2/fig 2.1 inserting data using lookup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 2/fig 2.1 inserting data using lookup.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 2/fig 2.2 inserting data using lookup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 2/fig 2.2 inserting data using lookup.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 2/fig 2.3 inserting data using lookup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 2/fig 2.3 inserting data using lookup.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 2/fig 2.4 inserting data using lookup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 2/fig 2.4 inserting data using lookup.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 2/fig 3.1 removing data using lookup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 2/fig 3.1 removing data using lookup.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 2/fig 3.2 removing data using lookup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 2/fig 3.2 removing data using lookup.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 2/fig 3.3 removing data using lookup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 2/fig 3.3 removing data using lookup.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 2/fig 3.4 removing data using lookup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 2/fig 3.4 removing data using lookup.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 2/fig 4.1 polling data using lookup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 2/fig 4.1 polling data using lookup.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 2/fig 4.2 polling data using lookup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 2/fig 4.2 polling data using lookup.png -------------------------------------------------------------------------------- /assets/priority queue with heap part 2/fig 4.3 polling data using lookup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue with heap part 2/fig 4.3 polling data using lookup.png -------------------------------------------------------------------------------- /assets/priority queue/what is a heap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue/what is a heap.png -------------------------------------------------------------------------------- /assets/priority queue/what is pq and its instruction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/priority queue/what is pq and its instruction.png -------------------------------------------------------------------------------- /assets/queue/understanding queue/adding queue instruction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/queue/understanding queue/adding queue instruction.png -------------------------------------------------------------------------------- /assets/queue/understanding queue/dequeue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/queue/understanding queue/dequeue.png -------------------------------------------------------------------------------- /assets/queue/understanding queue/enqueue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/queue/understanding queue/enqueue.png -------------------------------------------------------------------------------- /assets/queue/understanding queue/removing queue instruction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/queue/understanding queue/removing queue instruction.png -------------------------------------------------------------------------------- /assets/queue/understanding queue/whatisqueue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/queue/understanding queue/whatisqueue.png -------------------------------------------------------------------------------- /assets/stacks/stack example 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/stacks/stack example 1.png -------------------------------------------------------------------------------- /assets/stacks/stack example 2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/stacks/stack example 2.png -------------------------------------------------------------------------------- /assets/stacks/stack example 3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/stacks/stack example 3.png -------------------------------------------------------------------------------- /assets/stacks/stack poping.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/stacks/stack poping.png -------------------------------------------------------------------------------- /assets/stacks/stack pushing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/stacks/stack pushing.png -------------------------------------------------------------------------------- /assets/static & dynamic arrays/dynamic array.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/static & dynamic arrays/dynamic array.png -------------------------------------------------------------------------------- /assets/static & dynamic arrays/static array.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/static & dynamic arrays/static array.png -------------------------------------------------------------------------------- /assets/union find/union find with magnet example 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/union find/union find with magnet example 1.png -------------------------------------------------------------------------------- /assets/union find/union find with magnet example 2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/union find/union find with magnet example 2.png -------------------------------------------------------------------------------- /assets/union find/union find with magnet example 3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/union find/union find with magnet example 3.png -------------------------------------------------------------------------------- /assets/union find/union find with path compression.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/assets/union find/union find with path compression.png -------------------------------------------------------------------------------- /datastructures&algorithms_v2.1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HlaingTinHtun/Data-Structure-Algorithm-In-Burmese/98b60cb7a23cf7dc930a94dacd34cc475f71d1b0/datastructures&algorithms_v2.1.pdf --------------------------------------------------------------------------------