What is the output of the following program? < Assume there is NO syntax error> struct st { int info; struct st *next; }; struct st *list, *ptr; list = new st; list -> info = 20; ptr = new st; ptr -> info = 36; ptr -> next = NULL; list -> next = ptr; ptr = new st; ptr -> info = 40; ptr -> next = list; list ->next->next = ptr; list->next->info=99; list->next->next->next = ptr->next; ptr = list->next->next; while ( ptr != list ) { cout << “ List -> info value is “ << list -> info << " " << endl; list = list->next; } return 0; }
Q: Identify the output execution of print() function in main?
A: Given list L1 is initialized as 23->32->21->12 print() function not returning anything but…
Q: ríte a function called filler(A, 1) hat takes an integer A, and a list of integers 1 nd if some of…
A: Input : Input A Input l Output : Output the numbers from list that adds up to A.
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: 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: Write a function that returns a new list by eliminating the duplicate values in the list. Use the…
A: note: we are only allowed to solve one question in one post. please post-second question in a…
Q: Write a function definition which has two parameters, both lists. The function is supposed to return…
A: Here have to determine python code for given problem.
Q: o Write a function called average(list) that takes a list as a parameter and returns the average.…
A: ALGORITHM:- 1. Declare and initialise the list with the elements. 2. Pass it to the average()…
Q: Write a function lastDigits() that takes a list of numbers as parameter, returns a string made of…
A: Required: Write a function lastDigits() that takes a list of numbers as parameter, returns a string…
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: In OCaml Programming Language, write a function: val prime_separator : int list -> int list * int…
A: val prime_separator : int list -> int list * int list = <fun> that takes an integer list as…
Q: In OCaml Programming Language, write a function:
A: ICAML CODE: let rec cond_dup (lst: 'a list) (f: 'a -> bool): 'a list = match lst with…
Q: Hello, I need some help with this c++ question Given that lst1 is an object of the STL list…
A: Code: #include <iostream>#include <iterator>#include <list>using namespace…
Q: What is the best way to reuse lines of code? A. Copy and paste them wherever needed B. Lines of code…
A: The above question is solved in step 2 :-
Q: Write a function littler_indices (integers, upper_limit) that returns a list of the indexes of every…
A: def littler_indices(integers, upper_limit): i_list = [] for i in range(0, len(integers)):…
Q: Please use python for this problem: Please use Python when answering the question: Question…
A: Python is a high level programming language. Guido van Rossum, is the father of Python. Just like…
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: Using the following struct: typedef char DATA; struct node { DATA d; struct node *next; };…
A: PFB the program: #include <stdio.h>#include <stdlib.h>typedef char DATA;typedefstruct…
Q: primeFac (Perkovic, Problem 5.42) Write a function primeFac that computes the prime factorization of…
A: PROGRAM INTRODUCTION: Start the definition of the function to find the prime factors of the number…
Q: ) Write a function dropLowest() with one parameter n. 2) n is a list that contains any 5 random…
A: def dropLowest(n): index_Of_min = n.index(min(n)) n.remove(n[index_Of_min]) return…
Q: 2. listAverage() returns the average number in a list. Which of these functions does this correctly?…
A: listaverage() function which return the average of number given in list.
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: How would I make a C++ program that uses smart pointers in a doubly linked list
A: Using smart pointers in Doubly Linked Lists: shared ptr is a smart pointer that allows numerous…
Q: in C++ kth Element Extend the class linkedListType by adding the following operations: a. Write a…
A: (A) In this function, Initially, we declare a node called random and set it equal to the head of…
Q: n OCaml Programming Language, write a function: val prime_separator : int list -> int list * int…
A: GIVEN: In OCaml Programming Language, write a function: val prime_separator : int list -> int…
Q: Define the remNth function which removes every nth value from a given list. e.g remNth 2…
A: remNth :: Int -> [] a -> [] a remNth = \n -> \list -> case n of 0 -> tail list…
Q: Use the function design recipe to develop a function named count_odds. The function takes a list of…
A:
Q: Name: Nil } else { start aux (start + 1, count - 1) } } aux (init, n) } val xs List [Int] = { val n…
A: Note: Answering the first question 10 i.e. as per the guidelines. Task : Given the scala…
Q: Write a function named get_replacement that takes as arguments a character c and 2 lists of…
A: The Answer is
Q: 18. To add a new element to a list we use which Python con comma a. list1.addEnd(5) b.…
A: Here in this multiple type question we have asked some python command and function in Python
Q: please code in python Write a function that takes in a number and returns the sum of all primes…
A: def isPrime(n): if n <= 1 : return False for i in range(2, n): if n % i == 0: return False…
Q: $\square \quad$ Question 1 Study the definition of function funArray and answer the question below.…
A: Solution: Language: C++ Source Code: please check step 2 for code
Q: I need help being able to make a function that adds an item to the back of a doubly linked list to…
A: Objective: According to the given question, this program should include the method addBack to add…
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: 1) Write a function that takes one argument, a list named sample-list. 2 ) If the length of the…
A: Task :- Write a python program for given question. Python program :- def fun(sample_list):…
Q: Python Write a function that takes as a parameter a list of strings and returns a list containing…
A: def countLength(lstString): lstLength = [] for i in lstString: length =…
Q: Consider the following declaration. int list[] = {3, 8, 10, 13, 6, 11};a. Write a C++ code that will…
A: a) In this part, you need to write program for displaying all values of given list. You can show…
Q: Problem: List Reverse Given a list (objects with a chain of sub-objects, for example: var list = {…
A: According to the Question below the Complete Program: Program Output:
Q: Problem: List Reverse Given a list (objects with a chain of sub-objects, for example: var list = {…
A: According to the Question below the Complete Answer: Program Output:
Q: Write a function that takes a list and returns a new list that contains all the elements of the…
A: Introduction : Here, we have to write a function that takes a list and returns a new list…
Q: Write a function maxGroup that determines, for a given integer list, the stored number of the…
A: l=list(map(int,input().split()))d={}for i in l: if i in d: d[i]+=1; else:…
Q: Our second pattern is the mapped list pattern, described in video 4 3 mapped list pattern. Often we…
A: The for loop in Python is used to iterate the statements or a part of the program several times. The…
Q: In the struct structure given below, the data of a student is stored in a singly linear linked list.…
A: Assign the variables largest and secondLargest to store grades and maintain a variable to store…
Q: Show the output of the following two programs: (a)def main():list1 = m(1)print(list1)list2 =…
A: Given: Show the output of the following two programs: (a)def main():list1 = m(1)print(list1)list2…
Q: Suppose you have two objects of Doubly Linked List D1 and D2. Each object is representing a…
A: A linked list is a linear data structure that consists of nodes. A node has a pointer link that…
Q: Write a function val nextpascalrow : int list -> int list = that given a list of integers that…
A: Given: Write a function val nextpascalrow : int list -> int list = <fun> that given a list…
Q: Write a function that takes as a parameter a list of strings and returns a list containing the…
A: Please find the answer below :
Q: Task 12 Write a python function that takes a list as an argument. Your task is to create a new list…
A: def function_name(elements): #declaring varible to track removed elements removed=0 #new…
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 function called chop that takes a list, modifies it by removing the first and last elements,…
A: We will be seeing the simple program for implementing our classes. We will be having comments which…
Q: For practice, write programs to do the following tasks. Comma Code Say you have a list value like…
A: Answer : def join_words(words): result = '' for i in range(len(words)): result +=…
What is the output of the following program?
< Assume there is NO syntax error>
struct st
{ int info;
struct st *next;
};
struct st *list, *ptr;
list = new st;
list -> info = 20;
ptr = new st;
ptr -> info = 36;
ptr -> next = NULL;
list -> next = ptr;
ptr = new st;
ptr -> info = 40;
ptr -> next = list;
list ->next->next = ptr;
list->next->info=99;
list->next->next->next = ptr->next;
ptr = list->next->next;
while ( ptr != list )
{ cout << “ List -> info value is “ << list -> info << " " << endl;
list = list->next;
}
return 0;
}
Step by step
Solved in 2 steps with 1 images
- in haskell: Write a function sumNums that adds the items in a list and returns a list of the running totals. For example: sumNums [2,3,4,5] returns [2,5,9,14].Write a function that takes list and a number (x) as parameters. Assume list contains only numbers, the function displays all of the numbers that are greater than x, and return true. If the function does not find any number greater than x, return your false which indicates an error.10.20 LAB: Multiples of ten in a list Write a program that reads a list of integers, and outputs whether the list contains all multiples of 10, no multiples of 10, or mixed values. Define a function named is_list_mult10 that takes a list as a parameter, and returns a boolean that represents whether the list contains all multiples of ten. Define a function named is_list_no_mult10 that takes a list as a parameter and returns a boolean that represents whether the list contains no multiples of ten. Then, write a main program that takes an integer, representing the size of the list, followed by the list values. The first integer is not in the list. Ex: If the input is: 5 20 40 60 80 100 the output is: all multiples of 10 Ex: If the input is: 5 11 -32 53 -74 95 the output is: no multiples of 10 Ex: If the input is: 5 10 25 30 40 55 the output is: mixed values The program must define and call the following two functions. is_list_mult10() returns true if all integers in the list are…
- A function can modify the value of an actual parameter only if it'sa) mutable b) a list c) passed by reference d) a variableIn c++ and please without the use of vectors. Thanks very much! A contact list is a place where you can store a specific contact with other associated information such as a phone number, email address, birthday, etc. Write a program that first takes as input an integer N that represents the number of word pairs in the list to follow. Word pairs consist of a name and a phone number (both strings). That list is followed by a name, and your program should output the phone number associated with that name. Define and call the following function. The return value of FindContact is the index of the contact with the provided contact name. If the name is not found, the function should return -1 This function should use linear search. Modify the algorithm to output the count of how many comparisons were performed during the search, before it returns the index (or -1). int FindContact(ContactInfo contacts[], int size, string contactName) Ex: If the input is: 3 Joe 123-5432 Linda 983-4123…In c++ and please without the use of vectors. Thanks very much! A contact list is a place where you can store a specific contact with other associated information such as a phone number, email address, birthday, etc. Write a program that first takes as input an integer N that represents the number of word pairs in the list to follow. Word pairs consist of a name and a phone number (both strings). That list is followed by a name, and your program should output the phone number associated with that name. Define and call the following function. The return value of FindContact is the index of the contact with the provided contact name. If the name is not found, the function should return -1 This function should use linear search. Modify the algorithm to output the count of how many comparisons were performed during the search, before it returns the index (or -1). int FindContact(ContactInfo contacts[], int size, string contactName) Ex: If the input is: 3 Joe 123-5432 Linda 983-4123…
- Question 1 Write a function to print “hello_USERNAME!” USERNAME is the input of the function. The first line of the code has been defined as below. def hello_name(user_name): ..... Question 2 Write a python function, first_odds that prints the odd numbers from 1-100 and returns nothing def first_odds(): ..... Question 3 Please write a Python function, max_num_in_list to return the max number of a given list. The first line of the code has been defined as below. def max_num_in_list(a_list): ..... Question 4 Write a function to return if the given year is a leap year. A leap year is divisible by 4, but not divisible by 100, unless it is also divisible by 400. The return should be boolean Type (true/false). def is_leap_year(a_year): ..... Question 5 Write a function to check to see if all numbers in list are consecutive numbers. For example, [2,3,4,5,6,7] are consecutive numbers, but [1,2,4,5] are not consecutive numbers. The return should be boolean Type.Question 1 Write a function to print “hello_USERNAME!” USERNAME is the input of the function. The first line of the code has been defined as below. def hello_name(user_name): ..... Question 2 Write a python function, first_odds that prints the odd numbers from 1-100 and returns nothing def first_odds(): ..... Question 3 Please write a Python function, max_num_in_list to return the max number of a given list. The first line of the code has been defined as below. def max_num_in_list(a_list): ..... Question 4 Write a function to return if the given year is a leap year. A leap year is divisible by 4, but not divisible by 100, unless it is also divisible by 400. The return should be boolean Type (true/false). def is_leap_year(a_year): ..... Question 5 Write a function to check to see if all numbers in list are consecutive numbers. For example, [2,3,4,5,6,7] are consecutive numbers, but [1,2,4,5] are not consecutive numbers. The return should be boolean Type. def…should be in python: write a function that receives a list as its only parameter. Inside the function remove all the duplicate items from the list and returns a new list and the input should be given by user. For Example: If we call the function with [“dad”, “aunt”, “mom”, “sister”, “mom”] as its user input, the returned value should be [“dad”, “aunt”, “mom”, “sister”]. The order of the items inside the returned list does not matter.
- 18) Write a function that takes in 2 lists and checks whether they have the same elements in the same order. If the elements are all the same, the function should return the string “same”. If any of the elements are different, the function should return the string “different”. The definition of the function should be: Def equals(a, b):Create a c++ shopping cart program using: linked list- - this will be used as the customer's cart. This is where the items that the customer will buy are placed before checking them out. Array - to store your store products. Pointers - since you will be using linked lists, it is imperative that you also will be using pointers. Functions - Make sure that your program will have user-defined functions (e.g.: function for adding nodes, function for displaying the cart, etc.) The menu options would be cout#include<stdio.h> #include<stdarg.h> void fun1(int num, ...); void fun2(int num, ...); int main() { fun1(1, "Apple", "Boys", "Cats", "Dogs"); fun2(2, 12, 13, 14); return 0; } void fun1(int num, ...) { char *str; va_list ptr; va_start(ptr, num); str = va_arg(ptr, char *); printf("%s ", str); } void fun2(int num, ...) { va_list ptr; va_start(ptr, num); num = va_arg(ptr, int); printf("%d", num); }.