Write these functions in ML(SML) : Write a function dup to double each element of an integer list. One function only. dup([2,3,5]) → [2,2,3,3,5,5] Write a function dups to double each char of a string. Recursion must on list not string. dups("aabc") → "aaaabbcc" Write a function mid to keep elements of an integer list between 5 and 10. One function only. mid [12,3,6,4,5,1] → [6,5]
Q: ADT stands for abstract data type, in which the actual implementation does not play a role. Select…
A: Answer : thee correct options are : Both the stack ADT and the queue ADT are dictionaries . A queue…
Q: Write a C++ program to perform the following. a. Add a node at the end of singly linked list. b.…
A: a. Traverse the list till the end and add new node with given data in the list. b. To remove element…
Q: Define function sumProduct that receives a list of numbers and returns a pair, where the first…
A: Logic:- define function sumProduct which takes lst as parameter. Set sum=0, product =1 Iterate for…
Q: In OCaml Programming Language: Use the built-in higher order functions and write a non-recursive…
A: Given: In OCaml Programming Language: Use the built-in higher order functions and write a…
Q: C++, Write a recursion function that counts the positive elements multiple of 5 in a binary search…
A: //make f1 and f2 as class variable and initialize with 0 int traverse(struct node *root) { if…
Q: his in C++ 3: Write a program for Queue operation with a Queue containing only float type elements.…
A: c++ program is as given below :
Q: n C program. /* * dataStructure.h * * Provides a data structure made of a doubly-headed…
A: The question is asking me add a function to append a new element to a linked list. The answer is…
Q: Write a C program by using the Singly Linked List technique that will take an integer value as input…
A: Below is the program implementation of above in C language. NOTE: To remove second last, one utility…
Q: A list is either empty or it consists of two parts: the first element which is a (head) and a tail,…
A: b. Merge two lists generating an ordered list. list1 = [5,6,7]list2 = [1, 2, 3]list3 = list1 +…
Q: Code in C++ Implement Doubly Linked List class storing information about student name, course name…
A: Code:- #include <iostream>using namespace std;struct Node { string…
Q: Write a function that will duplicate every list element using recursion. Example: List: ['I',…
A: Based on Python
Q: Write a C++ program to simulate the working of queues using an array
A: Program: // C++ program to simulate the working of queues using an array#include…
Q: Code this in C program A set of integers 0..MAX may be implemented using an array of boolean…
A: Bitset Array Bitset array is also called bit array or bit map or bit vector which stores bit at each…
Q: write the following function in prolog. Implement predicate mergesort. to sort a given list.…
A: So ,we are going to write a prolog program to implemnt merge sort.
Q: OCAML programming language Cartesian map Use the built-in higher order functions and write a…
A: 1. The power of functions here cannot be better illustrated.2. create a function power.3.The nth…
Q: function to delete all the elements of a single linked list. The function should be recursive.
A: The following is the program :
Q: (Cartesian Map) In OCaml Programming Language: Use the built-in higher order functions and write a…
A: Given: (Cartesian Map) In OCaml Programming Language: Use the built-in higher order functions and…
Q: Recursion and list processing Write a maxel that returns the maximum element in an arbitrarily…
A: Code: maxel=[[7,9],[22,33,44],[4,5],[77,8]]print("Maximum Value:",max(maxel))
Q: write a C programme in C language 9. (a) Sort the following data diagrammatically in descending…
A: As per guidelines, first question will be solved please upload another question again. Heap is known…
Q: pseudo code subprogram to print all the elements from the nth element to the last one in a linked…
A: //To find the length of the linked list set length =0 while (cur!=NULL) cur=cur->Next…
Q: a list -> ’a list -> ’a list = that, given 2 lists, returns a third, containing elements of the…
A: I have posted the code and screenshot of sample run below. I have also added comments to make it…
Q: Need help with sml languege I need to write a binarySearch function that recursively implements the…
A: 1) Linear Search #include <iostream> using namespace std; //i= starting, j=lenght of array, x=…
Q: Turn the linked list implementation into a circular list: Have the previous pointer of the first…
A: In a circular linked list the node of the last hold the address of the first node hence forming…
Q: Write a function sort_and_return_in_pairs_list for example: [12, 13, 11, 15] return =>(11.12) and…
A: Write a function sort_and_return_in_pairs_list for example:[12, 13, 11, 15] return =>(11.12) and…
Q: Exercis • Derive a recursive Python function to create a list containing the values ranging from 0…
A:
Q: Need help with standard ML languege I need to write a binarySearch function that recursively…
A: write a binarySearch function that recursively implements the binary search algorithm to search a…
Q: 1. Write a C program that will initially create a SORTED list containing the following and then run…
A: Please find the program next step.
Q: Write a C++ program that implements a linked list as an abstract data type. The program must: Be…
A: PROGRAM STRUCTURE: Include all the required header files. Write the definition of the structure to…
Q: Write a function in C++ that adds two nodes at the end of the singly link list Like add two nodes…
A: Disclaimer: “Since you have asked multiple questions, we will solve the first question for you. If…
Q: create a double linked list based c++ program which will be contact managment system. there will be…
A: Below given code is the required code:
Q: A list of int values can be defined recursively as: a list item, a comma, and a list, where a list…
A: Defined the given statement true or false
Q: Write programs to do BFS and DFS traverse of the graph, based on the adjacent list structure. By…
A: To wite a Java program to print BFS traversal from a given source vertex .BFS(int s) traverses…
Q: Write a recursive function sumlist(my_list) to calculate the sum of the numbers in a list my_list…
A: #recursive function to find and return sum of numbers in the listdef sumlist(my_list): if…
Q: Define a recursive function named trim; it takes as its arguments a linked list (the head node of…
A: Actually, python is a easiest programming language. It is a dynamically typed programming language.…
Q: Write a program to implement Singly Linked List in C++ using Class Template: 1. Create a C++…
A: ALGORITHM: Step 1:Create a class node. Initialize the variable data Step 2: The head of a list and…
Q: def reverse_list (1st: List [Any], start: int, end: int) -> None: """Reverse the order of the items…
A: The above question is solved in step 2 :-
Q: Perl Program: It is given to the same members containing n whole numbers. You have to switch to…
A: In this problem, we need to solve the above programming problem. For this problem, I have used the…
Q: Using a doubly-linked list, implement a dictionary data structure in C. Include dictionary.c and a…
A: #include <stdio.h>#include <stdlib.h>#include "dictionary.h"/*requirements= delete(key),…
Q: The advantage of circular arrays for queues raises the question: Would the circularly-linked list…
A: Basics An array is a collection of the items stored in contiguous memory locations. The idea is to…
Q: Let L is a list object of integers, write a recursive function that returns the sum of L items…
A: Definition: Recursive function: It is a function which is used for calling of itself at the time of…
Q: write the following program using simply linked list in C++ language Add definition of the…
A: Since you have posted a question with multiple sub-parts, we will solve the first three sub-parts…
Q: Need help with SML/ML/MPL I need to write binarySearch function that recursively implements the…
A: C++ code for Binary search tree #include <bits/stdc++.h>using namespace std; int…
Q: Write a C program for the following . 2. Given a singly linked list L, create a function to split…
A: #include<stdio.h>#include<stdlib.h> struct node{ int info; struct node…
Q: Which data structure would you most likely see in a non-recursive implementation of a recursive…
A: Which data structure would you most likely see in a non-recursive implementation of a recursive…
Q: Write a function dup to double each element of an integer list. One function only. dup([2,3,5]) →…
A: NOTE: Since the problem doesn't include the programming language use to code the problem so I am…
Q: Practice recursion on lists Practice multiple base conditions Combine recursion call with and,or not…
A: Solution :: Lets see the above question in python programming .. Code :: def recursive_search(aList,…
Q: 6. Write a function DOT-PRODUCT that takes two lists, each list has the same number of elements, and…
A: 6. Write a function DOT-PRODUCT that takes two lists, each list has the same numberof elements, and…
Q: Write a LISP function f10 that finds the intersection of two lists. The intersection means the…
A: (defun f10 (lst-a lst-b &aux result) (dolist (a lst-a (nreverse result)) (dolist (b lst-b)…
Q: write the following program using simply linked list in C++ language Add definition of the…
A: Since you have posted a question with multiple sub-parts, we will solve the first three sub-parts…
Write these in SML
- Write these functions in ML(SML) :
- Write a function dup to double each element of an integer list. One function only.
dup([2,3,5]) → [2,2,3,3,5,5] - Write a function dups to double each char of a string. Recursion must on list not string.
dups("aabc") → "aaaabbcc" - Write a function mid to keep elements of an integer list between 5 and 10. One function only.
mid [12,3,6,4,5,1] → [6,5]
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- Define the function (doubleBubbleLst lst). This function should resolve to a list of sublists, where each sublist holds a single element from lst and all sublists from lst are also bubbled, so that every list and sublist has no atoms. This is the deep recursion version of bubbleLst. For example: (doubleBubbleLst '(1 2 (3 4)) ) resolves to '((1) (2) (( (3) (4) ))).Haskell Define a recursive function "merge :: Ord a => [a] -> [a] -> [a]" that merges two sorted lists to give a single sorted list. For example: > merge [2,5,6] [1,3,4] [1,2,3,4,5,6] Note: your definition should not use other functions on sorted lists such as "insert" or "isort", but should be defined using explicit recursion.1. a function that takes in a list (L), and creates a copy of L. note: The function should return a pointer to the first element in the new L. [iteration and recursion]. 2. a function that takes in 2 sorted linked lists, and merges them into a single sorted list. note: This must be done in-place, and it must run in O(n+m).
- Write a function in a racket code that takes as input a list of elements and returns a list with elements and their position after. For example, if the input to the function is (list ’a ’b ’c) then it will return (list a 1 b 2 c 3). Make sure to use recursion(C Program) Write a recursive function called PrintLinkedList() that outputs the integer value of each node in a linked list. Function PrintLinkedList() has one parameter, the head node of a list. The main program reads the size of the linked list, followed by the values in the list. Assume the linked list has at least 1 node.Define a recursive function named trim; it takes as its arguments a linked list (the head node of it) and a non-negative integer representing the index of an element in the list. The function mutates the linked list such that all elements that occur after the index is removed. Additionally, the function returns a linked list of all the elements that were moved. If the index value exceeds the length of the linked list, it should raise an IndexError. For example, if we defined a list as l1 = LN(1, LN(2, LN 3))) , calling the function would return the linked list LN(2, LN(3)), and the mutated l1 would become LN(1). You must use recursion. def trim(l: LN, index: int) -> LN:
- Need help with sml languege I need to write a binarySearch function that recursively implements the binary search algorithm to search a sorted integer list for a specified integer and returns true if it is found, false otherwise. For example, binarySearch ([100,200,300,400,500], 200) returns true, whereas binarySearch([100,200,300,400,500], 299) returns false. Hint: Write a helper function mid that returns a tuple (index, value) representing the middle value in a list. For example, mid [10, 2, 40, 8, 22] returns (2,40) because the value 40 at index 2 is the middle value in the list. Similarly, mid [10, 20] would return (1, 20). Use mid in conjunction with slice to implement binarySearch. Here is my slice function: fun count(index,hd::tl,start,stop) =if index+1 >= stop then hd::nilelse if index >= start then hd::count(index+1,tl,start,stop)else count(index+1,tl,start,stop);fun slice(x::y, start, stop) = count(0,x::y,start,stop); And here is the dummy implementation of binary…Question 1 write a curried SML function, filter, that takes two arguments, a predicate ( a function that takes a single argument and returns a bool) and a list. Calling filter f L returns a list containing only those elements of L that satisfy f (that is, only those elements that f returns true for are in the resulting list). Calling filter with an empty list returns an empty list. List members should appear in the same order in the results as in L. Do not use explicit recursion Full explain this question and text typing work only thanksThis is to be done in ML coding language. Please provide the actual code (with an output). Try and keep the code as simple as possible. Define a function rem_duplicate: ''a list -> ''a list whichtakes in input a list and removes all the duplicates. Test your code with sampleinput and report result. Examples: rem_duplicate [] = [] rem_duplicate [1,2,1] = [1,2] rem_duplicate ["a","a","a"] = ["a"] rem_duplicate [[1],[1,2],[1,2,3],[1,2],[4,5]] = [[1],[1,2],[1,2,3],[4,5]]
- Need help with standard ML languege I need to write a binarySearch function that recursively implements the binary search algorithm to search a sorted integer list for a specified integer and returns true if it is found, false otherwise. For example, binarySearch ([100,200,300,400,500], 200) returns true, whereas binarySearch([100,200,300,400,500], 299) returns false. Hint: Write a helper function mid that returns a tuple (index, value) representing the middle value in a list. For example, mid [10, 2, 40, 8, 22] returns (2,40) because the value 40 at index 2 is the middle value in the list. Similarly, mid [10, 20] would return (1, 20). Use mid in conjunction with slice to implement binarySearch.Implement the following functions in Scheme using the functions map and/or foldl. DO NOT use recursive definition for this problem. Define a function leq, which takes two lists of numbers (x1,x2,…,xn),(y1,y2,…,yn) and returns \#t if and only if x i≤y if or all 1≤i≤n. You can assume that the two lists have the same length.Haskell Using "merge", define a function "msort :: Ord a => [a] -> [a]" that implements "merge sort", in which the empty list and singleton lists are already sorted, and any other list is sorted by merging together the two lists that result from sorting the two halves of the list separately. Hint: first define a function "halve :: [a] -> (a],[a])" that splits a list into two halves whose lengths differ by at most one.