Edits to Complexity sprint 1#1428
Conversation
SallyMcGrath
left a comment
There was a problem hiding this comment.
Lovely! A few small text changes.
|
|
||
| Big-O notation is focused on the _trend_ of growth, not the exact growth. | ||
|
|
||
| If we think about strings, one character may take up one byte or four. If we think about doubling the length of the string, we don't worry about what characters are actually in the string. We think about the _trend_ - the string will take _about_ twice as much space. If the string only contained four-byte characters, and we only added one-byte characters, the string is still growing linearly, even though it may not take exactly double the space. |
There was a problem hiding this comment.
I think this might belong in the coursework ?
The trend is explained in the linked texts btw!
There was a problem hiding this comment.
I think the reading is quite vague on this - I think the only coverage is "Big O notation is used to express the worst-case scenario of an algorithm's runtime performance, abstracting away constants and lower-order terms to focus only on the most significant factors that affect the running time." which is easy to miss or mis-understand, so figured it was worth re-stating. Rephrased repetition is helpful...
There was a problem hiding this comment.
Ok, let's just simplify this a bit then? I made a tiny edit
| - Objects and arrays need memory for their internal organisation _as well_ as the data itself. | ||
| - Objects and arrays are stored in different ways in different languages. But they need to store _at least_ the information contained within them. | ||
| - This means an array of 5 elements will use _at least_ as much memory as the 5 elements would on their own. | ||
| - And objects will use _at least_ as much memory as all of the _values_ inside the object (and in some languages, all of the keys as well). |
There was a problem hiding this comment.
Again, is this a bit too much info? We don't want to overload them.
There was a problem hiding this comment.
Maybe... Let's maybe have a chat about it?
I changed it because the previous content is kind of misleading - in most compiled programming languages, arrays and objects take exactly as much space as their contents/members/fields, so I wanted to avoid instilling an intuition that they have overhead where they don't necessarily...
There was a problem hiding this comment.
Hmm, it's a good point. I was trying to steer away from the python size of debacle I've encountered before with trainees and have oversteered.
Co-authored-by: Sally McGrath <sally@codeyourfuture.io>
Co-authored-by: Sally McGrath <sally@codeyourfuture.io>
|
|
||
| What does this mean? It means that the time is the square of the input size: n\*n. | ||
|
|
||
| An example is finding which elements in an array are present more than once. For each element, we need to check every other element in the same array to see if they're equal. If we double the number of elements in the array, we _quadruple_ the number of checks we need to do. |
There was a problem hiding this comment.
TBH I had intended these just as a visual, that's why I rm the examples - but if you want them, I'm ok with this
No description provided.