In a doubly linked list the first class is Node which we can create a new node with a given element. Its constructor also includes previous node reference prev and next node reference next. make a node object for the new element. Check if the index >= 0. If index is 0, make new node as head; else, make a temp node and iterate to the node previous to the index. If the previous node is not null, adjust the prev and next references. Print a message when the previous node is null.   implement these 3 methods: insert_at_index(), delete_at_end(), display(). use these three functions above use this to name the items

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

In a doubly linked list the first class is Node which we can create a new node with a given element. Its constructor also includes previous node reference prev and next node reference next.

make a node object for the new element. Check if the index >= 0.
If index is 0, make new node as head; else, make a temp node and iterate to the node previous to the index.
If the previous node is not null, adjust the prev and next references. Print a message when the previous node is null.

 

implement these 3 methods: insert_at_index(), delete_at_end(), display(). use these three functions above

use this to name the items

1. insert_to_empty_list()
2. insert_to_end()
3. insert_at_index()

4. delete_at_start()

5. delete_at_end() .

6. display()

let the output be

OUTPUT:

The list is empty
Element is: 3
Element is: 10
Element is: 20
Element is: 30
Element is: 35
Element is: 38
Element is: 40
Element is: 50
Element is: 60


Element is: 10
Element is: 20
Element is: 30
Element is: 35
Element is: 38
Element is: 40
Element is: 50

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Operations 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
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education