CS50 Flashcards

1
Q

what is the input to any computer?

A

elictiricity

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what does electricity represent in computers?

A

zeros and ones

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is the highest you can count with 3 light bulbes?

A

up to 7 as we count from 0 and we have 8 patterns to count

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

how did we count that 123 is one hundred and twenty 3?

A
because from the right to the left we use the base of 10
3 * 1 + 10^0
2 * 10 + 10^1
1 * 100 + = 10^2
123
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what is the base to calculate in binary systems?

A

2 ^ 0 1
2 ^1 2
2^ 2 4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

how to represent letters in binary?

A

we use numbers to represent each letter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is a byte?

A

8 bits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is a bit?

A

a zero or a one

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

how many letters can u represent with a byte?

A

256

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what is an algorithm?

A

it’s a step by step instruction to solve a problem

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what is a compiler?

A

a software that converts source code to machine code?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what is machine code?

A

it’s the language of zeros and ones

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

how is the code evaluated?

A

from right to left

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

how many bytes in an int?

A

4 bytes (32 bits)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what is an unsigned integer?

A

it’s not a new data type it’s just a qualifier for int meaning it changes it’s properties containing only positive values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

how many bytes does char take?

A

1 byte (8 bits)

17
Q

how many bytes does a float take?

A

4 bytes (32 bits)

18
Q

how many bytes does a double take?

A

8 bytes (64 bits)

19
Q

when is && evaluates to true?

A

when all of the operands evaluate to true

20
Q

when is || evaluate to true?

A

when only one condition is true

21
Q

what happens when you don’t break in switch case?

A

u fall down the cases after one of them evaluates to true

22
Q

how many steps in compiling?

A

preprocessing:
copies functions prototypes any #include to current file
compiling:
converts source code to assembly code
assembling:
converts assembly code to machine code zeros and ones
linking:
links our zeros and ones to the original C language zeros and ones and other libraries

23
Q

what is an array?

A

a sequence of contiguous values stored back to back

24
Q

can u initialize an array with a variable?

A

no it must be a constant

25
what is the null character?
\0 8 zero bits
26
when can we describe an algorithm in theta?
if the upper bound is the same as the lower bound
27
what is the complexity of linear search?
O(n) | sigma(1)
28
what is psuedo code for linear search?
starting from first element till last if we find element then exit otherwise move to next element
29
what is the main idea of binary search?
divide and conquer | each loop divide it by half
30
what is the condition to do binary search?
elements must be sorted
31
what is the complexity of binary search?
O(log n) | sigma (1)
32
what is psuedo code for binary search?
repeat until subarray of size 0 (start and end are crossed) calculate the current middle point of the current array if the target is at middle or if the target is less than what's at the middle, repeat but change the endpoint to be just the left of the middle or if the target is more than what's at the middle, repeat but change the start point to be just the right of the middle
33
what is the main idea of bubble sort?
move higher elements to the right and lower value elements to the left
34
what is psuedo code for bubble sort?
``` set swap counter to non-zero repeat until is swap counter not zero set counter to zero look at adjacent pairs if not in order swap them and increase counter by one ```
35
what is the complexity of bubble sort?
O(n2) | sigma(n)
36
what is the main idea of selection sort?
find the smallest element in an unsorted list and add it to the end of the sorted list
37
what is psuedo code for selection sort?
repeat until no unsorted elements remain: search the unsorted part of the data to find the smallest element swap the smallest value with the first element of the unsorted part
38
what is the complexity of selection sort?
O(n2) | simga(n2)