Substring: Complete the following code to check if str2 with length strlen2 is a substrir str1 with length strlen1. Examples: str1=flower, str2=low (low is a substring of flower) str1=flower, str2=law (law is not a substring of flower) Algorithm: 1. Find the first character of str2 in str1. 2. If not found, str2 is not a substring of str1, else compare the remaining characters. 3. If all remaining characters matched, str2 is a substring of str1. Else, str2 is not a substring of strl. cld mov rcx, qword [strlen1]

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 10PE
icon
Related questions
Question
100%
9-13. Substring: Complete the following code to check if str2 with length strlen2 is a substring of
str1 with length strlen1.
Examples:
str1=flower, str2=low (low is a substring of flower)
str1=flower, str2=law (law is not a substring of flower)
Algorithm:
1. Find the first character of str2 in str1.
2. If not found, str2 is not a substring of str1, else compare the remaining characters.
3. If all remaining characters matched, str2 is a substring of str1. Else, str2 is not a
substring of strl.
cld
mov rcx, qword [strlenl]
9.
10.
11.
cmp rcx, 0
je not Substring
mov rcx, qword [strlen2]
dec rcx
12.
inc rsi
13.
cmp rcx, 0
je substring
jmp notSubstring
Transcribed Image Text:9-13. Substring: Complete the following code to check if str2 with length strlen2 is a substring of str1 with length strlen1. Examples: str1=flower, str2=low (low is a substring of flower) str1=flower, str2=law (law is not a substring of flower) Algorithm: 1. Find the first character of str2 in str1. 2. If not found, str2 is not a substring of str1, else compare the remaining characters. 3. If all remaining characters matched, str2 is a substring of str1. Else, str2 is not a substring of strl. cld mov rcx, qword [strlenl] 9. 10. 11. cmp rcx, 0 je not Substring mov rcx, qword [strlen2] dec rcx 12. inc rsi 13. cmp rcx, 0 je substring jmp notSubstring
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning