Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Explain the code below (a) public void insertFront(Object item) { DListNode newNode = newNode(item, head, head.next); head.next.prev = newNode; head.next = newNode; size ++;

1. Explain the code below

(a) public void insertFront(Object item) { DListNode newNode = newNode(item, head, head.next); head.next.prev = newNode; head.next = newNode; size ++; } explain your design:

(b) public void insertBack(Object item) { DListNode newNode = newNode(item, head.prev, head); head.prev.next = newNode; head.prev = newNode; size ++; } explain your design:

(c) public DListNode front() { if(size != 0) { return head.next; } else { return null; } } explain your design:

(d) public DListNode back() { if(size != 0) { return head.prev; } else { return null; } } explain your design:

(e) public DListNode prev(DListNode node) { if( node == null || node.prev == head ) { return null; } else { return node.prev; } } explain your design:

(f) public DListNode next(DListNode node) { if( node == null || node.next == head) { return null; } else { return node.next; } } explain your design:

(g) public void insertAfter(Object item, DListNode node) { if(node != null) { DListNode insAfter_Node = newNode(item, node, node.next); node.next.prev = insAfter_Node; node.next = insAfter_Node; size ++; } } explain your design:

(h) public void insertBefore(Object item, DListNode node) { if(node != null) { DListNode insBefore_Node = newNode(item, node.prev, node); node.prev.next = insBefore_Node; node.prev = insBefore_Node; size ++; } } explain your design:

(i) public void remove(DListNode node) { node.prev.next = node.next; node.next.prev = node.prev; size --; } explain your design:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions