Tutor profile: Andrew G.
Subject: Basic Math
Cedric has $10. He gives half to his friend and then Cedric spends $2 on a soda. Cedric then sees a $4 toy he wants to buy. Does Cedric have enough money to buy the toy?
(This question is the best example of how interactivity is the bread and butter of tutoring). Let's first draw 10 dollars: DDDDDDDDDD Crossing out every other dollar and then erasing the crossed out dollars we have $5 left: DDDDD Let's now cross out and erase $2 Cedric spent on the soda: DDD We now try to cross out the $4 for the toy, but we can only cross out 3 things! So Cedric does not have enough to buy the toy.
Subject: Computer Science (General)
Describe the similarities and difference between a for loop and a recursive function.
Similarities: Both a for loop and a recursive function both run the same code repeatedly until a condition is met. Differences: A recursive function is a function that calls itself with (ideally) different arguments every time. These arguments have to change or else the recursive function will run forever (or at least until the computer has had enough!). A for loop relies on a counter and is contained within its own block. While a for loop is free to use its counter variable, whatever it does can be independent of it (for example, printing the same message to the console a particular number of times). A good use for a for loop would be for iterating over an array or string you know the length of ahead of time. A good use for a recursive function is for data you don't know exactly how many times you need to call or for a task you can logically break down into a smaller task that has the exact same logic (such as merge sort).
Alice and Bob are having a bike race. The first to travel 24 miles is the winner. Say Alice is travelling at 8 miles/hour and Bob is travelling at 6 miles/hour then. Alice also gives Bob a 12 mile head start. With all of that then: (1) Who is going to win? Alice or Bob? (2) How long will it take for the winner to cross the finish line? (3) How far ahead will the winner be when they cross the finish line?
To solve this problem, you will need to come up with a linear equations for both Alice and Bob. Our input/independent variable will be time (t); our output/dependent variable will be distance. For Alice, we use (a) to represent her distance; we will use (b) to represent Bob's distance. Now that we have come up with good variable names, recall how a linear equation is structured: y = mx + b. Where (y) is the dependent variable, (m) is the "rate of change", (x) is the dependent variable, and (b) is some starting constant offset. For Alice, we know she doesn't have a head start looking back at the problem, so b = 0 for Alice. We also see her "rate of change" (how fast she is moving) is 8 miles/hour, so m = 8. All together, our linear equation for Alice is: a = 8t For Bob, he has a 12 mile head start, so b = 12. He is moving at 6 miles/hour, so m = 6. His linear equation will be: b = 6t + 12 With our equations, we can start to answer the 3 questions. Our strategies will be as follows: (1) To figure out who is going to win, we will use our equations to see at what time (t) both Alice and Bob will reach a = 24 and b = 24 respectively. Whoever has the lower value is the winner of the race (because a lower value of (t) means it took them less time to reach the finish line). (2) (1) will give us (2) for free. The winner's value of (t) will be how long it takes them to cross the finish line. (3) We will plug in the winner's value of (t) into the loser's linear equation. That value will give us has far the loser has traveled, and knowing the winner has traveled 24 miles, our answer will be 24 - loser's distance traveled. Let's solve: (1) For Alice: 24 = 8t. Divide by 8 on both sides, and we get: t = 3. For Bob: 24 = 6t + 12. First we subtract by 12: 12 = 6t. Now we divide by 6: t = 2. So it took Alice 3 hours to finish the race, and it took Bob 2 hours to finish the race, so the winner is Bob! (2) We know the that Bob won in 2 hours from the last problem. (3) We know Bob won in 2 hours, so we will plug in t = 2 into Alice's linear equation to figure out how far she has traveled in 2 hours herself: a = 8t a = 8 * 2 a = 16 At t = 2, Bob is at: b = 6t + 12 b = 6 * 2 + 12 b = 24 So we subtract Alice's distance (a) from Bob's distance (b) to see how far back she is once the race is over: b - a = 24 - 16 = 8. So Bob was 8 miles ahead when he won the race.
needs and Andrew will reply soon.