Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
13 Cards in this Set
- Front
- Back
O |
N inputs => how. Many operations?? |
|
O(n) |
For(int i=0;i<n;i++) If(a[i]=="") به تعداد n ورودی operation مقایسه داریم پس o( n) است |
|
Rule1 |
Worst case ro در نظر بگیر |
|
ترتیب |
N! > 2^n > n^2 > nlogn > n> logn 1 |
|
O(m +n) |
دو تا ورودی داریم که for اولی به تعداد اولی تکرار میشه و for دومی به تعداد دومی |
|
Loops |
Nested => * After another => + |
|
Bigocheatsheet.com |
|
|
Spatial complexity |
چقدر فضای اضافه اون تابع گرفته. ورودی دیگه مهم نیست |
|
توی performance |
باید فقط نگران لوپ ها باشی |
|
Arrays |
Lookup(access element by index) O(1) Push(insert at the end) O(1) Pop(from the end) O(1) Insert or delete(in between) جابجایی داریم با یک for که در بدترین حالت میشه O(n) |
|
Arrays |
Pros: Fast lookup, Fast push and pop from end Cons: Slow insert o delete |
|
Hash table |
Pros: Fast Insert o look up Cons: Unordered Slow iteration |
|
خوراک optimization |
استفاده از Hashtable و dictionary برای جلوگیری از o مرتبه n2 و تبدیل به o مرتبه n |