Implement this algorithm: • Implement a function cross_out_multiples that takes as arguments a list of boolean values (true/false) called is_prime and a number n. The function sets the boolean values at all multiples of n (2*n, 3*n, 4*n ...) that are in the list to false. Implement a function sieve(n) which gives back a list of all primes below n.
Q: Write a function that takes three lists of integers, l1, l2, and l3, and returns a list of all…
A: Note: Below is the required program in python language. Program Approach: Define a function that…
Q: Write a Python function called append to all that takes two parameters (Ist and s) and returns a new…
A: Below I have provided Python Programming. Also, I have attached the screenshot of the code and…
Q: Write a function that is given a list of int id's as a parameter, the id of the person looked for,…
A: The Answer is
Q: Remember the set data type? vvell, you can look it up in Pythons documentation. In this task, you…
A: def permutation(l): if len(l) == 0: return [] if len(l) == 1: return [l]…
Q: The Binary Search algorithm works by testing a mid-point, then eliminating half of the list. In…
A: Here is the Answer
Q: Implement a recursive C++ function which takes an array of integers (arr) and the starting (start)…
A: The solution involves the use of functions, bubble sort,, arrays and loops.
Q: Using the given clamp function, write a function clamp_all that takes a list of integers along with…
A: # foo.py is just to show use you own foo.py which is alre3ady emplemented. foo.py def…
Q: Implement the following functions in the same application in C#: 1. Given a number (integer) N…
A: C# code for the given question - using System; class MainClass { // method to print fibonaci…
Q: Write a function split n l that splits the list l and returns a pair of lists containing the first n…
A: def split(l,n): li=l[:n] lii=l[n:] liii=(li,lii) return…
Q: Solve in java You are given an input list of strings, ordered by ascending length. Write a function…
A: Strings in Java are essentially objects that represent lists of char values. A character array…
Q: Write a tail-recursive CLISP function to compute the length of an arbitrary list.
A: Note : As per guidelines answering 1st question when multiple questions are posted. Please repost…
Q: Write a python function named replaceVal(list, valToBeReplaced, newValue) which takes the above…
A: Have to program a function replaceVal which can replace the values form a list which is mentioned in…
Q: Write a Python function which should take two arguments (string and a list) and return yes/no based…
A: given: return YES if the type of all elements of list matches the given type of first argument (str…
Q: Please answer it in Python Write a function insere_milieu that takes as an argument a list l and an…
A: The asked python program is coded in the next step and is explained within comments in the program.…
Q: You will be given a positive integer n>0 and you will construct a pattern that is made up of n rows:…
A: Bell’s Numbers and the Bell Triangle are a sequence of numbers which count the possible partitions…
Q: Write a function in a racket code that takes as input a list of elements and returns a list with…
A: Recursion is when a function calls itself in its definition.
Q: Solve in java You are given an input list of strings, ordered by ascending length. Write a function…
A: In this problem, we need to design the Java program that will be able to solve the mentioned…
Q: Write a function that is given a list of int id’s as a parameter, the id of the person looked for,…
A: Code: #include<iostream>using namespace std;//function to check the person available or notint…
Q: Write a function differBy which takes two arguments, a number N and a list of numbers L, and returns…
A: ; (write-line "Hello World") (defun differBy (N list-data) (setq ans nil) ; initialize list to…
Q: The sieve of Eratosthenes is a way of computing all the prime numbers below a certain number. (A…
A: I give the code in python for both functions, output screenshot, code screenshot.
Q: Solve in java You are given an input list of strings, ordered by ascending length. Write a function…
A: Coded using Java language.
Q: In Python Please Implement a function all_same(lst: list) -> bool that determines whether all the…
A: Code1: (using manual method) Code2: (using all() function)
Q: Write a Python function peaksIndex() that takes a list as parameter, returns a list that contains…
A: def peaksIndex(arr): peaks=[] #for storing indexes of peak values for i in…
Q: Write a program to reverse the words of a string. Implement a function reverse () that reverses the…
A: Following is the C program that implements a function reverse which reverses the selected part of…
Q: Write a function(in pyhton) that takes a list of distinct integers l, and an integer k. Your…
A: The program is implemented in Python with structured program. In main the program has a list of…
Q: Solve in java You are given an input list of strings, ordered by ascending length. Write a function…
A: Algorithm - Take one string as input. Now use the below logic for(int i=0;i<r.length;i++){…
Q: if (ax)2+(ay)2 < (bx)2+(by)2, then a should come before b in the sorted array. 2) if (ax)2+(ay)2 =…
A: Lets see the solution.
Q: Below is a Python function definition for a linear search of a list Ist for element. It returns the…
A: Answer:
Q: Write a function that gets an array of ints of length n, and a number k, and returns the longest…
A: #include <stdio.h>//method to find and return the longest subsequence of consecutive k's in…
Q: Implement the sieve of Eratosthenes: a function for computing prime numbers, known to the ancient…
A: the code is an given below : #importing copy to create shallow copy # and math to use sqrt() import…
Q: The sieve of Eratosthenes is a way of computing all the prime numbers below a certain number. (A…
A: Here I written python code as per problem says with two function program. I hope you like it.
Q: Below, enter code to complete implementation of a recursive function Sum alLintegers(), which takes…
A: Here in the main method I have first of all asked the user to enter the number. Then I have called…
Q: solve in C please. Implement the following two functions that get a string, and compute an array of…
A: #include "headers.h" #include "processmanager.h" #include "history.h" int count_tokens(char *,…
Q: Write an iterative and recursive function that takes an array of strings as its argument and returns…
A: Please find the answer below :
Q: Write a function that filters a given list of band names and duplicates the "the", "a", "an" if the…
A: Algorithm - Take array of string in a method as argument. Now loop over the bands legth. use the…
Q: Solve in java You are given an input list of strings, ordered by ascending length. Write a function…
A: In this problem, we need to design the Java program that will be able to solve the mentioned…
Q: Use Python for this question: Implement a function findMixedCase that accepts a single…
A: Given: Implement a function findMixedCase that accepts a single argument, a list of words, and…
Q: Please help with the bolded functions: I need to implement the following two functions that get a…
A: Given data, Need to implement the following two functions that get a string and compute an array of…
Q: Write a function nesting(), which takes an arbitrary number of parameters, and returns a list…
A: Write a function nesting(), which takes an arbitrary number of parameters, and returns a list…
Q: implement QuickSort of ints that sorts the numbers in the non-decreasing order. Implement the…
A: As you have not specified the language in which you want the code. so i will provide the code in c++…
Q: Write a program in python with a function isPal(L), where L is a list of integers, and the function…
A: Task :- Write a python program to check if given list is pallindrome or not. Python program :-…
Q: Implement a function countMultiples in Python that: accepts a single argument, a 2-dimensional list…
A: 1)Declare count=0 2)Iterate through each list in list of list using for loop 3)next iterate…
Q: Write a Python function peaksIndex() that takes a list as parameter, returns a list that contains…
A: def peaksIndex(listA): # function to return the list of indexes with peak values N =…
Q: The Binary Search algorithm works by testing a mid-point, then eliminating half of the list. In…
A: For your readability, extra \n is added at the end of each iteration and you can remove them if you…
Q: Implement a recursive C++ function which takes an array of integers (arr) and the starting (start)…
A: Here we need to find the second smallest element’s index in the given range using recursive…
Q: Write a function that takes a list of lists and then returns the value of all the symbols in it,…
A: Algorithm - Create a map with respective values of the symbols Define a method that returns the…
Q: How to write a function in python where it takes a list of string s. Where s=…
A: The program has the following algorithm:Intitialize the counter counting string list position number…
Q: Implement a function pairsThatSum that accepts two arguments: 1. a target number 2. a list of…
A: #function pairsThatSum that accepts two arguments: 1. a target number 2. a list of numbersdef…
Q: Implement a function findMixedCase in Python that: accepts a single argument, a list of words, and…
A: code : import re def findMixedCase(nstr): for word in nstr: resup,reslow=False,False…
Q: Write a program that reads a list of integers, and outputs whether the list contains all even…
A: In Python, a function is a gathering of related statements that plays out a particular errand. It…
Step by step
Solved in 3 steps with 4 images
- Write a function that is given a list of int id's as a parameter, the id of the person looked for, and the length of the array. Use the data: Bob 123456 89 Suki 234567 77 Felix 345678 55 Julie 456789 67 The function searches the id array and returns the index of the id or -1 if the id does not exist. The main program outputs the name of the person at that index or a message that the person was not found. The name array (up to length number of students) and id array are declared in function main. Show all the declarations and the actual call. A sample run may look like the following: int SearchPerson(const int id[], int length,int who); Enter the id of the person 345678 That person is: Felix with a mark of 55 Enter the id of the person 444444 That person does not exist.Write a recursive function that finds the minimum value in an ArrayList. Your function signature should be public static int findMinimum(ArrayList<Integer>) One way to think of finding a minimum recursively is to think “the minimum number is either the last element in the ArrayList, or the minimum value in the rest of the ArrayList”. For example, if you have the ArrayList [1, 3, 2, 567, 23, 45, 9], the minimum value in this ArrayList is either 9 or the minimum value in [1, 3, 2, 567, 23, 45] Hint:The trick is to remove the last element each time to make the ArrayList a little shorter. import java.util.*; public class RecursiveMin{public static void main(String[] args){Scanner input = new Scanner(System.in);ArrayList<Integer> numbers = new ArrayList<Integer>();while (true){System.out.println("Please enter numbers. Enter -1 to quit: ");int number = input.nextInt();if (number == -1){break;}else {numbers.add(number);}} int minimum =…Implement a function rollsToRepeat in Python that simulates a dice game in which a pair of dice are rolled repeatedly until some total on the dice occurs the specified number of times. Details: accepts one integer argument, n , the number of repeats required before the game ends rolls a pair of dice repeatedly until some dice total has repeated n times returns the total number of times the pair of dice was rolled For example, using a random seed of 85 , the sequence of rolled pairs will be : (2, 6), (5, 1),(3, 2), (2, 4), (3, 5), (2, 6), (4, 5), (5, 2), (6, 5), (5, 5), ... If you runrollsToRepeat with n=1 , only 1 repeat is required. On the first roll, the total 8=2+6 is repeated once (as wouldany first roll). So the simulation stops and the function returns 1. This always happens whenn=1 . n=2 , some total must repeat twice. This first occurs on the 4throll, when the total of 6occurs for the 2ndtime. n=3 , some total must repeat three times. This first occurs on the 6throll, when…
- The sieve of Eratosthenes is a way of computing all the prime numbers below a certain number. (A prime number is a number that is only divisible by itself and 1). Implement this algorithm: Implement a function cross_out_multiples that takes as arguments a list of boolean values (true/false) called is_prime and a number n. The function sets the boolean values at all multiples of n (2*n, 3*n, 4*n ...) that are in the list to false. Implement a function sieve(n) which gives back a list of all primes below n. Put your code in sieve.py This program is tested via unit tests.Write a recursive function that finds the minimum value in an ArrayList. Your function signature should be public static int findMinimum(ArrayList<Integer>) One way to think of finding a minimum recursively is to think “the minimum number is either the last element in the ArrayList, or the minimum value in the rest of the ArrayList”. For example, if you have the ArrayList [1, 3, 2, 567, 23, 45, 9], the minimum value in this ArrayList is either 9 or the minimum value in [1, 3, 2, 567, 23, 45] ================================================ import java.util.*; public class RecursiveMin{public static void main(String[] args){Scanner input = new Scanner(System.in);ArrayList<Integer> numbers = new ArrayList<Integer>();while (true){System.out.println("Please enter numbers. Enter -1 to quit: ");int number = input.nextInt();if (number == -1){break;}else {numbers.add(number);}} int minimum = findMinimum(numbers);System.out.println("Minimum: " + minimum);}public static int…Write a function that is given a list of int id’s as a parameter, the id of the person looked for, and the length of the array. Use the data: Bob 123456 89 Suki 234567 77 Felix 345678 55 Julie 456789 67 The function searches the id array and returns the index of the id or –1 if the id does not exist. The main program outputs the name of the person at that index or a message that the person was not found. The name array (up to length number of students) and id array are declared in function main. Show all the declarations and the actual call. A sample run may look like the following: int SearchPerson(const int id[], int length,int who); Enter the id of the person 345678 That person is: Felix with a mark of 55 Enter the id of the person 444444 That person does not exist. in C++ please use basic coding I'm not…
- Using JavaScriptDefine a function getMonth which accepts number from 1 to 12 as an argument and return the descriptive name of the month. For example: getMonth(1) should return January while getMonth(12) returns December, finally getMonth(-1) returns null. Use array or object to define a list of names for the month and refrain from using if statement to check the argument if it's 1, 2, etc.Write a function MedianWithoutHL(ScoreList) that takes an unsorted list of n numbers as a parameter, discards the highest and the lowest numbers and return the median. You can assume the number of items in the list is between 0.0 and 9.9. To find the median from a list of items, you have tosort the list and find out the value of the item in the middle.Note: If the list has an odd number of items, the median is the value of the middle item. If the list has an even number of items, the median is the average of the two middle items.Sample Run #1:scoreList1 = [9.0, 9.0, 7.5, 8.0, 9.5, 6.5, 5.0, 7.0, 7.5, 8.5]print("The Original ScoreList: ", scoreList1)print(MedianWithoutHL(scoreList1))Output of Sample Run #1:The Original ScoreList: [9.0, 9.0, 7.5, 8.0, 9.5, 6.5, 5.0, 7.0, 7.5, 8.5]The List after sorting: [5.0, 6.5, 7.0, 7.5, 7.5, 8.0, 8.5, 9.0, 9.0, 9.5]Without the High & Low: [6.5, 7.0, 7.5, 7.5, 8.0, 8.5, 9.0, 9.0]7.75Assume that L is a list of Boolean values, True and False. Write a program in python with a function longestFalse(L) which returns a tuple (start, end) representing the start and end indices of the longest run of False values in L. If there is a tie, then return the first such run. For example, if L is False False True False False False False True True False False 0 1 2 3 4 5 6 7 8 9 10 then the function would return (3, 6), since the longest run of False is from 3 to 6.
- Write a recursive function called that takes a string of single names separated by spaces and prints out all possible combinations (permutations), each combination on a new line. When the input is: Alice Bob Charlie then the output is: Alice Bob Charlie Alice Charlie Bob Bob Alice Charlie Bob Charlie Alice Charlie Alice Bob Charlie Bob Alice Here is my original code that needs to be fixed: def all_permutations(permList, nameList): # TODO: Implement method to create and output all permutations of the list of names. if nameList == len(permList) - 1: return nameList else: for x in range(permList, len(nameList)): permList[nameList], permList[x] = permList[x], permList[name_List] return all_permutations(permList, nameList + 1) permList[nameList], permList[x] = permList[x], permList[name_List] if __name__ == "main": nameList = input().split(' ') permList = [] all_permutations(permList, nameList)Create a recursive function in a file called ab_equality.py: def ab_equal(n, k, current): Print out all of the strings of a's and b's of length n so that the number of a's and b's are equal. For n = 2, there's ab and ba. For n = 3 there are no strings since they'd have to have 2 a's and 1 b, or 2 b's a 1 a so not equal. For n = 4, there will be 6 of these strings, and for n = 5, zero again. Hint: use k to track the difference between a's and b's. So for instance if your current is aaabb then k should be equal to either 1 or -1 (your choice depending). When you call the function, you should call it from your main or testing function with the length in the n parameter, 0 should be put into the k parameter, and then an empty string will be passed in for current.Implement a function pairsThatSum that accepts two arguments: 1. a target number2. a list of numbers the function then returns a list of tuple s that contains all pairs of numbers from the list that sum to the given target number. Note: the pair can be two numbers with the same value, e.g. (2,2) but these must be different items (have different locations) in the list. See the last example below. each pair should be reported only once (don't include a pair and its reverse), and each pair's values should be listed in the order that they occur in the list. E.g., the first example records the pair (0,3) instead of the pair (3,0) , because 0 occurs in the list before 4 . the list of pairs should be ordered by the order of the first value in the list, e.g., (0,3) comes before (1,2) because 0 comes before 1 in the list. (note: if you take the right approach, you won't have to do anything extra for this requirement) Below is an example of the output from the code: >>>…