def shared_motif(dna_list): This function takes in a list of DNA strings and returns the longest common substring. A substring is a contiguous sequence of characters within a string. A common substring is a substring of every element in the given list of DNA strings. Note that the number of DNA strings in the input list is not always the same! There may be multiple solutions, but you only need to return the first one. Example: • Sample input DNA list: ["GATTACA", "TAGACCA", "ATACA"] • The returned longest common substring: "TA"
Q: C++ Programming Language ::::::: Redo the same functions this time as nonmember functions please :…
A: The Program is given below:
Q: Extract the city name and state from strings like “Utica, NY” and “Los Angeles, CA”. Assume the…
A: Code: As no coding language is mentioned providing the code in JAVA: import…
Q: Nearest smaller element def nearest_smaller(items): Given a list of integer items, create and…
A: Actually, program is an executable software that runs on computer.
Q: Excercise # 1 Write a program that generates a sequence of 20 random values between 0 and 99 in a…
A: As there are multiple questions in this post, as per our policy, I'll answer the first question.…
Q: ef normal (L): '' '(list of int) -> list Precondition: len (L)> = 1 This function…
A: We need to define the function normal() as per the given descriptio .
Q: def analyze_word (word: str, pos_words: List [str], neg_words: List(str]) -> int: Given a word, a…
A: def analyze_word(word, pos_words, neg_words): ''' (str, list, list) -> int Given a…
Q: #include #include using namespace std; /* The structure to be used for representing a…
A: A doubly Linked list is a type of Linked List Data structure that behaves like a two-way list/chain.…
Q: 5 partition_list (head) This is a little like split_list() from the Short problem, except that,…
A: Given Solution: class ListNode:""" Models a single node in a singly-linked list. Has no methods,…
Q: Question-1: Write a python code that takes a string as an user input and finds out all the duplicate…
A: I will provide you a commented python code. So just read the code once and you will easily…
Q: email address, birthday, etc. Write a program that first takes as input an integer N that represents…
A: Code: import java.util.Scanner; class Main{ public static String getPhoneNumber(String[]…
Q: String makeString(String start, String sep, String end) Returns a string representation of this…
A: import java.util.*;import java.lang.*;import java.io.*; class StringList{ ArrayList<String>…
Q: what does the following code do? public int function(T e) Node temp = head; int var = 0; while (temp…
A: answer is d. Find and return the position of the given element in the list if element found it…
Q: Java Linked List Print Program I have a program with multiple linked list that has data stored from…
A: Hey there, I am writing the required solution of the above stated question.Please do find the…
Q: Question To be implemented in d5q1.py: mergeList function: You run a store. You have two lists. The…
A: PROGRAM INTRODUCTION: Initialize the two lists in which the required elements are to be taken as…
Q: Given two lists(List1, List2) of INTs create a third list such that should contain only odd numbers…
A: I'm providing the answer to the above query. I hope this will be helpful for you...
Q: #include #include #define MAX_CHAR 256 using namespace std; // A Suffix Trie (A Trie of all…
A: #include <stdio.h> #include <stdlib.h> #include <string.h> #include…
Q: Comma Code Say you have a list value like this: spam = ['apples', 'bananas", 'tofu', 'cats'] Write a…
A: NOTE: Since the question doesn't mention the programming language use to code so I am using Python…
Q: def make_grid (w: int, h: int, player_coord: Tuple lint, int], gold_coord: Tuple[int, int]) -> List…
A: The program is written python l=[]L=[]def make_grid(w,h,player_coord,gold_coord): for i in…
Q: Complete the string_lengths(my_list) function below. It takes a list of strings, and it should…
A: def string_lengths(my_list): START DECLARE d = {} FOR x in my_list do SET d[x] = len(x) RETURN d…
Q: Nearest smaller element def nearest_smaller(items): Given a list of integer items, create and return…
A:
Q: def make_grid(w: int, h: int, player_coord: Tuple[int, int], gold_coord: Tuple[int, int]) ->…
A: def make_grid(w, h, player_coord, gold_coord): ''' (int, int, tuple of two ints, tuple of two…
Q: Topic: Singly Linked List Implement the following functions in C++ program. Read the question…
A: C++ program to implement three function removeAt, removeAll, contains are given below.
Q: list_n_perfect_squares This function takes a positive integer, n, and returns a list containing n…
A: The above question is solved in step 2 :-
Q: Dictionary Walk Program Using Java, write a program which takes two words as inputs and walks…
A: Since you have posted a question with multiple sub-parts, according to the company's policy we will…
Q: check_equivalency(tokens): Takes a list as input. Returns True if the list contains three elements,…
A: We have to write a Python program to Takes a list as input. Returns True if the list contains three…
Q: Python Programming: 2-Dimensional list The Lo Shu Magic Square is a grid with 3 rows and 3 columns…
A: COLUMNS = 3def magic(): with open("phase1.txt") as textFile: lines = [] line2 = []…
Q: alphabet defghijklmnopqrstuvwxyz get_list = ['Now', 'is', 'the', 'TIME'] finalList = def…
A: issue in the above code is in the last nested for loop, instead of same variable i there should be…
Q: Use the function def remove(self, index) to write a python code given the following conditions:…
A: Given: Use the function def remove(self, index) to write a python code given the following…
Q: opic: Singly Linked List Implement the following functions in C++ program. Read the question…
A: I have implemented the given requirements in C++ as per the specification. The code is as follows:…
Q: 1. def make_grid(w: int, h: int, player_coord: Tuple[int, int], gold_coord: Tuple[int, int]) ->…
A: 1. Answer Here is the completed code for this problem. Comments are included, go through it, learn…
Q: Implement the following function using C++ remove_redundant() This method will clear out the…
A: Solution:-- 1)As the given question has required for the solution which is to be provided in the…
Q: Write a function called myFunction: The function has 2 parameters: 1. a non-nested list of strings…
A: Step 1 : Start Step 2 : Define the function myFunction which accepts two parameters a list - myList…
Q: Write the following function that merges two sorted lists into a new sorted list:def merge(list1,…
A: def merge(list1,list2): len1=len(list1) len2=len(list2) len3=len1+len2…
Q: 7. A code segment is intended to transform the list utensils so that the last element of the list is…
A: The given question asks for to remove last element of the list and inset the removed element at 1st…
Q: A singly linked circular list is a linked list where the last node in the list points to the first…
A: 1. There are two classes in the program Item and Cart 2. Item class contains the Item attributes…
Q: Extract increasing integers from digit string def extract_increasing(digits): Given a string of…
A: def extract_increasing(digits): #required method result = []…
Q: Task 2- Adjacent element swap for a list (Topics: list, loops, functions, string manipulation,…
A: Solution: Given,
Q: def find_positive_value_coordinates(lst: list[list[int]]) -> list[list[int]]: "" Takes in a nested…
A: Blank 1: for i in range(len(lst)): Blank2: for j in range(len(lst[i])):
Q: nt num, int pos) This method will add the integer num to the posth position of the list and returns…
A: Q. Topic: Singly Linked ListImplement the following functions in C++ program. Read the question…
Q: def get_words(training_text: TextIO) -> List[str]: """Return a new list containing the words from…
A: Code:- from typing import TextIO, List def get_words(training_text: TextIO)->List[str]: result =…
Q: You need to edit the same code so as to make it a circular doubly linked list. Implement the…
A: Modified code: #include <iostream>using namespace std;class Node{ public: int data;…
Q: PigLatinStrings converts a string into Pig Latin, but it processes only one word. If a word ends…
A: Program code: #include<iostream>using namespace std;class Node{ public: char value; Node…
Q: 5 partition_list (head) This is a little like split_list() from the Short problem, except that,…
A: python Python is the well general-purpose programming language that can be applied to a variety…
Q: Need help only part 2. Thank you! In this assignment, you will create a Linked List data structure…
A: Coded using Java.
Q: ure that takes a tree (represented as a list) and returns a list whose elements are all the leaves…
A: Scheme code (define (leaves items)(cond ((null? items) items)((not (pair? items)) (list items))(else…
Q: Python Code Create a code that can plot a distance versus time graph by importing matplotlib and…
A: import matplotlib.pyplot as plt # import matplotlib# initialize time and distanceTime = []Distance =…
Q: Define a two dimensional list with NxN elements. This list should be filled with random numbers…
A: • Define a two dimensional list with NxN elements. This list should be filled with random numbers…
Python
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
- C++ ONLY Add the following functions to the linked list. int getSize() -> This function will return the number of elements in the linked-list. This function should work in O(1). For this keep track of a size variable and update it when we insert a new value in the linked-list. int getValue(index) -> This function will return the value present in the input index. If the index is greater or equal to the size of the linked-list return -1. void printReverse() -> This function will print the linked list in reverse order. You don’t need to reverse the linked list. Just need to print it in reverse order. You need to do this recursively. You cannot just take the elements in an array or vector and then print them in reverse order. void swapFirst() -> This function will swap the first two nodes in the linked list. If the linked-list contains less than 2 elements then just do nothing and return. To check your code add the following code in your main function. LinkedList l;…JAVA CODE PLEASE Linked List Practice ll by CodeChum Admin Write a function printNodes that takes in the head of a linked list and prints all the values of that linked list using a while loop. Print the values separated by a [space]->[space] In the main function, write a program that asks the user to input five integers and assign these values to the nodes. Arrange the nodes in ascending order first before printing them using the printNodes function. Input 1. One line containing an integer 2. One line containing an integer 3. One line containing an integer 4. One line containing an integer 5. One line containing an integer Output Enter·number·1:·1 Enter·number·2:·2 Enter·number·3:·3 Enter·number·4:·4 Enter·number·5:·5 1·->·2·->·3·->·4·->·51-Let the list have a head and a tail. That is, a pointer (have a marker) to both the beginning (first Node) of the list and the last Node. What process does Tail facilitate? 2-insert(int index, int element): adds this element to the index position. For example, if index is 4, it adds this element between index 3 and 4 in the list. The size of the list has increased by one. 3-append(int elem): Adds the element to the end of the list. The size of the list has increased by one. 4-get(int index): Returns the element at the index position of the list, no change in the list. 5-remove(int index): Returns the element at the index position of the list. This element is removed from the list and the list size is reduced by one. 6-findMin(): returns the index of the smallest number in the list. 7-findMax(): returns the index of the largest number in the list. 8-search(int elem): searches elem in the list. It returns -1 when you can't find elem's index when you find it. 9-ToArray(): Return an…
- 1-Let the list have a head and a tail. That is, a pointer (have a marker) to both the beginning (first Node) of the list and the last Node. What process does Tail facilitate? 2-insert(int index, int element): adds this element to the index position. For example, if index is 4, it adds this element between index 3 and 4 in the list. The size of the list has increased by one. 3-append(int elem): Adds the element to the end of the list. The size of the list has increased by one. 4-get(int index): Returns the element at the index position of the list, no change in the list. 5-remove(int index): Returns the element at the index position of the list. This element is removed from the list and the list size is reduced by one. 6-findMin(): returns the index of the smallest number in the list. 7-findMax(): returns the index of the largest number in the list. 8-search(int elem): searches elem in the list. It returns -1 when you can't find elem's index when you find it. 9-ToArray(): Return an…1-Let the list have a head and a tail. That is, a pointer (have a marker) to both the beginning (first Node) of the list and the last Node. What process does Tail facilitate? 2-insert(int index, int element): adds this element to the index position. For example, if index is 4, it adds this element between index 3 and 4 in the list. The size of the list has increased by one. 3-append(int elem): Adds the element to the end of the list. The size of the list has increased by one. 4-get(int index): Returns the element at the index position of the list, no change in the list. 5-remove(int index): Returns the element at the index position of the list. This element is removed from the list and the list size is reduced by one. 6-findMin(): returns the index of the smallest number in the list. 7-findMax(): returns the index of the largest number in the list. 8-search(int elem): searches elem in the list. It returns -1 when you can't find elem's index when you find it. 9-ToArray(): Return an…Write the following function that sorts and merges two lists into a new sorted list. The new list contains only even numbers. def myMergeEvenList(list1, list2): Enter list1: 10,5,6,7 Enter list2: 12,8,5,0,1 The merged list is: 0,6,8,10,12
- Create two linked lists and then make a concatList(NODE **list1, NODE **list2) function that concatenates the two lists. The concatenated list must be a linked list. Fill in the "Write code here" sections appropriately.JAVA CODE PLEASE Linked List Practice l by CodeChum Admin Write a function printNodes that takes in the head of a linked list and prints all the values of that linked list using a while loop. Print the values separated by a [space]->[space] In the main function, write a program that asks the user to input five integers and assign these values to the nodes then print the five nodes using the printNodes function. An initial code is provided for you. Just fill in the blanks. Input 1. One line containing an integer 2. One line containing an integer 3. One line containing an integer 4. One line containing an integer 5. One line containing an integer Output Enter·number·1:·1 Enter·number·2:·2 Enter·number·3:·3 Enter·number·4:·4 Enter·number·5:·5 1·->·2·->·3·->·4·->·5JAVA CODE PLEASE 2. Linked List Quiz by CodeChum Admin Write a function printNodes that takes in the head of a linked list and prints all the values of that linked list using a while loop. Print the values separated by a [space]->[space] Create a program that accepts 10 integer inputs. Assign each input into a node and link them in ascending order then print the linked list. Create another two linked lists: One for nodes with even numbers and the other one for odd numbers. Print them respectively using the printNodes function. Input 1. One line containing an integer 2. One line containing an integer 3. One line containing an integer 4. One line containing an integer 5. One line containing an integer 6. One line containing an integer 7. One line containing an integer 8. One line containing an integer 9. One line containing an integer 10. One line containing an integer Output Enter·number·1:·1 Enter·number·2:·2 Enter·number·3:·3 Enter·number·4:·4…
- PigLatinStrings converts a string into Pig Latin, but it processes only one word. If a word ends with a punctuation mark in the Pig Latin form, put the punctuation at the end of the string. For example: “Hello!” becomes “ello-Hay!” Source: Mbela, K. (2020) Write a program that prompts the user to input a string and then outputs the string in Pig Latin. Create the program using a Linked List. The linked list should have function that prints the linked list. This function should be a recursive function.Don't copy from other websties a) Write a function to get the value of the Nthnode in a Linked List. [Note: The first (N=1) item in the list means the item at index 0.] It takes two parameters: the list or its head, and N. Return False if the list has fewer than N elements. The Linked List structure supports the following function. def getHead(self): return self.head # it points to a Node structure The Node structure supports the following functions. def getData(self): return self.data # it returns the value stored in the Node def getNext(self): return self.next # it points to the next Node b) Write a function that counts the number of times a given integer occurs in a Linked List. Assume similar structures as defined in 1._!?8. Problem Title: "Add Two Numb You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself..