Time complexity of a computer program

Time complexity of a computer program

mycodeschool

12 лет назад

687,230 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@ashmil1968
@ashmil1968 - 23.10.2019 22:37

What about the time that is taken by Shyam to compute the square root of n? Should not we include that as well while computing the time complexity?

Ответить
@andekhi3340
@andekhi3340 - 24.10.2019 08:57

Ram and Shyam are the Most used names of to people use as an example in India form class 1st to highest level of education 😂😂😂

Ответить
@solmusic4742
@solmusic4742 - 18.02.2020 16:21

Rest In Peace Brother. Really sad to know world lost you.

Ответить
@sandeepkumawat4982
@sandeepkumawat4982 - 06.03.2020 01:48

i know prime numbers..but watching this gives me confidence..:-D

Ответить
@adcdsa69
@adcdsa69 - 26.03.2020 16:24

Thanks U Sir

Ответить
@DeepakSingh-sy4ws
@DeepakSingh-sy4ws - 13.05.2020 03:26

u r too good sir

Ответить
@ninja-gh
@ninja-gh - 24.05.2020 19:36

Why this video is getting blur, anyone facing the same issue.!?

Ответить
@cpsarathe
@cpsarathe - 09.06.2020 14:23

@mycodeschool is the eureka moment for me. Every video is so simple and gives a great refresher/addon in computer science fundamentals.

Ответить
@SuperCacazinho
@SuperCacazinho - 15.06.2020 02:04

You're amazing !!!
Greetings from Brazil ! <3

Ответить
@neo-g3k
@neo-g3k - 15.06.2020 14:36

Codechef

Ответить
@pravatyadav3623
@pravatyadav3623 - 08.08.2020 14:54

People may come and go but this video shall go on forever

Ответить
@randhir2126
@randhir2126 - 17.08.2020 20:09

Shyam 1 , Ram 0

Ответить
@grpnpraveen8765
@grpnpraveen8765 - 25.08.2020 15:40

its good

Ответить
@kumarvaibhav3985
@kumarvaibhav3985 - 28.08.2020 21:32

This man surely does not know the difference between yellow and orange color

Ответить
@prashantmajumdar1519
@prashantmajumdar1519 - 31.08.2020 17:36

Anyone from 2020 when corona virus is a threat to humankind

Ответить
@RandomThiChege
@RandomThiChege - 04.09.2020 19:25

how it is n-2 times and other is n-1

Ответить
@junaidiqbalhashmi9449
@junaidiqbalhashmi9449 - 07.09.2020 16:37

Whenever i need to recall DS and Algo concept i definitely come here. best of best. May his soul rest in peace. I request to other cofounder please take some time and made videos on oop so beginner like me clear their concept plz plz

Ответить
@girishtripathy3354
@girishtripathy3354 - 16.10.2020 10:49

My laptop will probably gonna crash if I inputted n = 1000003. lmao

Ответить
@lakhanjain5119
@lakhanjain5119 - 27.10.2020 06:49

more time saving trick....
1. If square root of n is a decimal then the number is prime.
2. No need to run the loop is first logic is used.
(Edit) 3. Only in case u need list of all prime numbers below n then run the loop.

Ответить
@charlesjsescoto
@charlesjsescoto - 26.11.2020 14:59

All of these started here, but he left us already :(

Ответить
@quocdaingonguyen4385
@quocdaingonguyen4385 - 05.12.2020 11:25

How come I didn't see this video and this channel sooner....You are really something else, Animesh! Thank you!

Ответить
@shyamraj6214
@shyamraj6214 - 13.02.2021 20:18

My name is shyam 😁😁😁

Ответить
@kal5211
@kal5211 - 06.03.2021 07:50

My man.

Ответить
@taher786...
@taher786... - 25.03.2021 16:17

ill be really honest...This video literally enlightened me...dude youre just a great teacher

Ответить
@themanwhoknocks
@themanwhoknocks - 20.04.2021 20:31

watching in 2021 :)

Ответить
@C.Sakthivignesh
@C.Sakthivignesh - 06.06.2021 11:42

Shall I watch this video it was uploaded 8 years ago?
I am new to programming
Please please any one reply me.

Ответить
@divyanshmaurya3129
@divyanshmaurya3129 - 11.07.2021 20:09

I like this channel a lot since I came to know about it in UG. I expected more videos since then from this channel but today I came to know why they were not coming.
I am deeply saddened by demise of Harsha RIP🙏🏻.

Ответить
@sanketmule14
@sanketmule14 - 29.07.2021 21:41

I didn't understand how loop will run n-2 times in Ram ALgo. and sqrt(n-1) times in Shyam Algo in worst case. plz explain

Ответить
@md_ashraf6455
@md_ashraf6455 - 28.08.2021 09:18

;)

Ответить
@raushanpandey6053
@raushanpandey6053 - 24.01.2022 20:52

You guys are great man...

Ответить
@hometvfirestick
@hometvfirestick - 08.02.2022 13:28

amazing

Ответить
@dhruvmalik8052
@dhruvmalik8052 - 15.03.2022 18:01

Very helpful video
thanx bro

Ответить
@LuckyPatel
@LuckyPatel - 03.04.2022 16:00

am i Late?

Ответить
@vansh8216
@vansh8216 - 23.05.2022 15:39

Sham rox Ram shox

Ответить
@truegrabbers
@truegrabbers - 17.06.2022 22:11

WOW

Ответить
@ArpitSingh-je2sk
@ArpitSingh-je2sk - 18.07.2022 21:48

Miss you sir !

Ответить
@jumbocat805
@jumbocat805 - 11.09.2022 10:40

watching this on Sep 11, 2022! Thanks for great content. :)

Ответить
@asifikbal4771
@asifikbal4771 - 22.10.2022 09:12

plzz upload more videos

Ответить
@Retspm
@Retspm - 17.11.2022 04:14

N is a letter

Ответить
@cineclassicshub
@cineclassicshub - 20.11.2022 19:44

Great explanation!

Ответить
@JameBold
@JameBold - 11.01.2023 18:31

Time Complexity

Prime number is a number that can divided by exactly two numbers
1 and the number itself
smallest prime number is 2

number-prime ?
2
3
5
7


is_prime function

Ram
for (int i = 0; i < input_number; i++) {
if (input_number % i == 0) {
return false;
}
}
return true;



Shyam
for (int i = 2; i <= sqrt(input_number); i++) {
if (input_number % i == 0) {
return false;
}
}
return true;


- lets say 1 ms for a division operation


- Rams program: in worst case performs (input_number - 2) divisions

- Shyam program: in worst case performs (sqrt(input_number) - 1) divisions

------------------------------------------------------------------------
Time to run the program with different inputs
------------------------------------------------------------------------

input_number = 11

Ram program: (11 - 2) = 9 ms

Shaym program: (3 - 1) = 2 ms

------------------------------

input_number = 101

Ram program: (101 - 2) = 99 ms

Shaym program: (10 - 1) = 9 ms

------------------------------

input_number = 1 000 003
= 10⁶ + 3

Ram program: (1 000 003 - 2) ≈ 10⁶ = 10³ seconds
= 16.66 minutes

Shaym program: (sqrt(10⁶ + 3) - 1) ≈ 10³ ms = 1 second

------------------------------


Time complexity of a program is the simple measurement of how fast
the time taken by the program grows if the input size increases

Ram program:
Time ∝ input_number O(input_number)
The time taken by the program is proportional to the input_number

Shaym program:
Time ∝ sqrt(input_number) O(sqrt(input_number))
The time taken by the program is proportional to the square root of the input_number

Ответить
@paia6447
@paia6447 - 10.02.2023 09:11

Sieve of Eratosthenes prime numbers is least execution i think

Ответить
@ShivaMahajan07
@ShivaMahajan07 - 20.07.2023 12:05

such a great explaination

Ответить
@ramavathvivek7091
@ramavathvivek7091 - 03.06.2024 14:05

I dont how the lecture was passed away but may your soul rest in peace sir 🙏

Ответить
@auguststas7770
@auguststas7770 - 23.06.2024 20:44

why n-2 times while sqrt(n-1) times???

Ответить
@sandeeps6174
@sandeeps6174 - 08.08.2024 04:47

why must a grief for a man i have never met

Ответить
@gowrisankar5004
@gowrisankar5004 - 06.10.2024 18:56

Ram what a loser!!!!!!

Ответить
@nabinkoirala6846
@nabinkoirala6846 - 19.02.2025 09:47

I am here in 2025, and I can bet if there are any better videos of Big 0 notation than this.

Ответить