Lecture 4/24: Lecture 9 Q&A
Lecture 9 Questions and Answers (Exported from Zoom Q&A log)
Q: I had that same problem with my keyboard (bad design by apple) 🍎
A1: That makes 3 of us!! But At least Apple fixed mine for free…
Q: Does this affect due date of assignments?
A1: No, we have not planned to do that
Q: It seems that chris keeps answering questions after class every time, but I couldn't see any questions posted here at that time. where did they post those questions?
A1: He hangs out in the same zoom and answers questions live, so just stay here and you can chat with him. Nick goes to the after-party room and I have office hours. Come by any of those
Q: Random question for homework: Is it safe to assume for search.cpp that there will be a maximum of one beginning punctuation character and one end of punctuation character? (or should I parse out the word to deal with words like @@@@@!apple!@@@@?)
A1: There can be multiple punctuation, remove them all!
Q: it seems like nobody orally asking question but chris could "know" those questions and answer them, which made me confused. and besides, where can I find the links to Nick's and Julie's room/OH?
A1: maybe he is reading them from Chat? or Q&A? Not sure. Zoom links for all office hours are linked on course home page — see right side “Zoom Details”
Q: Why was the string passed by reference again?
A1: In this case, it is simply for efficiency (rather than make a copy)
Q: What's the significance of using const with the input parameters of isPalindrome?
A1: It means that the function will not change s, it is “read only”
Q: is the substring function inclusive of the character at the second parameter
A1: the second argument is the number of characters to include in the substring
Q: why isnt middle defined?
A1: string middle = …. Declares middle as a string type variable and then initializes it
Q: can recursion in any way be compared to a loop?
A1: Sometimes, yes, but not always. The simple examples that have a first/rest form of recursive decomposition is fairly loop-like
Q: does nick use the same link of his OH as after-party room?
A1: I don’t think so but check the Zoom Details to confirm
Q: Would this solution work if the disks weren’t ordered by size on the src to begin with?
A1: Nope, that would cause havoc!
Q: is moveSingleDisk empty in this case?
A1: It is defined in the graphics code to move the disk on the display
Q: why do you call findSolution twice recursively? Shouldn't it see the function take in n-1 as an argument and see it's not 1 and then call itself again
A1: We first move the 4 disks on top to the auxiliary, that is the first recursive call, this uncovers the bottommost disk and it can move to the target. Then we move that tower that was moved aside on top of the bottommost disk
Q: How do you code something like a cantor fractal to “infinity” without crashing your computer?
A1: Correct, you’re gonna have to stop somewhere. In this case, you could stop when the tiny lines were only one pixel long, so no further subdivision is possible
Q: What does Chris mean by “size n-1”?
A1: I think he means level n-1, the size is 1/3
Q: Is size n the size of the original line?
A1: Yes, I think that is the intention. I may be confusing how he is using size versus level
Q: Why 1.0/3 rather than 1/3 or 1.0/3.0?
A1: live answered
Q: Why’d he do it as 1.0/3, instead of just 1/3?
A1: live answered
Q: why is it level-1? I thought we are increasing by one level each time?
A1: The level N fractal has a level N-1 fractal beneath on left and right
Q: Isn’t this be an infinite loop? How does it know to stop after drawing only 5 levels?
A1: There is a base case up at the top of drawCantor that returns without drawing anything once level == 0