1 public class DNode{ public int value; public DNode next, prev: public DNode (int val) ( this.value - val; 35 36 37 38 39 10 public void metod3 (int x){ if (head - null) head = new DNode (x): else( DNode temp - new DNode (x) : temp.next = head; temp.prev - head.prev; head.prev = temp; temp.prev.next - temp; head - temp; 6 this.next = this: It 11 12 this.prev =- this:} 8 ) 9 class DoublyLinkedList{ 10 11 12 13 14 15 list"); 16 17 18 19 20 21 22 23 13 14 15 16 17 18 19 50 51 52 53 public DNode head-null; public void metodl () { if (head - null) system.out.println("Empty public void metod4 () ( DNode iterator - head.prev; system.out.println (head.prev.value) : while (iterator !- head.prev) ( else if (head.next -- head) { head - null; else( head = head.next:} 54 system.out.printin (iterator.value); iterator - iterator.prev: 56 57 58 59 public void metod2 (int x) { DNode temp - new DNode (x) ; DNode iterator - head; while (iterator.next !- head) iterator - iterator.next: iterator.next - temp; temp.prev - iterator: head.prev temp: temp.next = head: static void Main (String 0 args) { DoublyLinkedList db - new 25 26 27 28 29 30 31 32 33 34 50 DoublyLinkedList () ; db.metod3 (8) : db.metod3 (2) ; db.metod2 (9): db.metod3 (4); db.metod2 (10): db.metodl (): db.metod4 () : 51 52 57 58

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
What is the output of the following program? Add necessary comments(like what each method does) to the program before answering the question. You can state the line number and then your comment. (since you will not be able to write your comments onto
this code)
1 public class DNode{
public int value;
public DNode next, prev:
35
36
37
38
39
10
11
12
13
14
15
public void metod3 (int x) {
if (head == null)
3
public DNode (int val) (
this.value = val;
this.next = this;
head = new DNode (x) ;
else(
DNode temp = new DNode (x);
temp.next = head;
temp.prev - head.prev;
head.prev =- temp;
temp.prev.next - temp;
head - temp;
this.prev = this;}
8 }
9 class DoublyLinkedList{
10
11
12
13
14
15 list");
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
public DNode head-null;
16
17
18
19
50
51
52
53
54 system.out.println (iterator.value);
public void metodl () {
if (head -- null)
System.out.println ("Empty
public void metod4 () {
DNode iterator = head.prev;
system.out.println (head.prev.value);
while (iterator != head.prev) (
else if (head.next == head) {
head = null;
else{
head = head.next:}
}
iterator - iterator.prev;
public void metod2 (int x) {
DNode temp - new DNode (x) ;
DNode iterator - head;
while (iterator.next !- head)
iterator - iterator.next;
56
57
58
59
50 DoublyLinkedList ();
51
52
53
static void Main (String(] args) {
DoublyLinkedList db = new
iterator.next = temp;
temp.prev = iterator:
head.prev = temp;
temp.next = head;
}
db.metod3 (8);
db.metod3 (2);
db.metod2 (9);
db.metod3 (4);
db.metod2 (10);
db.metodl ();
db.metod4 () ;
57
58
Transcribed Image Text:What is the output of the following program? Add necessary comments(like what each method does) to the program before answering the question. You can state the line number and then your comment. (since you will not be able to write your comments onto this code) 1 public class DNode{ public int value; public DNode next, prev: 35 36 37 38 39 10 11 12 13 14 15 public void metod3 (int x) { if (head == null) 3 public DNode (int val) ( this.value = val; this.next = this; head = new DNode (x) ; else( DNode temp = new DNode (x); temp.next = head; temp.prev - head.prev; head.prev =- temp; temp.prev.next - temp; head - temp; this.prev = this;} 8 } 9 class DoublyLinkedList{ 10 11 12 13 14 15 list"); 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 public DNode head-null; 16 17 18 19 50 51 52 53 54 system.out.println (iterator.value); public void metodl () { if (head -- null) System.out.println ("Empty public void metod4 () { DNode iterator = head.prev; system.out.println (head.prev.value); while (iterator != head.prev) ( else if (head.next == head) { head = null; else{ head = head.next:} } iterator - iterator.prev; public void metod2 (int x) { DNode temp - new DNode (x) ; DNode iterator - head; while (iterator.next !- head) iterator - iterator.next; 56 57 58 59 50 DoublyLinkedList (); 51 52 53 static void Main (String(] args) { DoublyLinkedList db = new iterator.next = temp; temp.prev = iterator: head.prev = temp; temp.next = head; } db.metod3 (8); db.metod3 (2); db.metod2 (9); db.metod3 (4); db.metod2 (10); db.metodl (); db.metod4 () ; 57 58
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY