text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
and conquer approach looking for Mike Smith,
153.73
2.18
as well as last time's binary search.
155.91
2.174
And then one, which doesn't have to be literally one step.
158.084
2.416
Maybe it's two, maybe it's 10, but it is a fixed finite constant number
160.5
4.2
of steps.
164.7
0.63
And that too might be the running time of some algorithm.
165.33
2.56
Now how do we describe the running times of algorithms?
167.89
2.81
Well, we use some special notation, asymptotic notation,
170.7
3.53
so to speak, which while it might look cryptic at first glance,
174.23
2.71
really is just a handy way of succinctly expressing the fact that you know what
176.94
3.81
the upper bound on some algorithms running time is,
180.75
2.7
what the lower bounds on some algorithms running time is.
183.45
2.62
And if those are one in the same formulas in theta,
186.07
3.09
do you have a coincidence of the two of big O, so speak, and capital theta.
189.16
5.49
So that, while Greek, literally is just a way
194.65
2.17
of expressing a bit more succinctly what these running times are.
196.82
2.96
And we'll continue to revisit this issue as we
199.78
1.916
look at more algorithms and soon data structures still.
201.696
2.894
But this time, we apologize.
204.59
3.58
We pull back a layer here and admit that there is no such thing as a string.
208.17
6.73
Indeed, all this time we've been saying that there's ins, and there's floats,
214.9
3.35
and there's chars, and there's doubles and more.
218.25
2.075
And we've also been saying there are strings,
220.325
1.875
but there really aren't strings.
222.2
1.76
This is sort of a figment of the imagination of our so-called CS50
223.96
3.25
library.
227.21
0.85
But it's a pedagogical simplification that we've
228.06
2.28
been using for the past several weeks, so as to not get
230.34
3.32
lost in the weeds, the lower level implementation
233.66
2.234
details of what a string is, so that we can just get
235.894
2.166
real work done in these first weeks.
238.06
2.01
But now we'll begin to look underneath that hood
240.07
2.58
and see what a string actually is and what the implications are.
242.65
3.87
And it turns out, while more complicated in some sense,
246.52
3.18
it really just boils down to some first principles,
249.7
2.95
what it is the computer is doing underneath that hood.
252.65
3.01
So let's take a look at string first by way of a couple of examples.
255.66
4.9
Let's go in to CS50 IDE, create a new file, save it as Compare zero dot C,
260.56
5.27
and look at the little program that actually doesn't necessarily
265.83
3.45
do what we think it's going to do.
269.28
2.72
In particular, let me go ahead and include our typical,
272
2.91
include CS 50 dot H. And let me go ahead and include standard IO dot H as well.
274.91
5.29
Let me go ahead and use main void, so I'm not
280.2
2.01
going to worry about any command line arguments for now.
282.21
2.47
And then I'm going to go ahead and just prompt the user.
284.68
2.333
Hey user, give me a string called S for instance.
287.013
2.144
And then I'm going to have no newline.
289.157
1.583
I just want that all in one same line.
290.74
1.99
Now I'm going to go ahead and do string S,
292.73
3.22
gets gets string, open paren and close parens,
295.95
2.51
so as to get a string from the user.
298.46
2.12
And then, let me do this.
300.58
1.09
Let me also print T colon and ask the user, essentially, for a string
301.67
4.33
that I'll call T, since T comes after S quite simply.
306
4.32
And now let me just compare these strings as the filename suggests.
310.32
3.37
So I know how to compare, not with if s equals t,
313.69
4.706
because that's the assignment operator.
318.396
1.624
But we know that s equals equals t should compare the values on the left
320.02
5.062
and on the right.
325.082
0.708
So let's try this.
325.79
0.88
So if s equals equals t, then I'm going to go ahead and print out same.
326.67
5.46
Elts, they are presumably difference, so I'm
332.13
2.43
going to go ahead and print out different with a newline character
334.56
3.98
and then save it.
338.54
1.08
So a pretty simple program, so let me go down into my terminal window and run
339.62
3.69
make compare 0.
343.31
2.12
Now let me go ahead and run dot slash compare 0. s,
345.43
4.49
I'm going to go ahead and type in Zamyla.
349.92
3.84
And I'm going to go ahead now and type in Maria.
353.76
3.127
OK, and they're different.
356.887
1.083
I expected as much.
357.97
1.22
Now let's go ahead and run this again.
359.19
1.83
Again with Zamyla.
361.02
1.696
And let's just say Zamyla again, different.
362.716
4.744
What did I do wrong?
367.46
1.004
Let me try this again.
368.464
0.916
Maybe it's the capitalization.
369.38
1.63
So Zamyla in all lower case, different.
371.01
5.11
Well, maybe it's just Zamyla's name.
376.12
1.69
Let me try Rob or RLB?
377.81
3.76
How about RLB?
381.57
1.2
Those are different, as is Rob and Rob.
382.77
2.86
So what is going on?
385.63
1.82
Those strings pretty much look the same to me.
387.45
2.12
I'm typing the same incantation of strings,
389.57
2.273
so what is it that's going on here?
391.843
2.777
You know what, let me do a test with something else.
394.62
2.46
Let me go ahead and create a new file here.
397.08
2.61
I'm going to call this copyzero.c.
399.69
1.66
Maybe I'm just misunderstanding how comparison works.
401.35
2.78
But surely I should be able to copy a string and make an identical copy,
404.13
3.11
so let's do that now.
407.24
1.14
Let me go ahead and create a file called copyzero.c.
408.38
4.58
And let me do an include cs50.h.
412.96
2.75
Include standard io.h into main void, so just as before.
415.71
6.027
And now, let me go ahead and just prompt the user like before.
421.737
2.583
Give me a string s.
424.32
1.3
And I'll put that in a variable, s, calling get string as before.
425.62
4.23
And now, I remember from prior classes that I'm supposed to do,
429.85
5.09
if s equals equals null, maybe I need to do some error checking here.
434.94
4.71