only_evens ( [1, 2, 3]) >>> [2] only_evens([1, 5, 3]) [] only_evens ( [4, 4, 4]) [4, 4, 4] >>> >>>
Q: Given the list: my list-[32, 45, 20, 6, 8, 12, 51, 12] and the following Python function: def do…
A: list [20,6,8] will be sent to function do_sum() sum of squares will be calculated. so sum2=…
Q: def only_evens(lst: List[List[int]]) -> List[List[int]]: """Return a list of the lists in lst…
A: The objective is to write the code for the given data.
Q: Write a simple airline ticket reservation program. The program should display a menu with the…
A: Create the class Passenger as a linked list. The three data members are passenger name, flight…
Q: Question 2 A doubly linked list may be referred to as a complex type of linked list in which a node…
A: - We need to have the code for inserting the provided elements in a sorted doubly linked list.
Q: I need original solution.. because the solutions you gave me last time are incorrect It has to read…
A: It is defined as a powerful general-purpose programming language. It can be used to develop software…
Q: 1. So far, we have learnt many insert functions of linked lists . Now you have to write another…
A: C++ program: #include <bits/stdc++.h>using namespace std; // Function to sort an array using…
Q: Given lst = [30, 1, 2, 1, 0], what is the list after applying each of the fol-lowing statements?…
A: The various functions and their description is shown in the table below.
Q: Question-1: Write a python code that takes a string as an user input and finds out all the duplicate…
A: I will provide you a commented python code. So just read the code once and you will easily…
Q: The following function is supposed to print the last K elements of a linked list in reverse order…
A: To print the last k elements of a linked list in reverse order using stack, we need to follow below…
Q: Write the python function named keep_even_values. This function will have 1 parameter that will be a…
A: iterate from i=0 to len(lst) check if lst[i]%2==0 newList.append(lst[i]) i=i+1…
Q: 1. So far, we have learnt many insert functions of linked lists . Now you have to write another…
A: Start. Insert the elements. Perform the sorting. Remove the duplicates. Print the lists. Exit.
Q: Beginner C++ Write a program that reads in a list of integers and prints their maximum and minimum.…
A: The solution to the given problem is below.
Q: A linked list is a series of nodes, where each node in the list points to the next. The last node…
A: A node is a structure name that consists of a value data member, and the next is the pointer…
Q: Write correct Python code to complete the following tasks. Do not use any list methods or functions…
A:
Q: Write a program to swap two data items in a doubly linked list. swap (2nd node with 4rth) swap the…
A: C++ Code #include <bits/stdc++.h> using namespace std; class Node{ public: int…
Q: Prob 1 Given a list of x objects, create a program that performs the following operation: -Get the…
A: Given a list(named X for example) of objects and two functions/methods(func1, func2) are to be…
Q: Develop an algorithm to calculate the average of the elements of a list x. Implement your algorithm…
A: Program Plan: Define calculateAverage() function that calculates the average of the list. Input the…
Q: Function mergesort of type int list - int list that sorts the given list of integers using the…
A: The code of this is given below.
Q: Given a singly linked list, reverse the list. This means you have to reverse every node. For example…
A: singly linked list: It is the simplest type of linked list in which every node contains some data…
Q: Modify the Iterative C code to reverse a linked list #include using namespace std; void…
A: Please find the answer below
Q: 2. Write a function with the following signature: bool findElement(node *&list, int value) The…
A: Input: Search key Output : Return true if element present otherwise return false step1: Initialize…
Q: A dummy-headed circular singly-linked list has been created and holds a list of integer…
A: A circular linked list can be denoted as a data structure that is used to store values in the form…
Q: list comprehension
A: This is the above code in python language. This prints the Pythagorean Triplets in form of list:…
Q: um element of array public static int findMin(int[] list) { assert list != null &&…
A: // pre: list != null, list.length > 0 // post: return index of minimum element of array…
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: nsider a singly linked list of the form Y create a new node as shown below; ew node(); a=100; h is…
A: SUMMARY: - Hence, we discussed all the points.
Q: Can someone help me with this? C++ programming please! Given the MileageTrackerNode class, complete…
A: Actually, c++ is a powerful general purpose language.
Q: n a linked list. Please use C
A: given - 1. Write a simple procedure to count the number of elements in a linked list. Please use C
Q: 2. The following program below returns the maximum of the elements in a list. max ([X|List], Max):-…
A: Program1 // This java program find minimum and maximum value// of an unsorted list of Integer by…
Q: Create a program in C++ using a character linked list. It will insert the letters into the list…
A: #include <iostream> #include <string> using namespace std; int main () { string str;…
Q: in python create function that returns even numbers in a list form must only use while loop and…
A: Write a python function using only a while loop and if conditions that accept a list of numbers and…
Q: A linked list is a series of nodes, where each node in the list points to the next. The last node…
A: #include <iostream>#include <string>using namespace std; struct Node{ int value;…
Q: Write the following function that merges two sorted lists into a new sorted list:def merge(list1,…
A: def merge(list1,list2): len1=len(list1) len2=len(list2) len3=len1+len2…
Q: 2) Write a Python code to return the sum of integers in the list, returning 0 for an empty list.…
A: We will input the size of the list. Then we will input the list elements with the help of for loop.…
Q: public static int findMin(int[] list) { assert list != null && list.length > 0 : "failed…
A: // pre: list != null, list.length > 0 // post: return index of minimum element of array…
Q: (A) If operations given below is applied on a stack, what will be the result? (B) For array…
A: (A) . If following operations are performed what will be result. createStack() -> creates an…
Q: 1. So far, we have learnt many insert functions of linked lists . Now you have to write another…
A: *As per the company norms and guidelines we are providing first question answer only please repost…
Q: USING DOUBLY LINKED LIST in C Language In this project, you will implement a Polynomial ADT using…
A: The C programming language is a computer programming language and a powerful general-purpose…
Q: def is_valid_index(idx, in_list): """ Checks whether the provided index `idx` is a valid…
A: if (idx in in_list - 1): if len(idx) != 0: return idx else:…
Q: Write a python program that takes two lists, merges the two lists, sorts the resulting list, and…
A: def task7(list_in_1, list_in_2): final = list_in_1+ list_in_2 for i in range(len(final)):…
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: Circular linked list is a form of the linked list data structure where all nodes are connected as in…
A: struct Node *insertTonull(struct Node *last, int data) { if (last != NULL) return last;…
Q: General Instruction: Write a python program that declares and initializes a one-dmensional list…
A: myList = [5, 10, 15, 20, 25, 30, 35]print("The element in the list are: " + str(myList) + "\n")def…
Q: Using C, Must be in C Create a menu driven program that performs the following tasks (each task…
A: code:- #include<stdio.h>#include<stdlib.h>struct node{ int data; struct…
Q: PROGRAM: Your program should apply linked lists and have the following variables and functions. . An…
A: Solution - Programming language - C All solution steps are included in in program code as comments.…
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: 2. Write a program in 'C' language that implements a list using array. The elements of the list are…
A: Step 1:- Program Approach:- 1.Declare the array whose name is color 2.Initiliazie the array 3.Use…
Q: that gets a a paramet ate from that list. At the end return the new list. Do not use dictionary…
A: Main logic: - i = 0 while i < len(a): j = i + 1 while j < len(a): if…
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.
in python
create function that returns even numbers in a list form
must only use while loop and if built-in
cannot use anything else such as split, splice, sort!
cannot use for in statements!
must return a list!
Step by step
Solved in 4 steps with 2 images
- C++ PROGRAMMINGTopic: HashTable - PolyHash Quadratic Explain the c++ code below.: SEE ATTACHED PHOTO FOR THE PROBLEM INSTRUCTIONS It doesn't have to be long, as long as you explain what the important parts of the code do. (The code is already implemented and correct, only the explanation needed). You can also explain line by line for an upvote, thanks. EXPLAIN THE CODE BELOW: #include <cstdlib> #include <math.h> #include <cstring> #include <iostream> using namespace std; class HashTable { string* table; int N; int count; // TODO: Polynomial Hash Code using a=7 int hash_code(string key) { int code; int hash = 0; for (int i = 0; i < key.size(); i++) { char ch = key[i]; code += ((ch - 96) * pow(7, key.size() - (i + 1))); } return code; } // TODO: This hash table uses a MAD compression function // where a = 11, b = 461, p = 919 int compress(int code) { return (((11*code)+461) % 919) % N; }…* Assignment: Word operations * * Description: * This assignment asks you to implement common word operations that are * not available in the Scala programming language. The intent is to practice * your skills at working with bits. * */ package wordOps /* * Task 1: Population count (number of 1-bits in a word) * * Complete the following function that takes as parameter * a 32-bit word, w, and returns __the number of 1-bits__ in w. * */ def popCount(w: Int): Int = ??? /* * Task 2: Reverse bit positions * * Complete the following function that takes as parameter * a 16-bit word, w, and returns a 16-bit word, r, such that * for every j=0,1,...,15, * the value of the bit at position j in r is equal to * the value of the bit at position 15-j in w. * */ def reverse(w: Short): Short = ??? /* * Task 3: Left rotation * * Complete the following function that takes two parameters * * 1) a 64-bit word, w, and *…Stacks 1- Write a Python function that takes a user input of a word and returns True if it is a Palindrome and returns False otherwise (Your function should use a Stack data structure). A palindrome is a word that can be read the same backward as forward. Some examples of palindromic words are noon, civic, radar, level, rotor, kayak, reviver, racecar, redder, madam, and refer. 2- Write a Python function that takes a stack of integer numbers and returns the maximum value of the numbers in the stack. The stack should have the same numbers before and after calling the function. 3- Write a main function that tests the functions you wrote in 1 and 2 above and make sure that your code is well documented.
- C++ A matrix is a rectangular array of numbers that is arranged in a two-dimensional table. Matrices have numerous applications in computer systems. Matrix structures are examined in computer memory, graphics, and cryptography. The Hill cipher, for example, makes use of matrix inversions to encrypt and decrypt data. The intent of this problem is to develop a C++ program that computes and displays the inversion of a 2 x 2 matrix. A matrix is said to have the dimensions m x n if it has m rows and n columns. A square matrix has the same number of rows as columns, and is therefore said to have m x m dimensions. Matrix M shown below is an example of a 2 x 2 matrix. The inverse of a square matrix, M-1, is defined by the equation M(M-1) = I, where I is called the identity matrix. I is a square matrix that is all zeros except for ones along the main diagonal from the upper left corner to the lower right corner. I for a 2 x 2 matrix is: Multiplying a square matrix by its inverse will always…In this unit, you will make 3 capabilities: primary(): Call print_stack() and afterward call f1(10). f1(unsigned int): Call print_stack(). Characterize a nearby string containing "ABCD". Call f2() passing the string variable as its boundary. do as quickly as possible f2(char*): Call print_stack(). Moreover, characterize a full scale OFFSET=32 in this unit and utilize that full scale instead of the offset boundary at whatever point you call print_stack(). This assists you with testing your code utilizing various counterbalances without transforming it all through your code. Ensure the code arranges and there should be no mistakes. I need to see the full result in the terminal running, so I realize that the code arranges..Caesars Cypher in C programming language How do you program an encryption and decryption for a Caesars Cypher that covers all the possible ASCII characters? In this there should be a shift over K = 5 but the example below is K = 3. This should result in actual character and not the control ASCII represenations. For example: >>> $ encrypt(I have a key)N%mf{j%f%pj~>>> $ encrypt(see me at 3)xjj%rj%fy%8>>> $ decrpyt(|jfw%ns%gqzj)wear in blue Assume that the text parsing method has been succesful and it's the encryption/decryption of the char array that needs to be factored. Formula Encryption -> C = E(k, P) = (P + k) (mod 26) Decryption -> P = D(k, C) = (C - k) (mod 26) Where k = 5
- (True/False): Local variables are created by adding a positive value to the stack pointerC++ ProgrammingTopic: Stack, Ques and DequesBelow is the initial program of the main file, only modify the main file, sllstack file also provided. See attached photo for instructions. main.cpp #include <iostream> #include <cstring> #include "sllstack.h" using namespace std; int main(int argc, char** argv) { SLLStack* stack = new SLLStack(); int test; string str; cin >> test; switch (test) { case 0: getline(cin, str); // PERFORM SOLUTION TO BRACKETS PROBLEM HERE // FYI: Place your variable declarations, if any, before switch. break; case 1: stack->push('a'); stack->push('b'); stack->push('c'); cout << stack->pop() << endl; cout << stack->pop() << endl; cout << stack->pop() << endl; cout << stack->isEmpty() << endl; break;…Look at this stack frame: Fill in the data types for the following procedure: SomeSub PROC, LOCAL val1: , LOCAL val2: , LOCAL val3: , LOCAL val4:
- (C Language) The Fibonacci sequence begins with 0 and then 1 follows. All subsequent values are the sum of the previous two, for example: 0, 1, 1, 2, 3, 5, 8, 13. Complete the Fibonacci() function, which takes in an index, n, and returns the nth value in the sequence. Any negative index values should return -1.Write a function to sort strings in dictionary order. Example: Giving 'C programming', 'Java', 'CIS-1007', 'University'. The output in dictionary order should be: "C programming" "CIS-1007" "Java" "University" Note: You might ask the user to give the number of the input strings. You might need to use multidimensional arrays to store these strings. Note: You are NOT ALLOWED to use any built-in library EXCEPT stdio.h.a) Write a c++ program which contains a function isPalindrome, the function checks a stringusing pointers whether it is a palindrome or not and based on the decision return Ture orFalse. A string/word that reads the same backwards as forward is known as palindrome.E-g MADAM , POP , BOB etcb) Write a program that takes a char array (char *) that take your name as input, a charpointer point it and convert lower to upper and vice versa.