This problem set is due on Wednesday May 6, 2020 at 20:00 Central, to be submitted on Gradescope. Each problem is worth 10 marks in total.
poll(V) returns the result of one vote, uniformly at random.
next(V) returns the result of the "next" vote. You can use next() to iterate through the votes in no particular order. It will return null if you have iterated through all of the votes.
votes(V) gives you the total number of votes.
reset(V) resets the iteration.
{Gilgamesh, Jeanne d'Arc, Gilgamesh, Gilgamesh, Jeanne d'Arc, Zhuge Liang, Gilgamesh, Cú Chulainn, Hans Christian Andersen, Oda Nobunaga, Jeanne d'Arc}.Then
votes(V) returns 11. Calling poll(V) will return one member, chosen at random with uniform probability, from the set of results. Calling next(V) repeatedly will result in iterating through members of the set one at a time, for example, a series of calls to next(V) returns in succession:
Gilgamesh, Gilgamesh, Hans Christian Andersen, Zhuge Liang, Jeanne d'Arc, Oda Nobunaga, Jeanne d'Arc, Gilgamesh, Jeanne d'Arc, Gilgamesh, Cú Chulainn.Calling
next(V) after iterating through the entire set will return null until reset(V) is called. After reset(V) is called, calling next(V) will iterate through members of the set again, in some order. The order in which the set is iterated through is not guaranteed to be the same.partition(V) which, in $O(1)$ time, returns a partition of $V$ into two sets $(V_1,V_2)$ with $|V_1| = \left\lfloor \frac n 2 \right\rfloor$ and $|V_2| = \left\lceil \frac n 2 \right\rceil$. All of the available functions can be called on $V_1$ and $V_2$.