Can you write a pseudocode for this code? CODE (PYTHON) Function to construct def construct(): # Open file fin = open('i

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
correctanswer
Posts: 43759
Joined: Sat Aug 07, 2021 7:38 am

Can you write a pseudocode for this code? CODE (PYTHON) Function to construct def construct(): # Open file fin = open('i

Post by correctanswer »

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())
Register for solutions, replies, and use board search function. Answer Happy Forum is an archive of questions covering all technical subjects across the Internet.
Post Reply