In Section 10.11.1, you used selection sort to sort a list. The selection-sort function repeatedly finds the smallest number in the current list and swaps it with the first one. Rewrite this program by finding the largest number and swapping it with the last one. Write a test program that reads in ten numbers, invokes the function, and displays the sorted numbers.
Q: Write a function remove_smallest() that gets a dictionary as a parameter and remove the item which…
A: def remove_smallest(data): #find min value in dict value=min(data.values()) #create new…
Q: Write a program that gets a list of integers from input, and outputs the integers in ascending order…
A: Program:#include<iostream>#include<vector> using namespace std; void…
Q: Write a C ++ program that generates 1000 random integers ranging from 5 to 100 and stores them in an…
A: Program: //including essential header file #include <iostream> #include <cstdlib>…
Q: Exercise 5: Write a program that that reads values from an input file "data.txt" and stores them in…
A: The main purpose of the program is to read numeric data from data.txt file and store into the list.…
Q: Insert Items in the list Display all items. Traverse the link list so that each item's bill gets…
A: C++ is an object-oriented programming language, it's used to develop web-browser applications and…
Q: Exercise : Create a program that asks the user to create 2 lists composed of 5 numbers each. 2…
A: """Program to get two list from user of 5 numbers each, remove duplicatesand print list in reverse…
Q: a program that gets a list of integers from input, and outputs the integers in ascending order…
A: Program Explanation: - The integer variable size is declared. The string variable is declared to…
Q: write a function that add any item in a linked list after the item X, if the item X is not found in…
A: Step 1: Define the function insertAfterX() with two arguments namely, element to be inserted and the…
Q: Write the following function that merges two sorted lists into a new sorted list: void merge(const…
A: solution is given below
Q: Write pseudo code to count occurrence of a given number in the list. For example, consider the…
A: Introduction of Pseudo Code: Pseudocode is used to implement an algorithm in the programming…
Q: Write a program that reads a list of integers, and outputs the two smallest integers in the list, in…
A: #include <stdio.h>#include <stdlib.h>#include <limits.h> int main(){ int…
Q: the string below comes from an alphabet consisting of only characters A and B. Accordingly, write…
A: Answer : #include<stdio.h> void print_permutation(char str[], int i, int n) { //if the…
Q: eprivate static void sort(int [] list, int low, int high) { eif (low < high) { // Find the smallest…
A: Hi there, Please find your solution below, I hope you would find my solution useful and helpful.…
Q: Write a Java program that generates randomly a list of N integers, sorts the generated list using…
A: The Java program is given in step-2.
Q: Write a program that gets a list of integers from input, and outputs the integers in ascending order…
A: The required C++ code is: #include<iostream>#include<vector>using namespace std;// swap…
Q: Write a program that reads a list of integers, and outputs the two smallest integers in the list, in…
A: import java.util.*;public class Main{public static void main(String[] args) { int…
Q: Write a program that takes sequence of comma separated numbers an input from the user. The program…
A: Code: #reading list of numbers with comma separatorL = [int(x) for x in input("Enter numbers with…
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 Java method that merges two sorted lists into a new sorted list. public static int[]…
A: Given: Create a Java function that combines two sorted lists to create a new sorted list.
Q: A user is going to enter numbers one at a time, entering 'q' when finished. Put the numbers in a…
A: Using while loop and if-else statements we can solve this problem.
Q: Write a program that takes a sequence of non-negative numbers and performs the computation suggested…
A: print("Enter numbers with spaces and to end enter -1 at last : ")n = input() lst = [int(x) for x in…
Q: Write a program that first gets a list of integers from input. The input begins with an integer…
A: Approach We will use for loop to iterate over each list element and if statement to check whether…
Q: Write a program that reads in babynames.txt and produces two files, boynames.txt and girlnames.txt,…
A: # Create a bool variable to use as a flag. foundGirl = False # Get the search value from the…
Q: Exercise 2: Write a program that reads n values from an input screen and stores them in a list T1,…
A: Here programming language is not given so using C++. First of all let's understand the algorithm: 1.…
Q: Write a function swap that swaps the first and last elements of a list argument. Sample output with…
A: code snippet:
Q: the infix expression a/b-c+d*e-a*c into postfix expression and trace that postfix expression for…
A: the infix expression a/b-c+d*e-a*c into postfix expression and trace that postfix expression for…
Q: Create a program that removes duplicate integer values from a list. For example if a list has these…
A: Program code: #Taking input from user until the user press 0 def input_element(): #array…
Q: Write a Java method that merges two sorted lists into a new sorted list. public static int []…
A: As per the given question, we have to design a java program that merges two sorted lists. Algorithm…
Q: Write the python function selection_sort_descend_trace() that takes an integer list and sorts the…
A: Given:
Q: In Python, Write a program that replaces words in a sentence. The input begins with word…
A: Python program to solve the given problem is below.
Q: Write a program that reads a list of integers from the keyboard and creates the following…
A: PROGRAM CODE: #include <iostream> // include header file for input output…
Q: In Java languge (Duplicate Elimination) Write a program that reads in a series of first names and…
A: Java program to solve the given problem is below.
Q: the string below comes from an alphabet consisting of only characters A and B. Accordingly, write…
A: Given: The string below comes from an alphabet consisting of only characters A and B. Accordingly,…
Q: Write a program that gets a list of integers from input, and outputs the integers in ascending order…
A: Here is the c++ implementation of above problem. I have used bubble to get the results.
Q: Write the following function that merges two sorted lists into a new sorted list: void…
A: #include <bits/stdc++.h>#include<algorithm>using namespace std;int merge_arrays(int…
Q: 42. Write a loop that will read in a list of even numbers (such as 2, 24, 8, 6) and compute the…
A: According to the Question below the Complete Program: Program Output:
Q: Write a program that reads a list of integers, and outputs whether the list contains all even…
A: Programming instructions: Take inputs from the user for the list. Create a function…
Q: Write a program named p3.py that starts with an empty list and then asks the user for a positive…
A: import random lst = [] # Creating an empty list. n = int(input("n >> ")) # Generating n random…
Q: A user is going to enter numbers one at a time, entering 'q' when finished. Put the numbers in a…
A: I give the code in Python along with output and code screenshot
Q: the numbers that are present in both lists. See sample lists and output below. Input two sets of…
A: given - Write a program that asks the user to input 2 lists of numbers, 5 numbers per list. Your…
Q: write a program that reads the students.txt file and stores the name of the student and the grade…
A: The java coding is implemented below: All the steps and functions are mentioned in comment so that…
Q: Write a program that asks the user to input 2 lists of numbers, 5 numbers per list. Your program…
A: Given: Write a program that asks the user to input 2 lists of numbers, 5 numbers per list. Your…
Q: Write a program that takes input of a list of text, numbers, etc., and outputs that list in reverse.…
A: I give the code in Python along with output and code screenshot
Q: Please write a program that checks if the last data item entered appears earlier in the list. The…
A: Coded using Python 3.
Q: Write a python function called remove_odd that takes a list of numbers that have both even and odd…
A: PROGRAM CODE: def remove_odd(list): list = [x for x in list if x%2==0] print (list)…
Q: In this problem you will process two lists of numbers and return the difference. The difference are…
A: Algorithm : 1. Input n. Enter n elements of list1. Store in arr1. 2. Input m. Enter m elements of…
Q: Write a C++ program that generates 1000 random integers ranging from 5 to 100 and stores them in an…
A: Note: We are authorized to answer one question at a time, since you have mentioned 1, 2, 3, and 4…
Q: Write a version of the sequential search algorithm that can be used to search a sorted list. Write a…
A: Given :- Write a version of the sequential search algorithm that can be used to search a sorted…
In Section 10.11.1, you used selection sort to sort a list. The selection-sort function repeatedly finds the smallest number in the current list and swaps it with the first one. Rewrite this
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
- You can shuffle a list using random.shuffle(lst). Write your own function without using random.shuffle(lst) to shuffle a list and return the list. Use the following function header:def shuffle(lst):Write a test program that prompts the user to enter a list of numbers, invokes the function to shuffle the numbers, and displays the numbers.Write a program that reads a list of integers, and outputs whether the list contains all even numbers, odd numbers, or neither. The input begins with an integer indicating the number of integers that follow. Your program must define and call the following two functions. is_list_even() returns true if all integers in the list are even and false otherwise. is_list_odd() returns true if all integers in the list are odd and false otherwise.def is_list_even(my_list)def is_list_odd(my_list)Exercise 2: Write a program that reads n values from an input screen and stores them in a list T1, then fills another list T2 with values from T1 where any consecutive duplicated values appears only one time, i.e. removes consecutive duplicated values. If you run your program with the following input data: 4 7 3 3 3 6 14 14 10 5 7 7 7 7 2 2 4 4 4 10. Your output should be as follows: Number of elements in T1: 20 T1: 4 7 3 3 3 6 14 14 10 5 7 7 7 7 2 2 4 4 4 10 Number of elements in T2: 11 T2: 4 7 3 6 14 10 5 7 2 4 10 Your program should have at least these 3 functions: 1. main():displays the original list T1, the number of elements of T2 and list T2 2. readData():reads data from input screen into a list 3. removeConsecutiveDuplicates(): takes a list and remove any consecutive duplicated numbers
- 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.***NEED HELP WITH THIS**** write a code that replicates the list's insert() method. Recall that insert(index, item) method inserts the item at specified index in the list. Write a code that: Asks the user to input 5 items in a list and display the list. Ask the user to input the index where they would like to insert a new item. Ask the user to input the item that they would like to insert into the list. Inserts the new item into the list and displays the modified list. If the index is greater than the length of the list, simply insert the new item at the end of list. Also i dont need to use the list's insert() method to do this program. I dont need to write a function, just the code to replicate the functionality of insert() method.Write a program that reads a list of integers, and outputs whether the list contains all even numbers, odd numbers, or neither. The input begins with an integer indicating the number of integers in the list. The first integer is not in the list. Your program must define and call the following two functions. is_list_even() returns true if all integers in the list are even and false otherwise. is_list_odd() returns true if all integers in the list are odd and false otherwise.def is_list_even(my_list)def is_list_odd(my_list) Must pass the following attached screen shot test
- Write a program that reads a list of integers, and outputs whether the list contains all even numbers, odd numbers, or neither. The input begins with an integer indicating the number of integers in the list. The first integer is not in the list. Your program must define and call the following two functions. is_list_even() returns true if all integers in the list are even and false otherwise. is_list_odd() returns true if all integers in the list are odd and false otherwise.def is_list_even(my_list)def is_list_odd(my_list) My program is failing on is_list_even([10,12,14]) and is_list_odd([9,11,13]) Code so far: def is_list_even(my_list): for i in range(len(my_list)): if my_list[i] % 2 != 0: return False return True def is_list_odd(my_list): for i in range(len(my_list)): if my_list[i] % 2 == 0: return False return True if __name__ == '__main__': my_list = [] n = float(input()) for i in range(n):…The following is useful as part of a program to play Minesweeper. Suppose you have a 5×5 list that consists of 0s and M's. Write a program that creates a new 5×5 list that has M's in the same place, but the Zeroes are replaced by counts of how many M's are in adjacent cells (adjacent either horizontally, vertically, or diagonally). An example is shown below. An example is shown below:Code should be in Python, please Write a program that replaces words in a sentence. The input begins with word replacement pairs (original and replacement). The next line of input is the sentence where any word on the original list is replaced. Ex: If the input is: automobile car manufacturer maker children kids The automobile manufacturer recommends car seats for children if the automobile doesn't already have one. the output is: The car maker recommends car seats for kids if the car doesn't already have one. You can assume the original words are unique.
- The local driver's license office has asked you to create an application that grades the written portion of the driver's license exam. The exam has 20 multiple-choice questions. Here are the correct answers: 6. A 11. B 16. C 12. C 17. C 13. D 18. B 14. A 19. D 15. D 20. A 1. B 2. D 3. A 4. A 5. C 7. B 8. A 9. C 10. D Your program should store these correct answers in a list. The program should read the student's answers for each of the 20 questions from a list named Anskey_list and store the answers in another list, say ans_list. After the student's answers have been read from the ans_list, the program should display a message indicating whether the student passed or failed the exam. (A student must correctly answer 15 of the 20 questions to pass the exam.) It should then display the total number of correctly answered questions, the total number of incorrectly answered questions, and a list showing the question numbers of the incorrectly answered questions.Write a program that takes an integer list as input and sorts the list into descending order using selection sort. The program should use nested loops and output the list after each iteration of the outer loop, thus outputting the list N-1 times (where N is the size of the list). Important Coding Guidelines: Use comments, and whitespaces around operators and assignments. Use line breaks and indent your code. Use naming conventions for variables, functions, methods, and more. This makes it easier to understand the code. Write simple code and do not over complicate the logic. Code exhibits simplicity when it’s well organized, logically minimal, and easily readable. Ex: If the input is: 20 10 30 40 the output is: [40, 10, 30, 20] [40, 30, 10, 20] [40, 30, 20, 10] Ex: If the input is: 7 8 3 the output is: [8, 7, 3] [8, 7, 3] Note: Use print(numbers) to output the list numbers and achieve the format shown in the example.Write a program that takes an integer list as input and sorts the list into descending order using selection sort. The program should use nested loops and output the list after each iteration of the outer loop, thus outputting the list N-1 times (where N is the size of the list). Important Coding Guidelines: Use comments, and whitespaces around operators and assignments. Use line breaks and indent your code. Use naming conventions for variables, functions, methods, and more. This makes it easier to understand the code. Write simple code and do not over complicate the logic. Code exhibits simplicity when it’s well organized, logically minimal, and easily readable. Ex: If the input is: 20 10 30 40 the output is: [40, 10, 30, 20] [40, 30, 10, 20] [40, 30, 20, 10] Ex: If the input is: 7 8 3 the output is: [8, 7, 3] Note: Use print(numbers) to output the list numbers and achieve the format shown in the example. LAB ACTIVITY 2.15.1: LAB: Descending selection sort with output during…