Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Code: Linked list is one of the most important data structure. A linked list is a data structure that can store an indefinite amount

C++ Code:

Linked list is one of the most important data structure. A linked list is a data

structure that can store an indefinite amount of items. These items are connected

using pointers in a sequential manner. A linked list is made up of many nodes which

are connected in nature. Each node in linked list has two parts, one part is to hold

the data in the node and the other part contains the address of the next node in the

list. The first node in the list is called head node and the last node is called

the tail. Note that the last node doesnt point to any other node and just stores

null. The nodes are linked using pointers as shown in the image:

- Create a class called Node with two public members: data (int) and Node *next.

- Create a class called Linked_List which will contain all the data members and

functions required for a linked list.

- Create constructor for Linked_List to initialize head and tail pointers to null.

- Maintain two private data members *head and *tail pointers to store addresses of

head and tail nodes in the linked list.

- Create a public function Insert_Node(int data) to add a new node to linked list.

Note: maintain head and tail nodes appropriately.

- Create a public function Display_List() to display the contents stored in the

linked list.

- Now, extend the functionality of Linked_List class to add some more member

functions:

> Create a function called Insert_Front(int data) to add node at the front of

the linked list.

> Create a function called Insert_At(int position, int data) to add a new node

at a particular position in a linked list.

> Create a function called Delete_First(),Delete_Last()and

Delete_At(int position) to delete the first node, the last node or delete the

node at a particular position from the list respectively. Maintain head and

tail pointers accordingly.

image text in transcribed

Linked list is one of the most important data structure. A linked list is a data structure that can store an indefinite amount of items. These items are connected using pointers in a sequential manner. A linked list is made up of many nodes which are connected in nature. Each node in linked list has two parts, one part is to hold the data in the node and the other part contains the address of the next node in the list. The first node in the list is called 'head' node and the last node is called the 'tail'. Note that the last node doesn't point to any other node and just stores null. The nodes are linked using pointers as shown in the image: - Create a class called 'Node' with two public members: data (int) and Node *next. - Create a class called 'Linked List' which will contain all the data members and functions required for a linked list. - Create constructor for 'Linked Lista' to initialize head and tail pointers to null. - Maintain two private data members *head and *tail pointers to store addresses of head and tail nodes in the linked list. - Create a public function 'Insert Node(int data)' to add a new node to linked list. Note: maintain head and tail nodes appropriately. - Create a public function 'Display List [) to display the contents stored in the linked list. - Now, extend the functionality of 'Linked List' class to add some more member functions: > Create a function called 'Insect_Front(int data)' to add node at the front of the linked list. > Create a function called 'Insectatat(int position, int data)' to add a new node at a particular position in a linked list. > Create a function called 'Delete First(), Delete Last()and Delete At (int position)' to delete the first node, the last node or delete the node at a particular position from the list respectively. Maintain head and tail pointers accordingly

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Rules In Database Systems Third International Workshop Rids 97 Sk Vde Sweden June 26 28 1997 Proceedings Lncs 1312

Authors: Andreas Geppert ,Mikael Berndtsson

1997th Edition

3540635165, 978-3540635161

More Books

Students also viewed these Databases questions

Question

Explain the major limitations of the Dividend Discount Model.

Answered: 1 week ago

Question

D How will your group react to this revelation?

Answered: 1 week ago