Q: Is there a grace period for Assignment 3?
A1: Yes.
Q: What does the small on time bonus do
A1: Increases your score on the assignment by a small percentage
Q: Just a clarification, is every on time bonus added on an assignment by assignment basis? Or is the time bonus stored and then all of your bonuses are added to your grade at the end?
A1: Applied on an assignment-by-assignment basis but not shown in Paperless
Q: So is the Karel problem on the HW an example of the count the number of solutions problem
A1: Yes!
Q: Dose HW Keral fit this category?
A1: Yes, it does!
Q: How does it know to print out everything w lines in the middle?
A1: The base case prints the newline at the end of the question (i.e. after printing the N flips, each line ends with newline)
Q: Is the âsofarâ a string of all of the possibilities? How does it know to add âHâ to each combination in sofar?
A1: soFar is tracking the partial sequence that has been built us thus far.In the recursive case, we extend that partial sequence as the argument being passed into the next recursive call
A2: sofar is a string of thr current possibility being explored. We test adding just the H and just the T at every level of the recursive case
Q: should we try to just use recursive normally first just due to the exponential nature of using a tree
A1: The more experience that you have with recursion, the better your intuition will be for which type to use (similar to the intuition you get with looping)
Q: is it possible to call another recursive function to call generateLetterSequences with all the alphabet letters?
A1: live answered
Q: What does the 12 stand for again?
A1: There are 12 chars in the password
Q: What is Chris pressing on his keyboard that makes it so he can jump around the code so quickly?
A1: live answered
A2: Option and an arrow key
Q: Instead of substring, could we use remaining = soFar.erase(i,1) or would that edit soFar by accident?
A1: live answered
Q: what does the original function call look like? what are the initial fvalues of soFar and rest
A1: The initial value for rest is the entire input string, and soFar starts as empty string
Q: If we input duplicating characters, this function will consider some equal strings as different solutions âaabcâ and âaabcâ. Should we use a Set to avoid this problem?
A1: live answered
Q: It looks like it is outputting the string in lexicographic order. Will that always happen as long as the input string is in lexicographic order?
A1: live answered
Q: Is this still O(a^n) type growth?
A1: Permute is O(N!) â do you see why?
Q: Whatâs the point of doing this?
A1: live answered
A2: Convenience, makes the interface to permute a little cleaner
Q: Oh I see it has one fewer branch each level down
Q: oops I meant that nicely, sounds kinda passive aggressive
A1: youâre good
Q: so the search is pruned and the recursion tree stops going down a particular path
if a substring is not a word?
A1: correct
A2: well if the substring is not the prefix of a word
Q: Could you also return reducible(lex, copy) or whould that do something else?
A1: live answered
Q: can u combine the two ifs
A1: yes using &&
Q: Would this potentially return true twice?
A1: No, once you return once, the recursive call is over
A2: No, the first solution found will return true without searching further
Q: wouldnât the for loop stop when you return true in the if loop
A1: Yes, it will!
A2: Yes, but since we are only looking for a yes/no answer of whether or not the word has the property, so we do wanst to stop as soon as we know the answer is yes
Q: Is a âsolutionâ defined as we get a word even if we pull one letter out? Like we donât have to go all the way to the base case?
A1: live answered
Q: Could you explain the return true in the recursion part once again?
A1: live answered
Q: Doesnât the return true prevent you from removing more letters?
A1: No, because you recurse prior to returning true
Q: In the base case, should we return false if lex doesnât contain word?
A1: This already happens on line 56
Q: Could you put return false inside the for loop but after the if statement?
A1: No, this would cut off the next iterations of the loop
A2: No, because you donât want to return false until youâve tried out al lpossible options in the for loop
Q: So, essentially you only want the function to continue unless the recursive call can reach the true in the base case?
A1: Correct
Q: Is it possible to only check for lex.contains once? For example, if you add a base case where the current word is not reducible
A1: live answered
Q: could a base for this problem also be returning true if the word is two letters and contains the letter a or i?
A1: Yes, but this would not be the best style
Q: Why can we use erase function on this one, but not in the permute example?
A1: live answered
A2: You could also use erase in permute, you just have to be careful to make a copy before you modify it
Q: for the 2 ifs statements lex.contains and reducible(lex, copy), can you put them in the same line with &&?
A1: live answered
A2: Yes!
Q: why would it not be the best style?
A1: live answered
A2: It would check something in the next step of recursion, we typically only want to check something at the current step
A3: In this case, we only erase one letter at a time, so checking two separate letters at once defies this
Q: Iâm still struggling - in this example would a word be reducable if at its base case it was reducable, but in the intermittent it wasnât? So say Jar. âAâ is a word, but there are no 2 letter words. Woudl that return true? Or because the base was, woudl it return true all the way up the chain?
A1: live answered
Q: Ahhhh, got it, ty.
Q: how exactly is .erase() come into play? doesn't it remove only the first char? if so then how are you able to check all the words of the same length?
A1: live answered
Q: For "cart", can cart, cat, at, a be a reducible pathway?
A1: Yup
A2: Yes
Q: Is this based in proof by induction? reminds me of that format
A1: Yes, exactly!
Q: Why doesn't rest.substr(i+1) raise an error when we're at the last character in permute?
A1: live answered