Похожие чаты

How to count Big-O notation for if statement?

8 ответов

4 просмотра

I dont know anything about these notations (All i know is O(n) means n operations can be done for a job) but i guess it should be 2n+1 n + 1 for the for loop (which you can rewrite it and make it n) and n for the arr[i] == x

Ive searched a little bit seems im right with 2n+1 but I also got that O(an+b) is equal to O(n) somehow

Farkhan°᭄- Автор вопроса
Farkhan°᭄
screenshot is it what you mean sir?

No For loop is n + 1 and "if" is n

Nader Jafari
Ive searched a little bit seems im right with 2n+1...

It's just limit (shouldn't have used it) maximizing. Since N tends to infinity. aN + b, here b won't really matter and aN, N will be the same

Farkhan°᭄
screenshot is it what you mean sir?

You can just eyeball the operations, its O(n) since its iterating over the whole list

Take an algorithms course, there's one by mitopencourseware. Google it to find it

Похожие вопросы

Обсуждают сегодня

Всем привет, написал код ниже, но он выдает сегфолт, в чем причина? #include <stdio.h> #include <stdlib.h> #include <string.h> struct product { char *name; float price; };...
buzz базз
75
Hey, Oceaners 🌊 As we approach Phase 1 of the token merger, OCEAN and AGIX will migrate to FET starting July 1st! Here's a list of exchanges that have communicated their su...
KreigDK | Never DM first🌊
3
База данных не поможет. Шифрование не поможет. Какие там ещё варианты? Накидывайте.
КТ315
20
I love the passion, really do. I do think this is being blown way out of proportion. We are not deleting our Telegram or not allowing you to talk about anything you want, a...
Mike Herron
3
Did you guys see the latest tweet from TonGifts? 🚀
Mike
44
А как лучше конвертировать физический адрес в виртуальный при маппинге? В случае ядра у меня, например, direct mapping, первые 768МБ я как есть мапплю в higher half, а остальн...
Evg Resh
26
А табстоп это сообщение от окна или от элемента управления?
The Bird of Hermes
18
Hey, what is the best and maintained way of transpiling cpp to c? (As a need to support many different toolchains quickly and may not have a c++ support in the given toolch...
Meitar Reihan
11
Открыл свой двухкилобайтный экзешник в x32dbg, а тут какая-то хрень. Смущает кнопка "выполнить до пользовательского кода", а что ещё может быть в файле помимо него ?
НѣкъиⰘижєжєиꙁъвьсєсвѣтьноѣсѣтиѥсть•
11
Hey guys, did you see the latest announcement about $FUN? 🔥
Brian
21
Карта сайта