Starting out With C++, Early Objects - Access
Starting out With C++, Early Objects - Access
8th Edition
ISBN: 9780133452259
Author: GADDIS
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 17, Problem 14PC

Read , Sort , Merge

Using the ListNode structure of Program 17-2, write the following functions:

ListNode *read()

ListNode *sort(ListNode* list1)

ListNode *merge(ListNode* list1, ListNode* list2)

The first function reads a sequence of whitespace-separated positive numbers and forms the numbers read into a linked list of nodes. The input for a sequence of numbers is terminated by - 1. The second function sorts a linked list of nodes and returns a pointer to the head of the sorted lists. The function should sort by rearranging existing nodes, not by making copies of existing nodes. The third function merges two linked lists that are already sorted into a linked list that is also sorted. The merge function should not make copies of nodes: Rather, it must remove nodes from the two lists and form those nodes into a new list.

Test your functions by having the user enter two sequences of numbers, sorting each sequence, and then merging and printing the resulting list.

Blurred answer
Students have asked these similar questions
1. Write a program to reverse a singly or doubly linked list. (take data as int)2. Write a program to remove duplicates from a doubly linked list. (1,2,3,4,5,2) (you will remove the 2nd duplicate).3. Write a program to swap two data items in a doubly linked list. swap  number 2 and number 4 data with each other.  course--data structure in c++ perform all three parts in the one cpp file.
Please provide code in the form of SML language, read directions carefully One file will have the two functions in it, the other file will be a test file with calls to the functions to test that they work. Thank you for any help you can provide. Write a union function that takes two lists that are in order from smallest to largest and produces a list with a single copy of all elements from both lists. The resulting list must also be in order from smallest to largest. Write an intersection function much like union, but with the result containing only those elements that appear in both lists. All lists will be in order from smallest to largest.
Instructions are given within the quotations for each function.   1)def remove_duplicate_sorted(t): """ this function returns a new list generated from t that has t's elements without duplicates and is sorted from smallest to largest. """ return [] 2)def list_to_dictionary(t): """ t is a list of values (values could be str, list, tuple, set, dictionary), create and return a dictionary such that the key is len(v) for some v in t, and the value is a list of values [v1, v2, ...] from t (in the order they appeared in t) whose len(vi) is the key. for example: if t = [(1,2,3), "abc", [1, 2], (), ""] then return value of this function should be: {3: [(1, 2, 3), 'abc'], 2: [[1, 2]], 0: [(), '']} """ return {} 3)def run(): """ This function repeatedly ask user to enter a string and store them in a list and print it out. It also passes this list to remove_duplicate_sorted() function and list_to_dictionary() function and print out the results of the function calls. """ return if __name__ ==…
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Introduction to Linked List; Author: Neso Academy;https://www.youtube.com/watch?v=R9PTBwOzceo;License: Standard YouTube License, CC-BY
Linked list | Single, Double & Circular | Data Structures | Lec-23 | Bhanu Priya; Author: Education 4u;https://www.youtube.com/watch?v=IiL_wwFIuaA;License: Standard Youtube License