Tutor profile: Cody H.
Subject: Python Programming
Python lacks an or-equals operator. This may tempt some users into using |= as a substitute (the bitwise or-equals). However, it's not exactly the same. What is the difference between: x = x or (...) and x |= (...) given that the (...) are identical in the two cases?
You are probably familiar with the idea that boolean operations short-circuit in most programming langauges: "true or (...)" does not require the second expression to be evaluated to know for a fact that the result of the entire computation is true. What is sneaky here is that bitwise-or cannot short-circuit, because the value of every bit needs to be computed, not just the true/false value (the only things that even could short circuit in theory would be all 1's with a bitwise or, and all zeros with a bitwise and, but remember "true" is usually represented as the integer 1, or ...000001 in binary), therefore using bitwise or instead of boolean or can cause expressions to be evaluate that would otherwise be short-circuited. If x = true, then "x = x or CrashComputer()" would not run CrashComputer(). However "x = x | CrashComputer()" would, perhaps unfortunately, run CrashComputer().
Subject: C++ Programming
Given an input array of size N, and the task of finding some element within the array that has the property P, under what circumstances is it possible for there to exist a solution with time complexity less than O(n)?
We must a priori know something about the relationship between elements of the array, so that we can learn things about elements without looking at all of them. In general, we can say the input data must be structured. Examples of structure include: sorted, all elements equal, partitioned by some property; however there are, of course, infinite possibilities for ways that data can be structured.
Subject: Artificial Intelligence
Is it possible for alpha-beta pruning to change the final output of the algorithm? Why or why not?
No, because alpha-beta pruning only removes branches of the tree that are known to be worse than some other option available. An example of "pseudo" alpha-beta pruning is when humans play chess, if we see that a certain move will cause us to lose our queen without immediately checkmating the opponent, we will stop calculating this line of play and look at other lines which don't lose our queen. This is only "psuedo" alpha-beta pruning because we don't know for a fact that losing our queen is bad until we've seen that it leads to our getting checkmated, at which point there would be no pruning occurring (because we've computed all the way to the end of the game tree).
needs and Cody will reply soon.