ﻟﯘﺗﭙﯘﻟﻼ ﻣﯘﺗﻪﻟﻠﯩﭗ
ۋاقىت ئالدىراڭغۇ ساقلاپ تۇرمايدۇ،
يىللار ۋاقىتنىڭ ئەڭ چوڭ يورغىسى.
ئاققان سۇلار، ئاتقان تاڭلار قايتىلانمايدۇ،
يورغا يىللار ئۆمۈرنىڭ يامان ئوغرىسى.
BFS & DFS
Breadth-first Search
- Running time complexity: O(V + E)
- Memory complexity is not good as we have to sort lots of references. That is why DFS is usually preferred.
- But it constructs a shortest path: Dijkstra algorithm does a BFS if all the edge weights are equal to one.
- We have an empty queue at the beginning and we keep checking whether we have visited the given node or not. Keep iterating until queue is not empty.
Basic Sorting Algorithms
Some Features
Time Complexity
Typical ones are: O(n^2) or O(nlogn) or O(n), for more check Big-O Cheatsheet.
In-place
Strictly an in-place sort needs only o(1) memory beyond the items being sorted.
So an in place algorithm does not need any extra memory.
Recursive
Some sorting algorithms are implemented in a recursive manner, especially the divide and conquer ones. Such as merge sort and quick sort.
Stable
Stable sorting algorithms maintain the relative order of records with equal values.
Heap Implementation
Priority Queue
- It is an abstract data type such as stack or queue
- But every item has an additional property: a priority value
- Priority Queue is usually implemented with heaps, but it can be implemented with self balancing trees as well
- The highest priority element is retrieved first, no FIFO structure here
- Operation: InsertWithPriority(data, priority), getHighestPriorityElement(), peek()
Trees Implementation
How to Use ~ば
The conditional 〜ば form changes differently in these word types: 『動詞』(verb)、『い形容詞』(i adjective)、『な形容詞』(na adjective)、そして『名詞』(noun)。
And 『動詞』(verb) will include three different categories: u verb, ru verb, and exceptions.