Option #2: List Computations Assignment Instructions Compute their Cartesian product, AxB of two lists. Each list has no more than 10 numbers. For example, if the user supplies the two input lists: A = [1,2] B = [3,4] then the Cartesian product output should be: AxB = [(1,3),(1,4),(2,3),
Q: C++ Programming Language ::::::: Redo the same functions this time as nonmember functions please :…
A: The Program is given below:
Q: t the following problem in the main case 0 (see attached photo) Your algorithm for the hierarchy…
A: Deque (doubly ended queue) is a linear data structure(i.e. it stores data in a sequential manner),…
Q: Several of the programming exercises in this section ask you to find the mean and median value in a…
A: #include <iostream> using namespace std; int main() { int a[100]; int i,n; float…
Q: Write a function for solving a quadratic equation using the following header:def solveQuadratic(eqn,…
A: def solveQuadratic(eqn, roots): a = float(eqn[0]) b = float(eqn[1]) c = float(eqn[2])…
Q: 9.15 REQUIRED LAB 9C: Output values below an amount Write a program that first gets a list of…
A: Code: # user input as a stringdata=input('Data list : ') # split integer values to store in…
Q: need help with python...paste indented code here QUESTION 3 Implement the following: 1) create a…
A: logic:- iterate from i=2 to 100 Check if i%2==0 Append i value to list i++ End loop
Q: PYTHON CODING This function takes a list of points and then returns a new list of points, which…
A: def solution_path(points): temp=points # adding starting point\ path=[points[0]] #…
Q: Python Programming Statement 1- Your friend John is provided with X lists consisting various Y…
A: According to the given problem statement we have to develop a Python code to find out to the minimum…
Q: Part 1.2: Big bOx Functions You are given two functions which are used in sequence as shown below.…
A: The Answer is
Q: Perform the Bubble Sort on the following list. You can use the sample algorithm presented during…
A: Bubble sort is one of the sorting techniques that work on the logic of repeatedly swapping the…
Q: 5.18 LAB: Smallest and largest numbers in a list Instructor note: Feel free to use Python's built-in…
A: Algorithm: Start Declare an empty list l Read numbers into the list till the is greater than 0…
Q: NOTE: A complete linked list program show (0.7) choices. 1 to Insert at the beginning 2 to Insert at…
A: The choices given from the program are:- to insert at the beginning to insert at the end. to…
Q: Focus on: Basic list operations, methods, use of functions, and good programming style Part 1.…
A: As per our guidelines we are supposed to answer only one question. Kindly repost the remaining…
Q: List slicing. a) Use a list comprehension to generate a list of all even numbers from 0 to 100…
A: In Python, List comprehension provides an shorter form to create an list based on the values of an…
Q: The programming language: C++ The union of two ordered lists (Sequential linear list)[the solution…
A: The program is written in C++. Please find the source code and output in the following steps.
Q: 1. count_perfect_squares This function takes a single argument, nums , Which is a list of numbers.…
A: Start import math def count_perfect_squares(nums): then count =0 if int(root + 0.5) ** 2…
Q: def bubble_down(values: list, left: int, right: int) -> None: """Bubble down through values[left:…
A: According to the information given:-We have to write the bubble_down function to swap the items in…
Q: Pseudocode: list [10, 15, 5, 16, 7, 1] mini <- list[0] min2 <- list[1] for each item in list _if…
A: list = [10, 15, 5, 16, 7 ,1] min1 = list[0] min2 = list[1] for item in list: if(item<min1):…
Q: Suppose lists A and B are lists with same length and have only integer items. define the function…
A:
Q: 2, The union of two ordered sets (Sequential linear list) [Problem description] Give the union of…
A: Algorithm : Step1: take size of first order set Step2:Take size of second order set Step3:input…
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: [Problem description] Give the union of two ordered lists. The maximal number of elements in an…
A: I am using python language for union of two ordered lists. According to example given in question,…
Q: 1. (a) 1 A) Design an algorithm that inputs two lists of numbers, A, and B, of lengths n and m…
A: Given The answer is given below.
Q: The list list1 and list2 are strictly identical if their corresponding elements are equal. write a…
A: #read size of the listsn=int(input("Enter the size of lists "))#lists…
Q: ndng 2. Modular Programming: Your program should be modular and consists of the following functions:…
A: the code is an given below : Raw_Code: def read():#prompting and reading Z value from userZ =…
Q: 3.8 LAB: Read values into a list Write a program that reads a list of integers into a list as long…
A: The above question is solved in step 2 :-
Q: 4.) A certain CS professor gives 5-point quizzes that are graded on the scale 5-A, 4-B, 3-C, 2-D,…
A: In this question we will write a python program the given program that accepts a quiz score as an…
Q: Topics: User-defined functions, list, string, docstring Problem Statement: This program finds the…
A: 1) Below is program to finds the unique letters from a given string and prints the unique letters…
Q: 1) Design the ADT in the form of binary list that provide the following services (UML) • insert a…
A: An abstract data type is implemented in which a binary list class is created which has binary[]…
Q: 9.16 REQUIRED LAB 9D: Find mode Write a program that reads a sequence of integers from input and…
A: - : Code Explanation : - We store the frequency of each element in the num_count list till…
Q: Lab Goal : This lab was designed to teach you more about list processing and algorithms. Lab D
A: Given Lab Goal : This lab was designed to teach you more about list processing and…
Q: Python assignment Exercise 2: Simple to-do list Create a simple to-do list using a list. Make sure…
A: The complete PYTHON code is given below with code and output screenshots
Q: Recursive Binary Search Instructions The binary search algorithm given in this chapter is…
A: Given: Recursive Binary Search Instructions The binary search algorithm given in this chapter is…
Q: Write a program that takes an integer list as input and sorts the list into descending order using…
A: Note: The correct code and output attached below. If you have any further query please let me know…
Q: public void Unknown() { if (size cur = head; Node prev = tail; for(int i=0; i < size/2; i++) {…
A: Ans : Assume this method is given within the KWArrayList class ,the answer that is correct is : c)…
Q: Given a list of numbers (nums), for each element in nums, calculate how many numbers in the list are…
A: Please find the answer below :
Q: Write a nested if statement that will determine the student's final letter grade. Display the…
A: Note: The final letter grade is based on Final Average value. PROGRAM: #Header file import random…
Q: Calculation "a" was used for loop to calculate the sum of squares of values in this list: 1, 7, 8,…
A: Note:-Since programming language was not mention we are providing solution in python programming…
Q: 16. Suppose that flips is a list containing strings, each either 'H' or 'T', for example., flips…
A: 16) Given: flip = ['H','H','H','H','H','T','T','H','T','H'] now expression to compute of 'H''s in…
Q: Write a DETAILED algorithm length to count the number of nodes in a singly linked list p, where p…
A: To search a node in the list we take a node whose pointer points to the first node p. Iterate…
Q: Instructions Create a program that contains a function append_combine(x, a) where x is a list of…
A: Since no programming language is mentioned, I am using python. Algorithm: Start Implement a method…
Q: Python Programming Question Python 3 PROGRAM A: APROGRAM.py This program should use a main function…
A: PYTHON program to solve the given problem.
Q: The two-dimensional lists m1 and m2 are identical if they have the same contents. Write a function…
A: Given: The two-dimensional lists m1 and m2 are identical if they have the same contents. Write a…
Q: Develop Pseudo-code (English-like) for: In the Find Largest pseudo-code algorithm of Figure 2.14,…
A: The algorithm in the question will find the largest element in the list. The first occurrence will…
Q: mplement
A: Deque (doubly ended queue) is a linear data structure(i.e. it stores data in a sequential manner),…
Q: Write a program which accepts a sequence of comma-separated numbers from console and generate a list…
A: List in Python: A list is a data type that allows you to store various types data in it. List is a…
Q: code shown in Figure 1 aims at perform data cleaning on the list food. There are a number of errors…
A:
Q: Write a python code that rolls 2 dice 10 times and saves them in separate lists. Then, add each roll…
A: Solution: import random import turtle l = []sumAll = 0 print("\nProgram to roll two dices and…
Q: (Using Python)Write a function that returns a new list by eliminating the duplicate values in the…
A: Actually, python is a easiest programming language. It is a dynamically typed programming language.
Option #2: List Computations
Assignment Instructions
Compute their Cartesian product, AxB of two lists. Each list has no more than 10 numbers.
For example, if the user supplies the two input lists:
A = [1,2]
B = [3,4]
then the Cartesian product output should be:
AxB = [(1,3),(1,4),(2,3),(2,4)]
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
- The function swap_list_ends in python takes one parameter, L, which is a list. The function then swaps the first and last items in L and returns the object None. Notice that since L is mutable, the changes the function makes to L are visible back in the calling program. SPECIAL CASE: If the list 'L' is empty, then the function does nothing to L and returns None. For example: Test Result L = [1, 3, 9, 2] if not(swap_list_ends(L) is None): print("Error: function should return None") print(L) [2, 3, 9, 1] L = ['super', 'awesome', 'excellent'] if not(swap_list_ends(L) is None): print("Error: function should return None") print(L) ['excellent', 'awesome', 'super'] L = [True, False] if not(swap_list_ends(L) is None): print("Error: function should return None") print(L) [False, True]Please answer it in Python Write a decale function that takes as an argument a list l and a number d and returns the list obtained from l by adding an offset of d to each element of l. Example: decale([4, 17, 12], 3) is [7, 20, 15]. Write a function intercale_zeros that takes as an argument a list l and returns the list obtained from l by inserting a zero after each element of l. Example: intercale_zeros([4, 17, 12]) is [4, 0, 17, 0, 12, 0].Assume s1,s2 are two stacks and we write s1=s2 , if the class stack based on linked list then Select one: a. This statement is good when s2 has large number of items and s1 has small number of items b. This statement is good when s2 has small number of items and s1 has small number of items c. This statement is good when s2 has large number of items and s1 has large number of items d. This statement is good when s2 has small number of items and s1 has large number of items
- The function interleave_lists in python takes two parameters, L1 and L2, both lists. Notice that the lists may have different lengths. The function accumulates a new list by appending alternating items from L1 and L2 until one list has been exhausted. The remaining items from the other list are then appended to the end of the new list, and the new list is returned. For example, if L1 = ["hop", "skip", "jump", "rest"] and L2 = ["up", "down"], then the function would return the list: ["hop", "up", "skip", "down", "jump", "rest"]. HINT: Python has a built-in function min() which is helpful here. Initialize accumulator variable newlist to be an empty list Set min_length = min(len(L1), len(L2)), the smaller of the two list lengths Use a for loop to iterate k over range(min_length) to do the first part of this function's work. On each iteration, append to newlist the item from index k in L1, and then append the item from index k in L2 (two appends on each iteration). AFTER the loop…Please code this in Java Or C or C++ Given two numbers represented by a linked list, where each node contains a single digit. The digits are stored in reverse order, such that the 1's digit is at the head of the list. Write a function that adds the two numbers and return the sum as linked list: Example : Input : (7-> 1 -> 6) + (5-> 9-> 2). That is 617 + 295 = 912 Output : 2-> 1 -> 9 Expected time complexity : O(m+n), where m and n are no. of nodes in first and second linked list respectively.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]
- Given a ListItem class, complete main() using the built-in list type to create a linked list called shoppingList. The program should read items from input (ending with -1), adding each item to shoppingList, and output each item in shoppingList using the PrintNodeData() function. Ex. If the input is: milkbreadeggswafflescereal-1 the output is: milkbreadeggswafflescereal #include "ListItem.h"#include <string>#include <list>#include <iostream> using namespace std; int main (int argc, char* argv[]) { // TODO: Declare a list called shoppingList of type ListItem string item; // TODO: Read inputs (items) and add them to the shoppingList list // Read inputs until a -1 is input // TODO: Print the shoppingList list using the PrintNodeData() function return 0;} #ifndef LISTITEMH#define LISTITEMH #include <string> using namespace std; class ListItem { public: ListItem(); ListItem(string itemInit); // Print this node void…USING PYTHON Chapter 5 -Programming Project: Implement a function that takes in two sorted lists and merges them into one list, the new list must be sorted. The function MUST run in O(m+n), where m is the length of list 1 and n the length of list 2. In other words, the function cannot do more than one pass on list 1 and list 2.ISP-Java Write a program that gets a list of integers from the input value and outputs all integers less than or equal to the threshold value. The first input begins with an integer indicating the number of integers that the list (array) will hold. Based on the first input value, the user will then input integers into the list. Then, the last input integer will indicate the threshold. Output all integers less than or equal to that last threshold value. Assume that the list will always contain fewer than 20 integers. Ex: The following is an example of the input and output: Enter the number of integers that list will hold: 4 Enter integers for the list: 12 26 88 1999 Enter threshold integer: 28 Below are the integers that are <= to the threshold integer: 12 26
- python 8.7 LAB: Writing append and search methods (singly-linked list)Given main.py and a Node class in Node.py, complete the LinkedList class in LinkedList.py by writing the append() and search() methods. The search() method should return the Node whose data value matches a given key, and None if the key is not found. The search() method should also set the position of each Node searched in the LinkedList, starting with 1. Ex: If the input is: 12 23 59 37 923 212the output is: 12 found in list at position 1.If the input is: 12 23 59 37 923 268the output is: 68 not found in list.Assume s1,s2 are two stacks and we write s1=s2 , if the class stack based on linked list then إختر أحد الخيارات: a. This statement is good when s2 has small number of items and s1 has large number of items b. This statement is good when s2 has small number of items and s1 has small number of items c. This statement is good when s2 has large number of items and s1 has small number of items d. This statement is good when s2 has large number of items and s1 has large number of items أخلِ اختياريGiven a data structure that is a list of tuples (see line below), write one line of code that accesses the first element of the 3rd tuple in the list. Assume this element exists. list_of_tups = [(4, 5), (6, 7, 8, 0), (9, 1, 2)]# add your line of code that produces the desired output of 9