write the following program using simply linked list in C++ language Add definition of the following functions into a simply linked list:  1) Insert before tail :  Insert a value into a simply linked list, such that it's location will be before tail.   So if a list contains {1, 2, 3}, insert before tail value 9 is called, the list will become {1, 2, 9, 3}.   2) Insert before value :  Insert a value into a simply linked list, such that it's location will be before a particular value.   So if a list contains {1, 2, 3}, insert before 2 value 9 is called, the list will become {1, 9, 2, 3}.   3)Count common elements : Count common values between two simply linked lists.  So if a list1 contains {1, 2, 3, 4, 5}, and list2 contains {1, 3, 4, 6}, number of common elements is 3.   4) Check if sorted : Check if elements of simply linked lists are sorted in ascending order or not. So if a list contains {1, 3, 7, 8, 9} its sorted, but if a list contains {1, 3, 7, 2, 5} its not sorted.   5) Find sublist  : Find and return sublist in a list, the start and stop positions indicate where the sublist starts and where it ends. So if a list contains {1, 3, 7, 8, 9}, sublist at start 2 and stop 4 is {3, 7, 8} .

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section7.5: Case Studies
Problem 3E
icon
Related questions
icon
Concept explainers
Question

write the following program using simply linked list in C++ language

Add definition of the following functions into a simply linked list:

 1) Insert before tail :  Insert a value into a simply linked list, such that it's location will be before tail.   So if a list contains {1, 2, 3}, insert before tail value 9 is called, the list will become {1, 2, 9, 3}.  

2) Insert before value :  Insert a value into a simply linked list, such that it's location will be before a particular value.   So if a list contains {1, 2, 3}, insert before 2 value 9 is called, the list will become {1, 9, 2, 3}.  

3)Count common elements : Count common values between two simply linked lists.  So if a list1 contains {1, 2, 3, 4, 5}, and list2 contains {1, 3, 4, 6}, number of common elements is 3.  

4) Check if sorted : Check if elements of simply linked lists are sorted in ascending order or not. So if a list contains {1, 3, 7, 8, 9} its sorted, but if a list contains {1, 3, 7, 2, 5} its not sorted.  

5) Find sublist  : Find and return sublist in a list, the start and stop positions indicate where the sublist starts and where it ends.
So if a list contains {1, 3, 7, 8, 9}, sublist at start 2 and stop 4 is {3, 7, 8} .

Expert Solution
steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Types of Linked List
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
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning