Related questions
There is something wrong with the code one part of the code "aab" should be false
Question picture is attached
Python code
# helper method
def in_substring_p(s, j, k):
count = 0
# iterate though string, with pointer j, k
while j >= 0 and k < len(s):
if s[j] != s[k]:
# character not match
break
count += 1
# increment pointer try for next character
j -= 1
k += 1
return count
# taking parameter s
def is_semidrome(s):
count = 0
for i in range(0, len(s)):
count += in_substring_p(s, i - 1, i + 1)
count += in_substring_p(s, i, i + 1)
# check if palindrome exist in substring
if count == 0:
return False
else:
return True
print(is_semidrome("popeye"))
print(is_semidrome("aab"))
print(is_semidrome("wow**mom!!!"))
print(is_semidrome("xyzjoyed"))
Step by stepSolved in 3 steps with 1 images
- Pointers and references are fully equivalent True Falsearrow_forwardFix the errors and send the code please // Application allows user to enter a series of words // and displays them in reverse order import java.util.*; public class DebugEight4 { public static void main(String[] args) { Scanner input = new Scanner(System.in); int x = 0, y; String array[] = new String[100]; String entry; final String STOP = XXX; StringBuffer message = new StringBuffer("The words in reverse order are\n"); System.out.println("Enter any word\n" + "Enter + STOP + when you want to stop"); entry = input.next(); while(!(entry.equals(STOP))) { array[x] = entry; ++x; System.out.println("Enter another word\n" + "Enter " + STOP + " when you want to stop"); entry = input.next(); } for(y = x - 1; y > 0; ++y) { message.append(array[y]); message.append("\n"); } System.out.println(message) }arrow_forwardpython def factorial(n):pass # replace this line with your lines of recursive codedef sum_recursively(n):pass # replace this line with your lines of recursive codedef sumlist_recursively(l):pass # replace this line with your lines of recursive codedef reverse_recursively(l):pass # replace this line with your lines of recursive code#EXTRA CREDITdef multiply_recursively(n, m):pass # replace this line with your lines of recursive codearrow_forward
- What should a programmer be especially aware of when programming with arrays? Syntax errors If-then-else statements Modularization Using an Out of Bounds array subscriptarrow_forwardJavaarrow_forwarddef ppv(tp, fp): # TODO 1 return def TEST_ppv(): ppv_score = ppv(tp=100, fp=3) todo_check([ (np.isclose(ppv_score,0.9708, rtol=.01),"ppv_score is incorrect") ]) TEST_ppv() garbage_collect(['TEST_ppv'])arrow_forward
- Submerging is the phenomenon wherein the pointer vanishes when you move it too quickly.arrow_forwardWhen you move the pointer too quickly, a phenomena known as submarineing happens when the cursor vanishes.arrow_forwardin python create function that has a parameter of dict[str, str] key should be a name value should be a word when given a dict of names and word, function should return the word that is most common ******************************* no using key, value for loops no .get, .items, .defaultset no importing builtins no using .values, .keys, or .index must do it through dictionary cycling ************************** should return a stringarrow_forward
- Text book imageComputer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONText book imageComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceText book imageNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Text book imageConcepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningText book imagePrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationText book imageSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY