Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming language: Java //DLL.java //**************************** DLL.java ******************************* // generic doubly linked list class public class DLL { private DLLNode head, tail; public DLL() { head

image text in transcribed

Programming language: Java

//DLL.java

//**************************** DLL.java ******************************* // generic doubly linked list class

public class DLL { private DLLNode head, tail; public DLL() { head = tail = null; } public boolean isEmpty() { return head == null; } public void setToNull() { head = tail = null; } public T firstEl() { if (head != null) return head.info; else return null; } public void addToHead(T el) { if (head != null) { head = new DLLNode(el,head,null); head.next.prev = head; } else head = tail = new DLLNode(el); } public void addToTail(T el) { if (tail != null) { tail = new DLLNode(el,null,tail); tail.prev.next = tail; } else head = tail = new DLLNode(el); } public T deleteFromHead() { if (isEmpty()) return null; T el = head.info; if (head == tail) // if only one node on the list; head = tail = null; else { // if more than one node in the list; head = head.next; head.prev = null; } return el; } public T deleteFromTail() { if (isEmpty()) return null; T el = tail.info; if (head == tail) // if only one node on the list; head = tail = null; else { // if more than one node in the list; tail = tail.prev; tail.next = null; } return el; } public void printAll() { for (DLLNode tmp = head; tmp != null; tmp = tmp.next) System.out.print(tmp.info + " "); } public T find(T el) { DLLNode tmp; for (tmp = head; tmp != null && !tmp.info.equals(el); tmp = tmp.next); if (tmp == null) return null; else return tmp.info; } }

//DLLNode.java

public class DLLNode { public T info; public DLLNode next, prev; public DLLNode() { next = null; prev = null; } public DLLNode(T el) { info = el; next = null; prev = null; } public DLLNode(T el, DLLNode n, DLLNode p) { info = el; next = n; prev = p; } }

3.11 PROGRAMMING ASSIGNMENTS 1. Farey fractions of level one are defined as sequence (, ). This sequence is extended in level two to form a sequence (1, 1, 1), sequence (1, 3, 2, 3, 1) at level three, sequence Use Doubly (313, 31) at level four, so that at each level n, a new fraction at is inserted Linked Lists for this between two neighbor fractions and only if c + ds n. Write a program that for a exercise number n entered by the user createsby constantly extending ita linked list of fractions at level n and then displays them. 3.11 PROGRAMMING ASSIGNMENTS 1. Farey fractions of level one are defined as sequence (, ). This sequence is extended in level two to form a sequence (1, 1, 1), sequence (1, 3, 2, 3, 1) at level three, sequence Use Doubly (313, 31) at level four, so that at each level n, a new fraction at is inserted Linked Lists for this between two neighbor fractions and only if c + ds n. Write a program that for a exercise number n entered by the user createsby constantly extending ita linked list of fractions at level n and then displays them

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

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions