### Preparing for the second midterm exam

Everything I said before the first midterm exam about how to prepare for the midterm and what kinds of questions I am going to ask is still true for this second midterm exam. So, make sure that you read this page as well.

The exams are cumulative. That means, all concepts that were relevant for the first midterm exam are relevant for this second midterm as well. However, the second midterm will focus on these new concepts

- lists (simple lists as well as lists of lists)
- recursion
- binary numbers, number bases in general, (ASCII) encoding strings as numbers

For lists, you should be able to do the following things:

- Given a Python expression, identify whether that expression is a valid list or not. If not, explain why not. If yes, what is the length of the list?
- Know what indexing and slicing are and how to use them to retrieve a specific element or a specific sublist from a list. (Check out Codelab if you want to practice this.)
- Also, know how to use indexing to retrieve the content of a single cell from a list of lists representing a grid.
- How do you traverse a list in Python? I.e., what construct allows you to look at each element of a list (independently of how long the list is)? What construct do you use if you only need to access the
*values*of the list elements? What construct do you use if you also need to access the indices? - Explain what linear and binary search do and how they work. (You do not have to be able to reproduce the Python code for binary search. But you have to be able to write down the strategy in English.)

For recursion, you should be able to do the following things:

- Explain what recursion is.
- Identify a recursive program and explain why it is recursive. Point out the base case and the recursive case.
- Read a recursive program and describe the behavior of this program.
- Given a problem, devise a recursive strategy for solving the problem. You don't have to give the Python code, but you have to describe the strategy in English and point out how it is recursive, that is, where the recursive call happens and what the base case is.

For binary numbers, you should be able to do the following:

- Given a number in binary representation, say what it is in decimal representation, and explain how you arrived at that result.
- Same thing the other way round, that is, decimal to binary.
- Given a number in base x representation (where x will probably be an integer between 2 and 16), say what it is in decimal representation and explain how you arrived at the result.
- Explain how the computer internally represents words a binary numbers.