Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
In OCaml
val prime_separator : int list -> int list * int list = <fun>
that takes an integer list as an input, and returns a pair of integer lists where the prime numbers are in the first while the composite numbers are in the second returned list.
#prime_separator [1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11];;
- : int list * int list = ([11; 7; 5; 3; 2], [10; 9; 8; 6; 4; 1]
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- This function finds the minimum number in a list. What should be replaced with in order for this function to operate as expected? function min(numList){ numList[0]; for(var i=0; i return min; numList[i] = min; min = numList[i]; min numList; numList min; i Het Which ofthese fu nction s deos this thearrow_forwardstruct insert_at_back_of_sll { // Function takes a constant Book as a parameter, inserts that book at the // back of a singly linked list, and returns nothing. void operator()(const Book& book) { /// TO-DO (3) /// // Write the lines of code to insert "book" at the back of "my_sll". Since // the SLL has no size() function and no tail pointer, you must walk the // list looking for the last node. // // HINT: Do not attempt to insert after "my_sll.end()". // ///// END-T0-DO (3) ||||// } std::forward_list& my_sll; };arrow_forwardWrite a function sum_alt that takes a list of numbers zand calculates their alternating sum, defined as n-1 Σ(-1)+1 zk. k=0 Here Zo, Z1, Zn-1 denote the individual elements of the list.arrow_forward
- Create a user-defined function called duplicates. This function will check to see if a singly linked list contains nodes with the same data stored. If any duplicates are found, return the value 1. Otherwise return 0. You may use the following typedef structure. typedef struct node_s{ int data; struct node_s * nextptr; }node_t;arrow_forward1. Write a function invert_dict to reverse a dictionary, for example: >>> eng2sp = {'one': 'uno', 'two': 'dos', 'three': 'tres'} >>> sp2eng = invert_dict(eng2sp) >>> sp2eng {'uno':'one', 'dos':'two', 'tres':'three'} 2. Write a function print_dict to print all the key-values in a dictionary, for example: >>> d2 {'a': 'one', 'b': 'two', 'c': 'Three'} >>> print_dict(d2) a:one b:two c:Threearrow_forwardin c++arrow_forward
- Consider the following function access_element_by_index that returns the iterator to the element at the index i in the list l. typedef std::list<int> int_list; int_list::iterator access_element_by_index(size_t I, int_list &) { assert( ? ); … } Assume the first element of the list is at the index 0, the second at the index 1, and so on. If the function is required to return an iterator that can be dereferenced, determine the precondition of the function, and write an assertion to validate it. (You don’t need to implement the functions).arrow_forwardC++ The List class represents a linked list of dynamically allocated elements. The list has only one member variable head which is a pointer that leads to the first element. See the following code for the destructor to List. ~ List () { for (int i = 0; i <size (); i ++) { pop_back (); } } What problems does the destructor have? Select one or more options: 1. There are no parameters for the destructor. 2. The return value from pop_back (if any) is nerver handled. 3. The destructor will create a stack overflow. 4. The destructor will create dangling pointers. 5.The destructor will create memory leaks. 6.The destructor will create undefined behavior (equivalent to zero pointer exception). 7.The condition must be: i <size () - 1 8. There is at least one problem with the destructor, but none of the above.arrow_forwardReplace XXX in the following function header for a doubly-linked list: ListInsertAfter(listName, currentNode, XXX) Group of answer choices headNode tailNode middleNode newNodearrow_forward
- program Linked List: modify the following program to make a node containing data values of int, char, and string. #include <iostream> using namespace std; struct node { int data; struct Node *next; }; struct Node* head = nullptr;//or Null or 0; void insert(int new_data) { struct Node* new_node=(struct Node*) new(struct Node); new_mode->data=new_data; new_mode->next=head; head=new_node; } void display() { struct Node* ptr; ptr=head; while(ptr ! = NULL) { cout<<ptr->data<<""; ptr=ptr->next; } } int main() { insert{2}; display{}; return0; }arrow_forwardPascal triangle! write a function(in OCaml) val nextpascalrow : int list -> int list = that given a list of integers that correspond to a row of the pascal triangle, it calculates the next row of the pascal triangle. # nextpascalrow [1; 6; 15; 20; 15; 6; 1];; - : int list = [1; 7; 21; 35; 35; 21; 7; 1]arrow_forwardMake List Items Uppercase 2 in python Define the function make_uppercase(mylist), which takes a list parameter mylist (a list of strings), mutates the list by uppercasing each string in mylist. The function returns None. For example, if mylist is ['cat', 'Dog', 'frOG'], then the mutated list should be ['CAT', 'DOG', 'FROG']. For example: Test Result mylist = ['cat', 'Dog', 'frOG'] result = make_uppercase(mylist) print(mylist) if result != None: print("Error, return value should be None") ['CAT', 'DOG', 'FROG'] mylist = ['baNanas', 'appLes', 'pEAches', 'PEArs'] result = make_uppercase(mylist) print(mylist) if result != None: print("Error, return value should be None") ['BANANAS', 'APPLES', 'PEACHES', 'PEARS']arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education