Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

Write a program in Java to manipulate a Double Linked List:

 

  1. Count the number of nodes

  2. Insert a new node before the value 7 of Double Linked List

  3. Search an existing element in a Double linked list (the element of search

    is given by the user)

    Suppose List contained the following Test Data: Input the number of nodes : 4
    Input data for node 1 : 5
    Input data for node 2 : 6

    Input data for node 3 : 7 Input data for node 4: 9

Expert Solution
Check Mark
Step 1

Algorithm:

  1. Start
  2. Implement a class Node with attributes data,next which is pointing to next node and prev which is pointing to previous node
  3. Create a class LinkedList with head as its attribute.
  4. Implement constructor to Initialize the data 
  5. Implement a method addNode() which adds node to the linked list
  6. Implement a method searchNode() which searches for a node with particular data in the list. If the node is present in the list, print node is present else print node is not present
  7. Implement a function count() which prints the count of number of elements in the list
  8. Implement a function printList() which prints the list data
  9. Inside the main method, create object of LinkedList
  10. Read no.of elements in the list n
  11. Read n numbers add the data to list by calling addNode()
  12. Call count() which prints number of elements in the list
  13. Read the search data
  14. Call searchNode() by passing search data
  15. Stop
Knowledge Booster
Background pattern image
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education