Question
Someone please help me solve this code. The language is Python 2 There are two inputs to this question: 1) A list of words 2)
Someone please help me solve this code. The language is Python 2
There are two inputs to this question:
1) A list of words
2) A list of tuples that represent directed edges in a graph.
Imagine that there exists a graph consisting of 26 nodes wherein each node corresponds to one letter of the English language. You are given a list of words as well as a list of lists. Each of the sublists in the latter input represents a directed edge between two letters i.e. ('a', 'b') represents an edge going from a to b. You task is to determine whether or not each word given in the input can be spelled out by tracing the edges in this graph, starting at any node. The output should be a list of 1's and 0's (1- True, 0 = False), in order of the input words.
For example, let's say you get ['a', 'b', 'ab', 'ba'] and [('a', 'b')]. The output should be [1,1,1,0].
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started