|
Main, Syllabus, Office hours |
Schedule |
Slides |
Daily |
Homework |
Code |
Exams |
Exam 1 | Exam 2 | Final Exam |
General information for exams:
- rules during Exam
- IDs will be checked. Make sure to bring your ID.
- SMART WATCH, tablets, are not allowed in the exam. REMOVE YOUR smart watch.
- Headphones not allowed.
- Caps not allowed. If you have a reason why you have to wear one, talk to the instructor beforehand.
- More logistics information will be added closer to the exam.
- The Cheat sheet (1 page) from the Slides page will be provided by the instructor, along with the exam
- You can bring a BASIC calculator (without data storage, except a single value like that accessed with M+/M-/MR/MC). You may need it for the index calculations for bucket sort.
- Scantron not needed.
- "How should I study for this exam? What should I focus on?"
- Understand and know how to solve problems from the listed Weekly Quizzes. Some problems will be simmilar to those.
- Review and understand what we covered in class.
- Master writing code for the listed functions
- Rules and logistics:
- students must take the exam for their section.
- either no calculator or at most a basic calculator allowed. This will be decided closer to the exam.
- Code - Given the function signature, continue to write code for
- basic/"building block" algorithms over strings, 1D arrays, 2D arrays
- find min or max. E.g.
int get_min(int *arr, int N)
- sum or product over array values. E.g.
int sum_over_array(int *arr, int N)
- answer none/some/all questions. E.g.,
int no_negatives(int arr[], int N)
return 1 if every number is 0 or higher. Else (if at least one number is negative) return 0 .
- check if one string is a substring of another string
- binary search:
int binary_search(int val, int N, int * A)
// use the variable names from arguments
- insertion sort:
void insertion_sort(int * arr, int sz)
// use the variable names from arguments
- indirect sorting (using an array of pointers to strings, or an array of indexes) (- because it was part of the hw)
- individual components of count sort:
- counting keys
- prefix sum (also known as cummulative sum)
- more to be updated
- Topics
- logs that you must be able to answer without a calculator. Remember that lg() = log_2().
- lg for: 1,2,4,8,16,32,64,128,256
- log_3 for: 1,3,9,27,81
- log_4 for 1,4,16,64
- log_5 for: 1,5,25,125
- log_6 for: 1,6,36
- log_7 for: 1,7,49
- log_8 for: 1,8,64
- log_9 for: 1,9,81
- log_10 for: 1,10,100, 1000,10000, (any power of 10)
- time complexity (for loops, if statements, functions): Theta, dominant term(s), best case/worst case where applicable.
- time complexity - short and long answers. For a long answer, be able to fill in all the steps for a detailed solution (like in the hw). E.g. for nested loops fill in all the information for all loops .
- Growth of functions and summations
- Θ, O, Ω, o,ω,
- order functions by their growth,
- e.g. know that if f(n) =Θg(n))=> f(n) = O(g(n)), but not viceversa
- see practice problems above
- Recurrences
- code <=> recurrence formula
- Tree method for solving recurences:
- using the tree method to derive time complexity for Mergesort and other recursive functions
- given recurrences, be able to give tree information at level i (number of nodes at level i, problem size for a node at level i, local time complexity for a node at level i) and number of levels in the tree.
- ?? Master Theorem - to be decided if it will be included
- be able to compare strings using alphabetical order
- sorting - insertion sort, count sort, radix sort, bucket sort, merge sort, quick sort, ?? selection sort ??
- stable?, adaptive?,
- time complexity, space complexity, data moves,
- be able to show the data after each iteration of the [outer/inner] loop without seeing the code (see practice problems).
- Know when (for what data and requirements) is an algorithm applicable and when not. When would you choose one algorithm over another (e.g. depending on system limitations for memory, or time requirements or some specific distribution of the data)?
- If given code for a variation of one of the sorting algorithms, be able to analyze it: Is it stable? Is it adaptive? What time and space complexity does it have? Is it a direct or indirect sort?
- for bucket sort study both formulas for computing the index: floor((elem-min)*N/(1+max-min)) and also the easier one : floor(elem*N)
- Binary search
- Indirect sort for insertion sort. E.g. given Data array, fill in values for the Index array after indirect sorting. Why/when would we use indirect sort?
- To be decided: QuickSelect (return k-th smallest item)
- Not included (not tested in the quiz):
- proving that an algorithm is correct;
- writing code for any algorithm not explicitly mentioned in the Code bullet
Practice problems:
- W-quizzes
- Understand and know how to solve problems similar to those in Homework 1.
- PRACTICE time complexity of loops, and Solution to a couple of problems (pdf, docx)
- Growth of functions, summations ( Solution )
- insertion sort, indirect sorting, binary search ( Solution)
- count sort, radix sort, bucket sort practice, (Solution ) - Problem NCS3 (about the formula for mapping numbers from [A,B] to [X,Y]) will probably not be part of the exam.
- Merge sort, Quick sort (Solution)
- Recurrences ( Solution ) - Master Theorem may or may not be part of this exam (depending when we cover it).