python wirte a function max_indexes(xs) that inserts a list xs with numbers and returns a list of indexpositions where the list has local maximum values. A local maximum value is a number in the list that has a smaller number before and after. for example in this list has a local maximum at position 2 and 7: [3, 4, 5, 2, 1, 0, 4, 6, 4, 2, 1] Here the function should return [2, 7]
Q: Write a function high_low_dict(numbers, sep) that takes a list of numbers and an int sep that will…
A: Note: The problem solved in JAVA. ALGORITHM: -> take a ArrayList to add elements and an int type…
Q: Write a function countdown321 (nums) that returns True if the sequence 3, 2, 1 appears in the list…
A: Here I written Python program as per you problem.
Q: Write a function named `freq(l)` that takes a list `l` of numbers and returns a tuple of the most…
A: Here is the python3 code implementation of above problem. For input1:…
Q: Write a function named slice_it (numbers_list, index) that takes a list and an integer as…
A: - We have to code the slice function.
Q: Write a function called get_palindromes () that takes a list of words as input. The function should…
A: Please refer below commented code and output screenshot: def get_palindromes(list_word):…
Q: 8. Write a function indices(L) that takes a list and returns a dictionary containing lists of…
A: Task :- Write a python program that takes a list and returns a dictionary containing lists of…
Q: Write a function min2 to compute the second smallest of number of an integer list. You may assume…
A: ANSWER: Second and Smallest of Number: A Simple Solution is to sort the exhibit in expanding…
Q: Write a function flat_list() which takes a list that contains unknown number of lists. This function…
A: Since Python is weakly typed, you can encounter regular and irregular lists of lists. Every element…
Q: 2. Write a python program as function that displays a list Prog and returns a tuple of two list…
A: def fun(Prog): # user define function print("The list:", Prog) # display the…
Q: Write a function called check_third_element that takes in a list of tuples, lst_tups as a parameter.…
A: Please find thee answer below :
Q: You are given pointers to first and last nodes of a singly linked list, which of the following…
A: Linked list is a dynamic memory allocation technique to store values.
Q: Python Write a function revers_all (sequence) that takes an arbitrary nested list sequence with…
A: 1) Below is program that defines a function reverse_all which reverses nested list It defines…
Q: in picat) 10. split list(Lst,N): split Ist into two parts with the first part having N elements,…
A: Note: As per the guidelines for the multiple questions, we can answer only the first question,…
Q: The code of a sequential search function is shown on textbook page 60. In fact, if the list is…
A: """Program to seach target element in list""" #function to search target in listdef…
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: Write the nondestructive function insertRowCol(L, row, col, val) which takes a rectangular 2D list L…
A: Program Plan: Function insertRowCol has 4 parameters: arr - input arrayr - Row to insert the valuec…
Q: Write a Python Code for the given function and conditions: Given function: def insert(self,…
A: In the given function the self keyword is been used, which represents that the insert() method has…
Q: Write a function flat_list() which takes a list that contains unknown number of lists. This function…
A: new_li.append(ele): append ele in new_li in last position previous: new_li = [1, 2, 3] after…
Q: In python, create a function wherein you transfer elements from a list into different lists. If a…
A: 1. Define a function called 'splitList' which takes 2 parameters, a List and a Stop Element 2.…
Q: Write a function that takes two lists as input, a list L1 containing characters and a list L2…
A: Note: The programming language is not mentioned so python is used for the solution. Algorithm:…
Q: Instructions are given within the quotations for each function. 1)def remove_duplicate_sorted(t):…
A: t = [1, 3, 5, 6, 3, 5, 6, 1] print ("The original list is : " + str(t)) res = [] [res.append(x)…
Q: deleted element x. MANDATORY FOR CODE TO BE IN P
A: Write a function Delete(x,L) in Pascal that deletes last occurrence of x in a singly linked list and…
Q: Write a function REMOVE-NUM that takes a list and returns a list consisting of the original list…
A: In this question, we have to remove all numeric values present in the list. We just need to delete…
Q: Write a function min2 to compute the second smallest of number of an integer list. You may assume…
A: According to the Bartleby guidelines, we can answer only one question. These are different questions…
Q: type comparison = GEQ | LT Where GEQ represents "greater than or equal" and LT represents "less…
A: It is defined as the most important language in the Machine Learning concept. OCaml adds advanced…
Q: Define a function named duplicate_evens (numbers_list) which takes an integer list as a parameter.…
A: In this question we have to write a python program in which from a given list, implement the…
Q: 5. The following function indexCounter aims to find and return all the indices of the element x in a…
A: def indexCounter(L, x): indexList = [] startIndex = 0 while startIndex < len(L):…
Q: PYTHON!!! Write a function that accepts a required threshold amount (int), and variable number of…
A: def append_string(threshold,val):#here is my python code it will accepts two parametres one is…
Q: Write a function called 'filler (A, 1) that takes an integer A, and a list of integers '1 and if…
A: Hey there, I am writing the required solution of the above stated question.Please do find the…
Q: Write a function addToAll(Ist, x) which takes a list of integers and a number and modifies the list…
A: Iterate over the given list and update element by adding x value to it
Q: Write a program in Java to manipulate a Singly Linked List: Count the number of nodes Insert a new…
A: Java program to solve the given problem is below.
Q: write a Python function that takes in a list of integers (nums) and finds whether the list consists…
A: Write a python code which has a function that takes a list of numbers and returns false if it does…
Q: Write a function countdown321 (nums) that returns True if the sequence 3, 2, 1 appears in the list…
A: Given:
Q: cut(aList) Takes a list of integers and returns a list identical to aList, but when a negative…
A: def cut(aList): if len(aList) == 0: # base case if list is empty return aList if aList[0] <…
Q: This is for Python version 3.8.5 and please include pseudocode. nums = [8, 15, 6, 17, 33, 20, 14,…
A: An array can be declared in the python using arrayname = [values seperated by comma] There are built…
Q: Write a function cmid to count elements of an integer list between 5 and 10. One function only. cmid…
A: #function cmid()def cmid(li): #set count variable to 0 count=0 #for each number in list li…
Q: Write a function called get_palindromes() that takes a list of words as input. The function should…
A: Here is python code for implementation of the question. See below steps for desired output.
Q: Given a nonempty unsorted singly linked list with a list_pointer first pointing to the first node in…
A: typedef struct list_node *list_pointer;struct list_node{ int data; list_pointer link;}; void…
Q: USING PYTHON Chapter 5 -Programming Project: Implement a function that takes in two sorted lists and…
A: Programming Project: Implement a function that takes in two sorted lists and merges them into one…
Q: Write a function flat_list() which takes a list that contains unknown number of lists. This function…
A: In the following python code , we need to perform the following operations : Define the python…
Q: Write a function that sums all the elements of a list that are divisible by 9. What is the result of…
A: Here is the code to sum the numbers of a list divisible by 9 is given as below: The code is divided…
Q: a) Suppose we are trying to hide a secret message by embedding it in random extra letters. Write a…
A: Below is the code in python as language not specified and sample output:
Q: 1. Write a python program to reverse list of N integers. 2. The user will input numbers/elements…
A: The first line will take the number of elements user is going to enter. Then n consecutive lines to…
Q: Define a function max_run(lst: list) -> int to find the maximum run in a list. A run is a…
A: Use a list to store the consecutive occurrences and then finally return max of that list
Q: this code should be in python: write a function that receives a list as its only parameter. Inside…
A: Introduction: this code should be in python: write a function that receives a list as its only…
Q: Python code Python Write a function named `freq(l)` that takes a list `l` of numbers and returns…
A: Here is the python3 code: See below step for code and output.
Q: The following C function takes a single-linked list of integers as a parameter and rearranges the…
A: Given: struct node { int value; struct node *next; }; void rearrange(struct node *list) {…
Q: PYTHON CODE Write a function removeRange() that takes a list of integer numbers and two integer…
A: According to the Question below the Solution: Program Output:
Q: O Write a function that takes a list and 2 integers x and y as parameter an the following: • If the…
A: I have written python code below:
Q: Write a program that creates a list-returned function to display a lists contains all but Implement…
A: Please find the answer below :
python
wirte a function max_indexes(xs) that inserts a list xs with numbers and returns a list of indexpositions where the list has local maximum values. A local maximum value is a number in the list that has a smaller number before and after. for example in this list has a local maximum at position 2 and 7:
[3, 4, 5, 2, 1, 0, 4, 6, 4, 2, 1]
Here the function should return [2, 7]
Step by step
Solved in 3 steps with 3 images
- Code in python Given a list, L, the function front_two creates a new list of length 2 out of the first two items in L as follows: In the new list, the second item becomes the first item, and the first item becomes the second. If L contains only one item, the first item in the new list should be the value None. If L is empty, both items in the new list should be value None. The function returns the new list. For example: Test Result L = ['a', 'b', 'c', 'd'] print(front_two(L)) ['b', 'a'] L = [] print(front_two(L)) [None, None] L = [5, 2] print(front_two(L)) [2, 5] L = [7] print(front_two(L)) [None, 7]PYTHON CS1 PROBLEM Define a function that takes a list of lists, glol, as a parameter. You may assume that the inner lists in glol are lists of positive integers. Your function should return True if at least one of the inner lists in glol contains two or more multiples of 10. Otherwise it should return False. For example: If glol = [ ] then your function returns False. If glol = [[ ], [4, 2]] then your function returns False. If glol = [[10, 2, 6, 8], [12, 6], [15, 20, 5]] then your function returns False. If glol = [[10, 2, 6], [12, 6], [10, 2, 70, 15], [15, 10, 5]] then your function returns True as the inner list [10, 2, 70, 15] contains 10 and 70. If glol = [[10, 2, 6], [12, 6], [10, 7, 15], [50, 10, 50, 4, 6]] then your function returns True as the inner list [50, 10, 50, 4, 6] contains 50 twice. 6. If glol = [[10, 20, 6, 90], [12, 6], [ 7, 3, 15], [50, 10, 50, 4, 7]] then your function returns True as the inner lists [50, 10, 50, 4, 7] and [10, 20, 6, 90] contain more…The mapped list pattern Our second pattern is the mapped list pattern, described in video 4 3 mapped list pattern. Often we need to write a function that takes a list as a parameter and returns a new list in which each item in the original list is "mapped" to a new item in the result list. For example, the following function takes a list of numbers as a parameter and returns a list of all the numbers squared, e.g. squares ( [1, 3, 7]) returns [1, 9, 49]. def squares (nums): "Returns the squares of the given numbers""" result = [] for num in nums: result.append (num * num) return result Although this is just a special case of the accumulator pattern, it is so common that we give it its own name: the mapped list pattern. Consider the following function: def squares(nums): ""Returns the squares of the given numbers""" result = [] for num in nums: result.append (num * num) return result If the main program calls print(squares ( [5, -3, 2, 7]) what is the state table for the function…
- Write a function list2DigitOdd() that creates and returns a list that contain all positive 2-digit odd numbers. The function call list2DigitOdd() will return a list containing 11, 13, 15, ..., 99.two_sum is a Python function that takes in a list of integers (elements) and an integer number (num) and returns True if there exist two values in elements that add up to num, otherwise, function returns False. def two_sum(elements: List[int], num: int): for i in range(len(elements)): for j in range(i + 1): if elements[i] + elements[j] == num: return True return False Study above function and answer below questions: A. What is time complexity of two_sum? B. Is it possible to improve on above algorithm performance (in terms of its asymptotic cost)? If yes, describe your algorithm, be detailed as much as possible.a- Write a Python function Salary_levels, that takes a list as an argument and returns the number of the high salaries (salary>=5000), the average salaries(1000<=salary<5000, and the low salaries (salary<1000). You can use the following list : salaries= [500,1070,1450,6500,9000,940,450,400,600,2750,1100,8400,1500,900,1200] b- Use the above function to print the counts of the high, average, and low salaries. N.B: the codes of parts a and b should be included in your answer.
- Write a function primeFac in Python that computes the prime factorization of a number: it accepts a single argument, an integer greater than 1 it returns a list containing the prime factorizationeach number in the list is a prime number greater than 1the product of the numbers in the list is the original numberthe factors are listed in non-decreasing order Examples of possibles results: >>> primeFac(5)[5] >>> primeFac(72)[2, 2, 2, 3, 3] >>> primeFac(72)==[2, 2, 2, 3, 3]True >>> [ (i,primeFac(i)) for i in range(10,300,23)][(10, [2, 5]), (33, [3, 11]), (56, [2, 2, 2, 7]), (79, [79]), (102, [2, 3, 17]),(125, [5, 5, 5]), (148, [2, 2, 37]), (171, [3, 3, 19]), (194, [2, 97]), (217,[7, 31]), (240, [2, 2, 2, 2, 3, 5]), (263, [263]), (286, [2, 11, 13])] >>> [ (i,primeFac(i)) for i in range(3,300,31)][(3, [3]), (34, [2, 17]), (65, [5, 13]), (96, [2, 2, 2, 2, 2, 3]), (127, [127]),(158, [2, 79]), (189, [3, 3, 3, 7]), (220, [2, 2, 5, 11]), (251,…Please answer it in Python Write a function min_odd that takes a list as an argument and returns the smallest even integer contained in the list. If the list contains no even integers, the function will return None. For Example : min_odd([45, 62, 19, 22, 26, 18, 3, 5, 14])Expected answer is 14 min_odd([])Expected answer is None Write a function index_of that takes as an argument an integer (supposedly even) and a list, and returns the index to which this integer appears in the list. If the integer does not appear, the function will return None. It is assumed here for simplicity that the integer searched for does not appear several times in the list. Hint: if the for e in list loop doesn't suit you, remember that you can make a for + range or a while. .. For Example: index_of(34, [3, 67, 62, 34, 19, 24])Expected answer is 3 index_of(16, [2, 6, 104, 5, 25, 18, 50, 16])Expected answer is 7Write a function that accepts two lists as it's only arguments. The function should return a new list containing all the elements of the two list arguments. For example, if the function was passed the lists [1, 2, 3] and [4, 5, 6], it would return a new list containing [1, 2, 3, 4, 5, 6]
- Write a function named listReplace that takes 3 arguments: list1, tuple1, and tuple2. The function then searches for entries of tuple1 in list1 and replaces them with the corresponding entries in tuple2 and returns the new list. For example, listReplace( [1,2,3,2,4,1,5], (1,2), (7,8)) will return the following list, replacing all 1s in list1 with 7, and all 2s with 8: [7,8,3,8,4,7,5] Be carefull the following call listReplace( [1,1,1,8,0,0], (1,0), (e,2) ) should return [0,0,0,2,2,2] and not [2,2,2,2,2,2]. Also listReplace ([1,1,1], (0,2), (4,5)) returns the original list, because 0 and 2 do not exist in list1.İn C language A singly linear list stores integer values in each node and has multiple nodes. Write a function using given prototype below. This function cuts the first node of the list and adds it to the end as last node. It takes beginning address of the list as a parameter and returns the updated list.struct node* cutheadaddlast(struct node* head);struct node { int number; struct node * next; };Old MathJax webview Old MathJax webview In Java Some methods of the singly linked list listed below can be implemented efficiently (in different respects) (as opposed to an array or a doubly linked list), others not necessarily which are they and why? b. Implement a function to add an element before the first element. c. Implement a function to add an item after the last one element. d. Implement a function to output an element of the list. e. Implement a function to output the entire list. f. Implement a function to output the number of elements. G. Implement a function to delete an item. H. Implement a function to clear the entire list. I. Implement functionality to search for one or more students by first name, last name, matriculation number or course of study. J. Implement functionality to sort the records of the student, matriculation number and course according to two self-selected sorting methods.