Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

You will be required to implement one of three types of Linked List: Singly Linked List Doubly LinkedList Circular Linked List Your Linked List must

You will be required to implement one of three types of Linked List:

Singly Linked List

Doubly LinkedList

Circular Linked List

Your Linked List must be comprised of Nodes. A Node may be implemented as either a struct or a class, and must contain only pointers and the users data. Your Linked List must have a Head pointer, and may need a Tail pointer depending on the type. You may not use any of the containers or algorithms from the STL or Boost libraries in implementing your Linked List or its functionality.

FUNCTIONALITY

Calculate and output the product of every second/third/fourth data element

Example:

  • Assume the linked list (singly, doubly or circular) contains the elements 10, 2, 3, 4, 5, 6in that order
  • The product of every second element: 48(2*4*6=48)
  • The product of every third element: 18 (3*6=18)
  • The product of every fourth element: 4 (4=4)

Calculate and output the total of all data elements such that data elements at even positions are added to the total and elements at odd positions are subtracted from the total

Example

  • Assume the linked list (singly, doubly or circular) contains the elements 10, 2, 3, 4, 5, 6 in that order
  • Indexing begins at 0, so 10 is at position 0, 2 is at position 1, etc
  • The value output is 6 (10-2+3-4+5-6=6)

Calculate and output the average of all data elements

Example:

  • Assume the linked list (singly, doubly or circular) contains the elements 10, 2, 3, 4, 5, 6 in that order
  • The value output is 5 ( (10+2+3+4+5+6)/6=5)

Reverse the current order of the data elements

Example:

  • Assume the linked list (singly, doubly or circular) contains the elements 10, 2, 3, 4, 5, 6 in that order
  • The elements should be reordered to 6, 5, 4, 3, 2, 10 in that order

Remove all duplicate data elements

Example:

  • Assume the linked list (singly, doubly or circular) contains the elements 4,5,5,6,6in that order
  • the resulting linked list should contain 4,5,6in that order Count and output the total number of data elements.

Example:

  • Assume the linked list (singly, doubly or circular) contains the elements 10, 2, 3, 4, 5, 6 in that order
  • the value output is 6

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started