# a4.py # STUDENTS: update the next three lines and then delete this one # PUT YOUR NAME(S) AND NETID(S) HERE # Sources/people consulted: STUDENTS: FILL IN OR WRITE "NONE" # PUT DATE YOU COMPLETED THIS HERE # Skeleton by Lillian Lee (LJL2) # Apr 20 2018 (This version folds in updates) # STUDENTS: # Instructions: implement the bodies of the predefined function headers below # according to their specifications. # # Rule 1: no direct or indirect calls to positions._collect_reachable_positions() # in any code you submit. # (Using positions.draw() to debug is OK, but delete such calls before # submission.) # # Rule 2: No strategies that essentially "flatten" an org chart into a # non-nested list (of strings, Positions, whatever) and then operate on that. # Rule 1 is actually a consequence of rule 2. # # (We want to see you directly implement recursion in two different settings, # even though a valid alternate approach in real life is to collect up all # reachable positions in a flat list, and then for each of the two problems # below you just iterate over that, doing different things for in the iteration.) # # Rule 3: implementations must make effective use of recursion. It's OK to # include for-loops or anything else, too. def posns_above(root): """Returns: list of Positions that supervise Position `root`, or supervise `root`'s supervisors, ... and so on up. No repeats in the returned list. (OK if different Positions have the same title) """ pass def map_people_to_positions(root): """Returns: dictionary of netids of people who hold the `root` Position or any Position subordinate to `root`, or subordinate to a subordinate of `root`, and so on, all the way down. The value for a given netid: list of Positions held by that netid that are the `root` Position or any Position subordinate to the `root`, or subordinate to a subordinate of `root`, all the way down, no repeats. Do not include keys that are not netids in your returned Dictionary; there should be no key entry representing vacant or non-specified. """ pass