Can you write a pseudocode for this code? CODE (PYTHON) Function to construct def construct(): # Open file fin = open('i
Posted: Fri Jun 10, 2022 11:58 am
Can you write a pseudocode for this code?
CODE (PYTHON)
Function to construct
def construct():
# Open file
fin = open('input.txt', 'r').readlines ()
# Input s and create Dictionary
fin[1].strip()
S
=
D = {}
# Add words to dictionary
for i in range (2, len(fin)):
line fin.strip()
D[line] = 1
=
# Initialize parameters
i = 0
C =
words
=
[]
# Loop over characters of s
while(True):
if(i>=len(s)): break
# If current word is in D, store
C += s
if (c in D.keys()):
words.append(c)
C =
if(i==len(s)-1 and c!=""): return
i += 1
'.join(words)
11 11
return
Test Case
print(construct())
CODE (PYTHON)
Function to construct
def construct():
# Open file
fin = open('input.txt', 'r').readlines ()
# Input s and create Dictionary
fin[1].strip()
S
=
D = {}
# Add words to dictionary
for i in range (2, len(fin)):
line fin.strip()
D[line] = 1
=
# Initialize parameters
i = 0
C =
words
=
[]
# Loop over characters of s
while(True):
if(i>=len(s)): break
# If current word is in D, store
C += s
if (c in D.keys()):
words.append(c)
C =
if(i==len(s)-1 and c!=""): return
i += 1
'.join(words)
11 11
return
Test Case
print(construct())