@andarted

There is something I don't understand. I'd be very grateful if anyone could explain it to me.

3:14 "With this sort algorithm, we loop through each position in the array, from top to bottom, and then for each of those positions, we have to loop through the array to find the smallest number to swap. You can see this in the code, where one FOR loop is nested inside of another FOR loop. - This means, very roughly, that if we want to sort N items, we have to loop N times inside of which, we loop N times, for a grand total of roughly N times N loops ... or N squared."

I would have thought that this algorithm would not need roughly N² runs in total, but roughly (N²)/2 runs.

I'll try to demonstrate what I mean with an example. Say we have 4 values (2, 4, 6 and 8), and so 4 positions (A, B, C, D) for values.

_
Before first run:

_Start:

A - 8
B - 4
C - 2
D - 6

_
First run:

It needs 4 checks to find the smallest number.
[8 goes from A to C, 2 goes from C to A]

- total: 4 checks -

A - 2
B - 4
C - 8
D - 6

_
Second run:

Now the algorithm starts at position B. It needs 3 checks to find the smallest number.
[4 checks + 3 checks = 7 checks]

- total 7 checks -

A - 2
B - 4
C - 8
D - 6

_
Third run:

Now the algorithm starts at position C. It needs 2 checks to find the smallest number.
[7 checks + 2 checks = 9 checks]

- total 9 checks -

A - 2
B - 4
C - 6
D - 8
_
Fourth run:

The FOR circle is finished, because 4 is the end of the array.

____
In total there were 9 checks.

To use the quote from the beginning: "This means, very roughly, that if we want to sort N items, we have to loop N times inside of which, we loop N times, for a grand total of roughly N times N loops ... or N squared."

N is in this example 4. And 4² is16. But in reality it took just 9 checks.

❗️16 isn't roughly 9, it's about twice the amount.

I could imagine, that this is just some kind of writing standard, that doesn't necessarily reflect the reality.

Or maybe, there is something I don't understand here. I don't like this doubt. Therefore, I would be very grateful to anyone who can tell me where my mistake lies.

@DuluthTW

This course is getting better - while it started out great anyway.

@hybridhorrors666

Algorithm is with you in every where its how you manage your daily day by sort your things your cloths etc don't thing it only computer algorithm it's with you in every where but you don't know !

@pinklady7184

I have watched all your videos, Carrie. Now I am looking forward to your next video #14.

@kujmous

This is my favorite episode!

@colza1025

Brilliant intro! Thank you. The graph search is awesome and I was really intrigued to search further. :)

@coolyashvanjani

I do hope the Tyrells are not going to murder the Starks!!

@stefanos-phoebosnahmias8736

i want to study game development and i know, in order to make a game you need algorithms, but i am not particularly good at math and sometimes when it gets too confusing, my mind gets lost. though, i am positive that i understood 65% of this video. Will i make it XD???

@RumbleFish69

Many people don't know that "algorithms" are computer rhythms that were created by Al Gore - The "Al Gore Rhythms". That is how we know that he invented the internet.

@jonasnvra946

What algorithm did you use to learn "the Persian polymath Muhammad ibn Musa al-Khwarizmi"?

@hammadkhan6455

i want to weep

@GlamAleks

I don't understand the merge sort example here - what if bottom numbers from the second set of four are lower than top sorted numbers in the first set?

@ahmedboutaraa8771

I'm speechless

@chakubanga1

I need a sharp mind to discern the algorithm of talking speed..

@omarg1976

helpful

@buccleuch7621

Informative but speed of delivery could be moderated. Just saying!

@BlueyMcPhluey

10:25 how do you get "around 14" loops?

@kaitlinhc7781

I need help with this stuff. There’s something happening and it’s most important that I can prove it. Will you help me? Will anyone help me???

@Rohit-rx5rz

Please any one help. I am in 1st year 2nd semester going to finish. Now holidays due to Corona virus .I cant develop the logic of how to put the values properly and all .for eg like in pattern printing and most of the competitive problems like in codeforces and hackerank. My friends do simply all these.i dont know how to do it. What should I do. HELP.i dont know what And how to code.

@kuldeepsbiology4496

Its too fast