1. Assume you have the following singly linked List of integers and the method printLL(): Head ↓ void printList(){ for (Node c=head; c!=null; c=c.next) System.out.print(c.data+" "); System.out.println(); } What will the method printLL() display after execute the following code: Node p=head; Node q = p.next; p.next= q.next; p.next.next = q; q.next=null; 2. Assume you have the following singly linked List of integers and the method printLL(): head void printList(){ for (Node c=head; cl=null; c=c.next) System.out.print(c.data+" "); System.out.println(); } What will the method printLL() display after execute the following code: 1. p=q; 2. p.data q.data; 3. p.next q.next; 4. p.next = null;

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
i need the answer quickly
1. Assume you have the following singly linked List of integers and the method
printLL():
Head
↓
next
void printList(){
1
4
+
null
for (Node c-head; c!=null; c=c.next)
System.out.print(c.data+" ");
System.out.println(); }
What will the method printLL() display after execute the following code:
Node p=head;
Node q = p.next;
p.next= q.next;
p.next.nextq;
q.next=null;
2. Assume you have the following singly linked List of integers and the method
printLL():
head
Р
q
void printList(){
null
for (Node c-head; c!=null; c=c.next),
System.out.print(c.data+" ");
System.out.println(); }
What will the method printLL() display after execute the following code:
1. p=q;
2. p.data q.data;
3. p.next = q.next;
4. p.next = null;
3.
void printDLL(){
for (DNode p-head; p!=null; p=p.next)
System.out.print(p.data + " ");
System.out.println();
}
Suppose you have the following doubly linked list:
head
↓
{
prev
next
prev
next
prev
+
1
next
prev
4
null
null
void RprintDLL(){
DNode p;
for (p=head; p.next!=null; p=p.next){}
for (; p!=null; p=p.prev)
System.out.print(p.data + " ");
System.out.println(); }
What will the two methods printDLL() and RprintDLL() after execute each the
following points:
1. temp = p.next.data;
2. c=head;
p.next.data = head.data;
p.next.next= head;
head.data= temp;
head.next.prev=null;
temp = p.data;
p.data = head.next.data;
head.next.data = temp;
head.prev=p.next;
head-head.next;
c.next=null;
p.next.prev=null;
3. head=p.next;
2
4. p=null;
next
3
5. head=null;
head = p;
Transcribed Image Text:1. Assume you have the following singly linked List of integers and the method printLL(): Head ↓ next void printList(){ 1 4 + null for (Node c-head; c!=null; c=c.next) System.out.print(c.data+" "); System.out.println(); } What will the method printLL() display after execute the following code: Node p=head; Node q = p.next; p.next= q.next; p.next.nextq; q.next=null; 2. Assume you have the following singly linked List of integers and the method printLL(): head Р q void printList(){ null for (Node c-head; c!=null; c=c.next), System.out.print(c.data+" "); System.out.println(); } What will the method printLL() display after execute the following code: 1. p=q; 2. p.data q.data; 3. p.next = q.next; 4. p.next = null; 3. void printDLL(){ for (DNode p-head; p!=null; p=p.next) System.out.print(p.data + " "); System.out.println(); } Suppose you have the following doubly linked list: head ↓ { prev next prev next prev + 1 next prev 4 null null void RprintDLL(){ DNode p; for (p=head; p.next!=null; p=p.next){} for (; p!=null; p=p.prev) System.out.print(p.data + " "); System.out.println(); } What will the two methods printDLL() and RprintDLL() after execute each the following points: 1. temp = p.next.data; 2. c=head; p.next.data = head.data; p.next.next= head; head.data= temp; head.next.prev=null; temp = p.data; p.data = head.next.data; head.next.data = temp; head.prev=p.next; head-head.next; c.next=null; p.next.prev=null; 3. head=p.next; 2 4. p=null; next 3 5. head=null; head = p;
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