0% found this document useful (0 votes)
38 views2 pages

Lecture 3 - CS50x 2022

This document summarizes key points from Lecture 3 of CS50x 2022. It discusses searching algorithms like linear search and binary search. It introduces concepts like Big O notation used to analyze algorithm efficiency. Specific algorithms covered include selection sort and bubble sort. The document also discusses recursion and merge sort. Lastly, it reviews the purpose of learning programming is to solve problems by creating outputs from given inputs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views2 pages

Lecture 3 - CS50x 2022

This document summarizes key points from Lecture 3 of CS50x 2022. It discusses searching algorithms like linear search and binary search. It introduces concepts like Big O notation used to analyze algorithm efficiency. Specific algorithms covered include selection sort and bubble sort. The document also discusses recursion and merge sort. Lastly, it reviews the purpose of learning programming is to solve problems by creating outputs from given inputs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

9/17/23, 2:56 PM Lecture 3 - CS50x 2022

This is CS50x
CS50’s Introduction to Computer Science

OpenCourseWare

Donate  (https://cs50.harvard.edu/donate)

David J. Malan (https://cs.harvard.edu/malan/)


[email protected]
 (https://www.facebook.com/dmalan)  (https://github.com/dmalan) 
(https://www.instagram.com/davidjmalan/)  (https://www.linkedin.com/in/malan/)
 (https://orcid.org/0000-0001-5338-2522) 
(https://www.quora.com/profile/David-J-Malan) 
(https://www.reddit.com/user/davidjmalan) 
(https://www.tiktok.com/@davidjmalan)  (https://davidjmalan.t.me/) 
(https://twitter.com/davidjmalan)

Lecture 3
Last week
Searching
Big O
Linear search, binary search
Searching with code
Structs
Sorting
Selection sort demonstration
Bubble sort demonstration
Selection sort
Bubble sort
Recursion
Merge sort

Last week
https://cs50.harvard.edu/x/2022/notes/3/ 1/20
9/17/23, 2:56 PM Lecture 3 - CS50x 2022

 Recall that our purpose for learning a new programming language and other tools is to
solve problems. And we solve those problems by creating some output from input:

 We learned about memory, which allows us to store data as bytes, and strings, which are
arrays of characters.

Searching

 Today we’ll focus on algorithms that solve problems with arrays.


 It turns out that, with arrays, a computer can’t look at all of the elements at once. Instead,
a computer can only to look at them one at a time, though we can look in any order, like
only being able to open one locker at a time:

 Recall that arrays are zero-indexed, meaning that the first item has an index of 0.
And with n items, the highest index would be n − 1.
 Searching is how we solve the problem of finding information. A simple problem has an
input of some values, and an output of a bool , whether or not a particular value is in the
array.

Big O
 Today we’ll look at algorithms for searching. To compare their efficiency, we’ll consider
running time, or how long an algorithm takes to run given some size of input.
 Computer scientists tend to describe running time with big O notation, which we can
think of as “on the order of” something, as though we want to convey an idea of running
time and not an exact number of milliseconds or steps.
 In week 0, we saw a chart with different types of algorithms and the times they might
take to solve a problem:

https://cs50.harvard.edu/x/2022/notes/3/ 2/20

You might also like