Question
Please write in python Code fragment 6.5 is given below def is_matched_html(raw): Return True if all HTML tags are properly match; False otherwise. S =
Please write in python
Code fragment 6.5 is given below
def is_matched_html(raw):
"""Return True if all HTML tags are properly match; False otherwise."""
S = ArrayStack()
j = raw.find('
while j != -1:
k = raw.find('>', j+1) # find next '>' character
if k == -1:
return false # invalid tag
tag = raw[j+1:k] # strip away
if not tag.startswith('/'): # this is opening tag
S.push(tag)
else: # this is closing tag
if S.is_empty():
return false # nothing to match with
if tag [1:] != S.pop():
return false # mismatched delimiter
j = raw.find('
return S.is_empty() # were all opening tags matched?
3. (30 points) In Code Fragment 6.5 (in the textbook, also copied below), we assume that opening tags in HTML have formStep 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