Q1. Scenario: You are building a recommendation system for a movie streaming platform. Each user's preferences are represented as a vector of ratings across 1000 movies. How would you represent two users' similarity using vectors?
Vectors are ordered lists of numbers that represent magnitude and direction. In this scenario, each user's rating vector has 1000 dimensions. To compute similarity, you can use the dot product or cosine similarity. Cosine similarity measures the angle between two vectors, ignoring magnitude, which is useful when some users rate more generously than others. The formula is cos(θ) = (A·B) / (||A|| ||B||). A higher cosine similarity (close to 1) indicates similar taste.
Q2. Scenario: In a self-driving car, the car's position is tracked using a vector [x, y, z] and its velocity vector [vx, vy, vz]. If the car moves for 2 seconds with constant velocity, what is the new position vector?
The new position vector is the initial position plus velocity multiplied by time: new_position = initial_position + velocity * time. In vector form: [x + vx·2, y + vy·2, z + vz·2]. This is vector addition and scalar multiplication. This fundamental operation is used in physics simulations, game development, and robotics for predicting object movement.
Q3. Scenario: You have a vector representing daily sales for a week: [120, 95, 110, 130, 105, 150, 140]. How would you calculate the total sales for the week and the average daily sale using vector operations?
Total sales is the sum of all elements in the vector: 120+95+110+130+105+150+140 = 850. In vector terms, this is the L1 norm or simply element-wise sum. The average is total divided by number of elements (850/7 ≈ 121.43). This is the mean of the vector. In data science, converting data into vectors allows efficient batch processing with libraries like NumPy.
Q4. Scenario: In natural language processing, you convert sentences into word embedding vectors (e.g., 300-dimensional). If you have two sentences, The cat sat" and "The dog sat" and their embedding vectors are A and B. How would you find the word that differs most between them?
Compute the difference vector D = A - B. The largest absolute value in D corresponds to the dimension where the embeddings differ most. This dimension might correspond to "cat" vs "dog". Vector subtraction is used in analogy tasks like "king - man + woman ≈ queen". This demonstrates how vector arithmetic captures semantic relationships.
Q5. Scenario: In a physics engine a force vector F = [5-3 2] Newtons is applied to an object of mass 2 kg. What is the acceleration vector? Use Newton's second law.
"Newton's second law: F = m·a so a = F / m. Divide each component by mass: a = [5/2 -3/2 2/2] = [2.5-1.5 1] m/s². This is scalar multiplication (scaling) of a vector. This operation is used everywhere in game physics and simulation to update velocities from forces.
