Flashcards in CS50 Week 3 Deck (31):
What happens if you try to access an element beyond the bounds of an array?
A segmentation fault
What function will convert a char to a value?
What is a simple but effective debugging technique?
What is the clang argument that allows for gdb debugging?
After compiling, how do you open GDP?
where debug is the name of the program being debugged.
What is a breakpoint in gdb?
A point at which the program pauses executing
Where is a convenient place to put the first breakpoint?
How do you step line by line through your code in gdb?
How do you reenter the last command you typed?
hit enter with no command.
How do you start your program running from within gdb?
How do you check the value of a variable at the point that you are in the code, while within gdb?
where i is the name of the variable
How do you display the code before and after your current position?
How do you move execution by execution within a function call, using gdb? This is distinct from the command "next"
step will be distinct from next only if you are at a function call, in which case it will follow the function instead of going to the next line of code in the sequence.
How do you set a breakpoint in gdb
What is a linear algorithm?
An algorithm of n complexity.
It will execute n times where n is the size of the input.
What is a logarithmic algorithm?
An algorithm of log(n) complexity.
It will execute log(n) number of times, where n is the size of the input.
What is bubble sort?
A sorting technique that starts at the first two values of a non-sorted sequence and compares them. If the numbers are out of order, it swaps the first and second values. Then it compares the second and third values, and does the same. It does this until the entire sequence can be read with no swaps.
What is the complexity of bubble sort?
What is selection sort?
The algorithm reads each value in a non-sorted sequence and remembers the smallest number. It then swaps the smallest number with the first number in the sequence. It then repeats this process on the unsorted elements of the sequence until all are sorted.
What is the complexity of selection sort?
This ends up being very close to n^2, so we say n^2
What is insertion sort?
An algorithm that sorts the elements in place. It examines each element in a non-sorted list, and places it in the appropriate position in a sorted list.
What is the complexity of insertion sort?
What is the best case scenario for bubble sort?
What is the best case scenario for selection sort?
What is the worst case scenario for linear search?
What is the worst case scenario for binary search?
What is the best case scenario for binary search?
What is the best case scenario for linear search?
In GDB, how do you display the active variables?
How do you deactivate a breakpoint in GDB