IMG_0935.jpeg
Document Details

Uploaded by NimbleFermat428
UNAM
Full Transcript
# Lecture 14: December 5, 2023 ## Review for Final ### Logistics * **Final:** December 18, 1:30-4:30 pm, Olin 255 * **Coverage:** Cumulative, but with emphasis on the material after the second prelim * **Format:** Similar to prelims (mix of short answer, multiple choice, and coding question...
# Lecture 14: December 5, 2023 ## Review for Final ### Logistics * **Final:** December 18, 1:30-4:30 pm, Olin 255 * **Coverage:** Cumulative, but with emphasis on the material after the second prelim * **Format:** Similar to prelims (mix of short answer, multiple choice, and coding questions) * **Content:** * Everything covered in lecture and assignments is fair game * Will provide a reference sheet with important formulas and definitions ### How to Prepare * Review lecture notes and slides * Go through assignments and solutions * Practice coding problems * Come to office hours with questions ## Topics Since Prelim 2 ### 1\. Concurrency * Threads and processes * Race conditions and critical sections * Locks *\&* Semaphores * Deadlock and livelock * Condition variables * **Readings:** * "Operating Systems: Three Easy Pieces", Chapters 26 - 32 ### 2\. Networking * Layered architecture (TCP/IP model) * Sockets * Clients and servers * HTTP and REST APIs * **Readings:** * "Computer Networking: A Top-Down Approach", Sections 1.1-1.5, 2.1-2.3, 2.5-2.7 ### 3\. Security * Vulnerabilities and attacks (e.g., buffer overflows, SQL injection, XSS) * Cryptography (e.g., symmetric and asymmetric encryption, hashing, digital signatures) * Authentication and authorization * **Readings:** * "Security Engineering", Chapters 1-4, 6, 11-12, 15-16 ### 4\. Data Science * Data collection and cleaning * Exploratory data analysis * Feature engineering * Model selection and evaluation * **Readings:** * "Python Data Science Handbook", Chapters 2-5 ## Example Problems ### 1\. Concurrency Consider the following code snippet: ```python import threading counter = 0 lock = threading.Lock() def increment(): global counter for _ in range(100000): with lock: counter += 1 threads = [] for i in range(2): t = threading.Thread(target=increment) threads.append(t) t.start() for t in threads: t.join() print("Counter value:", counter) ``` **a)** What is the purpose of the lock in this code? Explain how it prevents race conditions. **b)** Can deadlock occur in this code? Why or why not? **c)** How would you modify this code to use a semaphore instead of a lock? Provide a code example. ### 2\. Networking **a)** Explain the difference between TCP and UDP. When would you use each protocol? **b)** Describe the steps involved in a TCP handshake. **c)** What is a REST API? Give an example of a REST API endpoint and explain its purpose. ### 3\. Security **a)** What is a buffer overflow? How can it be exploited by an attacker? **b)** Explain the difference between symmetric and asymmetric encryption. Give an example of each. **c)** What is SQL injection? How can you prevent it? ### 4\. Data Science **a)** Describe the steps involved in a typical data science project. **b)** What is feature engineering? Give an example of how you might engineer a new feature from existing data. **c)** Explain the difference between supervised and unsupervised learning. Give an example of each. ## Question from the Audience Explain global interpreter lock(GIL).