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

Public class DLL{

    public DLLNode first;

   public DLLNode last;

   public DLL()

         {this.first=Null;

          this.last=Null;}

Public void Display()

{if (first==Null)

       {s.o.p(“ the list is empty”);}

else

{for (DLLNode curr=first; curr!=Null; curr=curr.succ)

{System.out.println(“the element is”+ curr.element);

}}

Public void AddBegining(DLLNode Node)

{Node.succ=first;

First.prev=Node

First=Node;

Node.prev=Null;

if(first ==null && last==null)

Last=node;

}

Public void Append(DLLNode Node)

{Node.succ=Null;

 if(first==Null)

{first=Node;

Node.prev=Null}

 

Public void insetAfter(int obj, DLLNode Node)

{DLLNode curr=first;

    while((curr!=Null)&&( curr.element!=obj))

   { curr=curr.succ; }

 

If(curr.element==obj)

{Node.succ=curr.succ;

Curr.succ.prev=Node;

Curr.succ=Node;

Node.prev=curr;}

Else

System.out.println(“the element doesn’t exist”);

Public void delete(DLLNode del)

{

  if(first==Null)

  {System.out.println(“the list is empty”); }

Else if(del==first)

 {first==del.succ;}

Else if(del.succ==Null)

  first=Null;

   last=Null;

Else

{DLLNode ptr= first;

while(ptr.succ!=del)

{Ptr=ptr.succ;}

Public class DLLNode{

  int element;

  DLLNode prev;

  DLLNode succ;

Public DLLNode(int E)

{this. Element=E;

This. prev=Null;

This.succ=Null}

Public static void main(String args[])

{DLL list = new DLL();

Scanner s = new Scanner(System.in);

Int X,Y,Size;

DLLNode Node1= new DLLNode(5);

DLLNode Node2= new DLLNode(6);

DLLNode Node3= new DLLNode(7);

DLLNode Node4= new DLLNode(9);

list.AddBegining(Node1);

list.Append(Node2);

list.Append(Node3);

list.Append(Node4);

list.Display();

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
Knowledge Booster
Background pattern image
Similar questions
SEE MORE 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