5. The algorithm below is used to find the largest element in a list of nu By modifying one of the lines in the program it is possible to make ti and how? 01 target <- list[1] 02 FOR EACH num IN list 03 { 04 IF(num > target) 05 06 target <- num 07 08 } 09 DISPLAY(target) O A. Line 01 becomes target <- list[2] B. Line 04 becomes IF (num < target) C. Line 04 becomes if (num ce target) D. Line 01 becomes list[e] <- target
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 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 multiply_ends(nums) that takes a non-empty list of integers and returns the first…
A: 1. declare function with parameter nums i. get first element i.e. 0ith index element…
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: Problem 13 Vrite a function that takes a list and computes the alternating sum of all its elements.…
A: PROGRAM CODING: #include<iostream.h>using namespace std; int alternate_sum(int ar[], int size)…
Q: Assume that the values A through H are stored in a self-organizing list, initially in ascending…
A: Answer :
Q: 6. Write a program that creates a list-returned function to display a lists contains all but the…
A: The program is written in Python. Check the program screenshot for the indentation. Please check…
Q: c. Given a list of integers, keep only distinct, even numbers sorted in descending order and stored…
A: Java code for the given question is given below.
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: 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: This code by C to : 1- Create a sorted linked list using tenStudent array (copy from array into…
A: #include<stdio.h>#include<stdlib.h>struct student{int TC;char F_name[12];char…
Q: Write a function successor(items, target) that finds the first occurrence of target in the list list…
A: 1) Below is program to define successor function, which accepts a list and target item in the list…
Q: Complete the below code so the program will : - Receive a word from user - Then, transfers it into a…
A: I have implemented the requirements as per specification. There was an error in the implementation…
Q: Write a function that takes a list removal(L), delete from it all the elements whose indices are…
A: Algorithm: Start Initialize a list with given data Define a method named removal which takes the…
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: PROGRAMMING EXERCISE 5-3 Write a program to take two numerical lists of the same length ended with…
A: According to the Question below the Solution: According to the Policy i can solve only one…
Q: 1) With any two pre-defined lists of integer values, the code prints "Yes, {small list} is a subset…
A: As per the given question, we are given two lists - List_1 and List_2 We have to check if either of…
Q: A list is given an = {6,2,-4,13,7} Answer the following questions. a. What is n in an? b. List all…
A: Given list is an= {6,2,-4,13,7} Total six values.
Q: write a function called get_pa S that takes a list of words as input. The unction should return a…
A: Here is the code in Python:
Q: Write a program to implement the address book using namic singly linked list, the node should…
A: Note: Since you have not provided the language to write the code, I am using Java language to write…
Q: This code by C to : 1- Create a sorted linked list using tenStudent array (copy from array into the…
A: To update a C code that has a linked list with arrays. Now we have to update the code where deletion…
Q: Please answer it in Python Write a function extrait_pairs that takes as an argument a list l1 and…
A: 1) Below is python program that define a function extrait_pairs that takes as an argument a list l1…
Q: 1. Write a python program to eliminate all prime numbers in the list. 2. The user will input…
A: take n elements in array do input validation , value must be within 2 to 100 pass an array in…
Q: Suppose, you are given a doubly linked list of student marks. Write down a function that checks…
A: #include<iostream> using namespace std; struct node{ double marks; node *next;…
Q: 14.8 LAB: Selection sort Write a program that takes an integer list as input and sorts the list…
A: Modified code: def selection_sort_descend_trace(lst): for i in range(len(lst) - 1):…
Q: 11. A group of students writes their names and unique student ID numbers on sheets of paper. The…
A: Please check the next steps for the answer:
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: 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: 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: Use this code to get the number of operations from a list size of 10, 30, 50, 70, 100. In C++ bool…
A: Introduction: To sort an array of N numbers using bubble sort, we need to compare two adjacent…
Q: Assuming that data is a correctly created list, then the fact that lists are mutable means that the…
A: Since the python follows the zero indexing rule, there must be at least 10 elements inside the list…
Q: Write a function inde which returns the index (start from 1) of the occurrence of a given value. Use…
A: NOTE - I have used the Python programing language. As per our guidelines, we are supposed to answer…
Q: Please write it in Python Write a delete function that takes as an argument a list l and an elem…
A: Python Code: def delete( l, x ): l.remove(x) return x Explaination : Define a function…
Q: Write a function that shuffles the rows in a two-dimensional list using the following header:def…
A: //program that shuffles the matrix /*define class*/ public class MyClass{ /** Main method */ public…
Q: Assume that L is a list of Boolean values, True and False. Write a program in python with a function…
A: #function that takes boolean list of values#then returns a tuple which contains start and end of…
Q: QUESTION I (40p) : Write the following function that sorts and merges two lists into a new sorted…
A: Program Approach: Create 2 empty lists list1 and list2. Fill both lists by taking numerical input…
Q: Write a function countdown321 (nums) that returns True if the sequence 3, 2, 1 appears in the list…
A: Given:
Q: Based on structure below, write a function to add a node at head of linked list. start NULL temp…
A: Linked List a linear data structure where each node holds the reference of the next node.
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 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: 14. Suppose we have an integer list that contains quiz scores in which a score can range from 0 thru…
A: Required:
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: 1. Using the singly-linked list shown below, and assuming that head references the first Node and…
A: Below are the statements to perform the following instruction: -
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 decale function that takes as an argument a list l and a number d and returns the list…
A: # returns the list obtained from l by adding an offset of d to each element of ldef decale(lst, d):…
Q: python wirte a function max_indexes(xs) that inserts a list xs with numbers and returns a list of…
A: PROGRAM: #Defining max_indexes() def max_indexes(xs): #Defining list to store the…
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: 4. Consider the following linked list: first 10 12 14 16 18 struct Node Txpe ( int val Nadetxne"…
A: For finding sum of all existing nodes traverse the linked list until it do not points to NULL value.…
The given algorithm snippet finds the LARGEST element from the given list of numbers. The requirement if to change 1 line in the algorithm so that it returns the SMALLEST value element. The options are given in the code, need to find the correct option.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images
- he algorithm below is used to find the largest element in a list of numbers.By modifying one of the lines in the program it is possible to make the algorithm find the SMALLEST element. Which line would need to be modified and how?01 target <- list[1] 02 FOR EACH num IN list 03 { 04 IF(num > target) 05 { 06 target <- num 07 } 08 } 09 DISPLAY(target) a. Line 01 becomes target <- list[2] b. Line 01 becomes list[0] <- target c. Line 04 becomes if (num <= target) d. Line 04 becomes IF (num < target)1. ax + b = 0, y = aeˣ! a,b ≠ 0a,b are constants number entered by the user. Find (x,y) and determine the quadrant of thecartesian plane. Print (x,y) and write which quadrant (I,II,III or IV). (PYTHON) 2. Write a program that sorts a list in ascending order. Don’t use sort method.Ask user number of list elements (at least 10 elements)Enter all elements from keyboard and printed.Sort your list. (PYTHON)Perl I CpSc 390 Usin Perl Programm: A list of names (names) is given : “Jo Peter Ann Fred Linda Joe”. Please do the following: print the names for the order number of the names find the name (CTRL-Z to exit from the input) a second list with other group of names is also given: ”Mary, George, Nick”. An extension of the first list (names) so that to include the new names is needed. Hint: try to keep space among the names make sorting reverse take the size of the list take the new list (from d) : peter linda joe jo fred an Nick Mary George and delete all the other names except : Joe, Peter, Mary, George. (in any order) . Give the name for the list as: names1
- Let A={1,2,3...,10}. How many subsets B of A where B = │4│and the smallest element in B is 4? Write a computer program or develop an algorithm that lists all subsets according to the part (a). (Please display the all subsets).Python Programming - (Duplicate Elimination) Part 1: Create a function that receives a list and returns a (possibly shorter) list containing only the unique values in sorted order. Test your function with a list of numbers and a list of strings. Program is to also display results, that's the sorted list containing values. Part 2: Instead of hard coding the list passed to the sorting functions, request list values from user. (Hint: Request two lists from user, one containing values and another containing string.) Have the program eliminate duplicated values and display the lists (tasks required in part 1).Python only* Use recursive function*. Define colorListCircles with 2 parameters Use def to define colorListCircles with 2 parameters The colorListCircles function must draw concentric circles using colors from a list. It has two parameters: the first specifies the radius of the largest circle, and the second is a list of colors. The number of concentric circles drawn is the length of the list, and these circles are colored, from largest to smallest, by the colors in the list from first to last. When viewed as nested rings, all rings should have the same thickness. If the list is empty, nothing should be drawn. We will test both how many circles are drawn as well as whether the correct circles are drawn in the correct order, you may not use any loops and you must use recursion. Also, you will still need to use drawDot. For full credit, your function should call drawDot in only one place, and should only contain one recursive call. Do not use any kind of loop Within the definition…
- Python only* Use recursive function*. Define colorListCircles with 2 parameters Use def to define colorListCircles with 2 parameters The colorListCircles function must draw concentric circles using colors from a list. It has two parameters: the first specifies the radius of the largest circle, and the second is a list of colors. The number of concentric circles drawn is the length of the list, and these circles are colored, from largest to smallest, by the colors in the list from first to last. When viewed as nested rings, all rings should have the same thickness. If the list is empty, nothing should be drawn. We will test both how many circles are drawn as well as whether the correct circles are drawn in the correct order, you may not use any loops and you must use recursion. Also, you will still need to use drawDot. For full credit, your function should call drawDot in only one place, and should only contain one recursive call. Do not use any kind of loop Within the definition…python code. instructions are given within the quotation marks. 1) def get_misspelled_linear(dictionary, text): """ dictionary is a list of sorted words in the dictionary; you may assume all words in the dictionary are lower case and only contains a-z and apostrophe' text is a list of words from any given text. Use linear search to find the list of all misspelled words in text, a misspelled word is a word that is in the text but not in the dicionary. The comparison is case insensitive. For example if cat is in the dictionary, then CAT, cAt, cAT, cat and etc. are all considered to be valid word. Return the list of misspelled word. Your list of misspelled word must appear in the original order as they were in the text list and keep original form (upper/lower case) if dictionary has N words and text has K words, then the running time for this method will be O(NK) """ return [] 2) def get_misspelled_binary(dictionary, text): """ dictionary is a list of sorted words in the dictionary; you…Modify the following program to read dictionary items from a file and write the inverted dictionary to a file: characters = {'Bugs':['Rabbit', 1940, 'boy'], 'Garfield': ['Cat', 1978, 'boy'], 'Tweety': ['Bird', 1942, 'girl'], 'Sandy': ['Squirrel', 1999, 'female']} print("Printing the original dictionary") print(characters) print("") def invert_dict(characters): inverse = dict() for key in characters: val = characters[key] for list_item in val: if list_item not in inverse: inverse[list_item] = [key] else: inverse[list_item].append(key) return inverse my_invert = invert_dict(characters) print("Printing the inverted dictionary") print(my_invert) Include the following: 1) The input file for your original dictionary (with at least six items).2) The Python program to read from a file, invert the dictionary, and write to a different file.3) The output file for your inverted dictionary.…
- (python) calculating time in Bubble Sort the funtion will only run for 40 seconds create a list that stats with 5 and will be adding 5 each time, 5+5+5+5+...... until the program closes after 40seconds... #Bubble Sort def bubble_sort(a_list): for pass_num in range(len(a_list) - 1, 0, -1): for i in range(pass_num): if a_list[i] > a_list[i + 1]: temp = a_list[i] a_list[i] = a_list[i + 1] a_list[i + 1] = temp• Create a function which takes a tuple and returns a dictionary which is a histogramto count how many times each number exists in the tuple:• The main program must take the dictionary, transform the items into a list,use sort () to order the list (in ascending order) and after that display the list. def histo_n (x):'' '(tuple) -> dictReturns a dictionaryPrecondition: the tuple contains integers>>> t = (1,2, -3,3,4, -3,3,3)>>> histo_n (t){1: 1, 2: 1, 3: 3, 4: 1, -3: 2}'' ' Subject: Python ProgrammingLoad the JSON file below into Python as a dictionary; convert to a list and calculate the minimum velocity and maximum height using recursion. Introduce the space mission to the user and ask the user to guess a minimum velocity and maximum height, which the code should use as start points. Print the results (min & max to a file, and at the end read the file to display the results on the screen) This is partial data from the space mission Jason-3, flight number 26