Computer Science Can someone convert this python code to racket/scheme programming language. 'to',Process finished with exit code 0if to not in hash_map:# add it to hmaphash_map[to] =...


Computer Science



Can someone convert this python code toracket/scheme programming language.



def reverse_weblink_graph(G):<br>['b', 'a', 'c']<br>['c', 'a',
'to', Process finished with exit code 0 if to not in hash_map: # add it to hmap hash_map[to] = set() hash_map[to].add(u) rev g = [] # finally, merge key, value to a single list with same idea as in # original G for k, v in hash_map.items(): rev_g.append ( [k, *v]) return rev_g G = [['a', 'b', 'c'], ['b', 'c', 'e'], ['c', 'b', 'a']] rev_g = reverse_weblink_graph(G) print(*rev_g, sep='\n') "/>
Extracted text: def reverse_weblink_graph(G): ['b', 'a', 'c'] ['c', 'a', "Ь'] ['e', 'b'] hash_map = {} for u, *v in G: # unpacking element of G; U will get first element ['a', 'с'] # and rest goes to list v for to in V: # for each element in v, means a link from 'U' -> 'to', Process finished with exit code 0 if to not in hash_map: # add it to hmap hash_map[to] = set() hash_map[to].add(u) rev g = [] # finally, merge key, value to a single list with same idea as in # original G for k, v in hash_map.items(): rev_g.append ( [k, *v]) return rev_g G = [['a', 'b', 'c'], ['b', 'c', 'e'], ['c', 'b', 'a']] rev_g = reverse_weblink_graph(G) print(*rev_g, sep='\n')

Jun 02, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here