SlideShare a Scribd company logo
SOURCE CODE:
import java.util.Iterator;
public class CircularLinkedList implements Iterable {
Node head , tail;
int size;
CircularLinkedList() {
head = null;
tail = null;
size = 0;
}
public boolean add(E e) {
Node ele = new Node(e);
ele.next = head;
if(head == null)
{
head = ele;
ele.next = head;
tail = head;
}
else
{
tail.next = ele;
tail = ele;
}
size++;
return true;
}
public boolean add(int index, E e){
Node ele = new Node(e);
Node ptr = head;
index = index - 1 ;
for (int i = 1; i < size - 1; i++)
{
if (i == index)
{
Node tmp = ptr.next;
ptr.next = ele;
ele.next = tmp;
break;
}
ptr = ptr.next;
}
size++ ;
return true;
}
private Node getNode(int index ) {
return null;
}
public E remove(int index) {
Node ret;
if (size == 1 && index == 1)
{
ret = head;
head = null;
tail = null;
size = 0;
return ret.getElement();
}
if (index == 1)
{
ret = head;
head = head.next;
tail.next = head;
size--;
return ret.getElement();
}
if (index == size)
{
Node s = head;
Node t = head;
while (s != tail)
{
t = s;
s = s.next;
}
ret = tail;
tail = head;
tail = t;
size --;
return ret.getElement();
}
Node ptr = head;
index = index - 1 ;
for (int i = 1; i < size - 1; i++)
{
if (i == index)
{
Node tmp = ptr.next;
tmp = tmp.next;
ptr.next = tmp;
break;
}
ptr = ptr.next;
}
size-- ;
return ptr.getElement();
}
public String toString()
{
Node current = head;
String result = "";
if(size == 0){
return "";
}
if(size == 1) {
return head.getElement().toString();
}
else{
do{
result = result + current.getElement().toString();
result = result + " ==> ";
current = current.next;
} while(current != head);
}
return result;
}
public Iterator iterator() {
return new ListIterator();
}
private class ListIterator implements Iterator{
Node nextItem;
Node prev;
int index;
@SuppressWarnings("unchecked")
public ListIterator(){
nextItem = (Node) head;
index = 0;
}
public boolean hasNext() {
return size != 0;
}
public E next() {
prev = nextItem;
nextItem = nextItem.next;
index = (index + 1) % size;
return prev.getElement();
}
public void remove() {
int target;
if(nextItem == head) {
target = size - 1;
} else{
target = index - 1;
index--;
}
CircularLinkedList.this.remove(target); //calls the above class
}
}
// Solve the problem in the main method
// The answer of n = 13, k = 2 is
// the 11th person in the ring (index 10)
public static void main(String[] args){
CircularLinkedList l = new CircularLinkedList();
int n=13;
int k=2;
for(int i=1;i<=n;i++)
l.add(Integer.valueOf(i));
int j = 13,i=0;
while(j>0)
{
System.out.println(l.toString());
i = i + k;
if(i>j)
i = k;
l.remove(i);
j--;
}
}
}
OUTPUT:
1 ==> 2 ==> 3 ==> 4 ==> 5 ==> 6 ==> 7 ==> 8 ==> 9 ==> 10 ==> 11 ==> 12 ==> 13 ==>
1 ==> 3 ==> 4 ==> 5 ==> 6 ==> 7 ==> 8 ==> 9 ==> 10 ==> 11 ==> 12 ==> 13 ==>
1 ==> 3 ==> 4 ==> 6 ==> 7 ==> 8 ==> 9 ==> 10 ==> 11 ==> 12 ==> 13 ==>
1 ==> 3 ==> 4 ==> 6 ==> 7 ==> 9 ==> 10 ==> 11 ==> 12 ==> 13 ==>
1 ==> 3 ==> 4 ==> 6 ==> 7 ==> 9 ==> 10 ==> 12 ==> 13 ==>
1 ==> 4 ==> 6 ==> 7 ==> 9 ==> 10 ==> 12 ==> 13 ==>
1 ==> 4 ==> 6 ==> 9 ==> 10 ==> 12 ==> 13 ==>
1 ==> 4 ==> 6 ==> 9 ==> 10 ==> 13 ==>
1 ==> 6 ==> 9 ==> 10 ==> 13 ==>
1 ==> 6 ==> 9 ==> 13 ==>
1 ==> 9 ==> 13 ==>
1 ==> 13 ==>
1
Solution
SOURCE CODE:
import java.util.Iterator;
public class CircularLinkedList implements Iterable {
Node head , tail;
int size;
CircularLinkedList() {
head = null;
tail = null;
size = 0;
}
public boolean add(E e) {
Node ele = new Node(e);
ele.next = head;
if(head == null)
{
head = ele;
ele.next = head;
tail = head;
}
else
{
tail.next = ele;
tail = ele;
}
size++;
return true;
}
public boolean add(int index, E e){
Node ele = new Node(e);
Node ptr = head;
index = index - 1 ;
for (int i = 1; i < size - 1; i++)
{
if (i == index)
{
Node tmp = ptr.next;
ptr.next = ele;
ele.next = tmp;
break;
}
ptr = ptr.next;
}
size++ ;
return true;
}
private Node getNode(int index ) {
return null;
}
public E remove(int index) {
Node ret;
if (size == 1 && index == 1)
{
ret = head;
head = null;
tail = null;
size = 0;
return ret.getElement();
}
if (index == 1)
{
ret = head;
head = head.next;
tail.next = head;
size--;
return ret.getElement();
}
if (index == size)
{
Node s = head;
Node t = head;
while (s != tail)
{
t = s;
s = s.next;
}
ret = tail;
tail = head;
tail = t;
size --;
return ret.getElement();
}
Node ptr = head;
index = index - 1 ;
for (int i = 1; i < size - 1; i++)
{
if (i == index)
{
Node tmp = ptr.next;
tmp = tmp.next;
ptr.next = tmp;
break;
}
ptr = ptr.next;
}
size-- ;
return ptr.getElement();
}
public String toString()
{
Node current = head;
String result = "";
if(size == 0){
return "";
}
if(size == 1) {
return head.getElement().toString();
}
else{
do{
result = result + current.getElement().toString();
result = result + " ==> ";
current = current.next;
} while(current != head);
}
return result;
}
public Iterator iterator() {
return new ListIterator();
}
private class ListIterator implements Iterator{
Node nextItem;
Node prev;
int index;
@SuppressWarnings("unchecked")
public ListIterator(){
nextItem = (Node) head;
index = 0;
}
public boolean hasNext() {
return size != 0;
}
public E next() {
prev = nextItem;
nextItem = nextItem.next;
index = (index + 1) % size;
return prev.getElement();
}
public void remove() {
int target;
if(nextItem == head) {
target = size - 1;
} else{
target = index - 1;
index--;
}
CircularLinkedList.this.remove(target); //calls the above class
}
}
// Solve the problem in the main method
// The answer of n = 13, k = 2 is
// the 11th person in the ring (index 10)
public static void main(String[] args){
CircularLinkedList l = new CircularLinkedList();
int n=13;
int k=2;
for(int i=1;i<=n;i++)
l.add(Integer.valueOf(i));
int j = 13,i=0;
while(j>0)
{
System.out.println(l.toString());
i = i + k;
if(i>j)
i = k;
l.remove(i);
j--;
}
}
}
OUTPUT:
1 ==> 2 ==> 3 ==> 4 ==> 5 ==> 6 ==> 7 ==> 8 ==> 9 ==> 10 ==> 11 ==> 12 ==> 13 ==>
1 ==> 3 ==> 4 ==> 5 ==> 6 ==> 7 ==> 8 ==> 9 ==> 10 ==> 11 ==> 12 ==> 13 ==>
1 ==> 3 ==> 4 ==> 6 ==> 7 ==> 8 ==> 9 ==> 10 ==> 11 ==> 12 ==> 13 ==>
1 ==> 3 ==> 4 ==> 6 ==> 7 ==> 9 ==> 10 ==> 11 ==> 12 ==> 13 ==>
1 ==> 3 ==> 4 ==> 6 ==> 7 ==> 9 ==> 10 ==> 12 ==> 13 ==>
1 ==> 4 ==> 6 ==> 7 ==> 9 ==> 10 ==> 12 ==> 13 ==>
1 ==> 4 ==> 6 ==> 9 ==> 10 ==> 12 ==> 13 ==>
1 ==> 4 ==> 6 ==> 9 ==> 10 ==> 13 ==>
1 ==> 6 ==> 9 ==> 10 ==> 13 ==>
1 ==> 6 ==> 9 ==> 13 ==>
1 ==> 9 ==> 13 ==>
1 ==> 13 ==>
1

More Related Content

PDF
import java-util--- public class MyLinkedList{ public static void.pdf
PDF
hi i have to write a java program involving link lists. i have a pro.pdf
PDF
import java-util-Iterator- import java-util-NoSuchElementException- im.pdf
PDF
This is problem is same problem which i submitted on 22017, I just.pdf
PDF
To complete the task, you need to fill in the missing code. I’ve inc.pdf
PDF
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
PDF
output and explain There is Mylist There is MyArrayList pa.pdf
PDF
can you add a delete button and a add button to the below program. j.pdf
import java-util--- public class MyLinkedList{ public static void.pdf
hi i have to write a java program involving link lists. i have a pro.pdf
import java-util-Iterator- import java-util-NoSuchElementException- im.pdf
This is problem is same problem which i submitted on 22017, I just.pdf
To complete the task, you need to fill in the missing code. I’ve inc.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
output and explain There is Mylist There is MyArrayList pa.pdf
can you add a delete button and a add button to the below program. j.pdf

Similar to SOURCE CODEimport java.util.Iterator;public class CircularLinke.pdf (20)

PDF
i am looking for help on the method AddSorted and the method Copy only.pdf
PDF
Help I keep getting the same error when running a code. Below is the.pdf
PDF
Given below is the completed implementation of MyLinkedList class. O.pdf
PDF
package ex2- public class Exercise2-E- { private static class N.pdf
PDF
Submit1) Java Files2) Doc file with the following contents.pdf
PDF
Works Applications Test - Chinmay Chauhan
PDF
Polymorphism
PPT
Link list part 2
PDF
using set identitiesSolutionimport java.util.Scanner; c.pdf
DOCX
For this micro assignment, you must implement two Linked List functi.docx
PDF
Hi,I have added the methods and main class as per your requirement.pdf
PDF
6. Generics. Collections. Streams
PDF
Solve using Java programming language- ----------------------------.pdf
PDF
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
PDF
Create a new java class called ListNode. Implement ListNode as a gen.pdf
PDF
Lab-2.4 101.pdf
PDF
STAGE 2 The Methods 65 points Implement all the methods t.pdf
PDF
Rewrite this code so it can use a generic type instead of integers. .pdf
PDF
public class MyLinkedListltE extends ComparableltEgtg.pdf
i am looking for help on the method AddSorted and the method Copy only.pdf
Help I keep getting the same error when running a code. Below is the.pdf
Given below is the completed implementation of MyLinkedList class. O.pdf
package ex2- public class Exercise2-E- { private static class N.pdf
Submit1) Java Files2) Doc file with the following contents.pdf
Works Applications Test - Chinmay Chauhan
Polymorphism
Link list part 2
using set identitiesSolutionimport java.util.Scanner; c.pdf
For this micro assignment, you must implement two Linked List functi.docx
Hi,I have added the methods and main class as per your requirement.pdf
6. Generics. Collections. Streams
Solve using Java programming language- ----------------------------.pdf
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
Create a new java class called ListNode. Implement ListNode as a gen.pdf
Lab-2.4 101.pdf
STAGE 2 The Methods 65 points Implement all the methods t.pdf
Rewrite this code so it can use a generic type instead of integers. .pdf
public class MyLinkedListltE extends ComparableltEgtg.pdf
Ad

More from arccreation001 (20)

PDF
2) In Autocrine signalling, reception of a signal released by the sa.pdf
PDF
Volatility Distillation separates out different .pdf
PDF
The first one has Van der Waals interactions sinc.pdf
PDF
Supersaturated actually. There is more solvent th.pdf
PDF
In optics, a virtual image is an image in which t.pdf
PDF
1) Political orientation and ideas are the main reasons behind count.pdf
PDF
Molarity = moles volume in L Molarity = 0.0342.pdf
PDF
The tracheal system in insects and gills in fishes are both helps th.pdf
PDF
The answer is D. ChemoorganoheterotrophCow is a chemoorganohetero.pdf
PDF
The A and B chains of human insulin are cloned in separate plasmids .pdf
PDF
Question 1How many parameters does a default constructor haveAn.pdf
PDF
Rio de Janeiro is a city located on Brazils south-east coast. It i.pdf
PDF
Othello.javapackage othello;import core.Game; import userInter.pdf
PDF
1.Types of Computer Information SystemsThere are four basic type.pdf
PDF
Microbiome of human bodyResearchers currently studying human norm.pdf
PDF
Na2SeO3 --- 2 Na+ + SeO32- 0.08              0.16       0.08 .pdf
PDF
It is an important to understand the early stages of reproduction. W.pdf
PDF
Let the normal gene be represented by P, and the two mutations be re.pdf
PDF
Imagine you are an Information Systems Security Officer for a medium.pdf
PDF
Each water molecule has 4 hydrogen bonds holding .pdf
2) In Autocrine signalling, reception of a signal released by the sa.pdf
Volatility Distillation separates out different .pdf
The first one has Van der Waals interactions sinc.pdf
Supersaturated actually. There is more solvent th.pdf
In optics, a virtual image is an image in which t.pdf
1) Political orientation and ideas are the main reasons behind count.pdf
Molarity = moles volume in L Molarity = 0.0342.pdf
The tracheal system in insects and gills in fishes are both helps th.pdf
The answer is D. ChemoorganoheterotrophCow is a chemoorganohetero.pdf
The A and B chains of human insulin are cloned in separate plasmids .pdf
Question 1How many parameters does a default constructor haveAn.pdf
Rio de Janeiro is a city located on Brazils south-east coast. It i.pdf
Othello.javapackage othello;import core.Game; import userInter.pdf
1.Types of Computer Information SystemsThere are four basic type.pdf
Microbiome of human bodyResearchers currently studying human norm.pdf
Na2SeO3 --- 2 Na+ + SeO32- 0.08              0.16       0.08 .pdf
It is an important to understand the early stages of reproduction. W.pdf
Let the normal gene be represented by P, and the two mutations be re.pdf
Imagine you are an Information Systems Security Officer for a medium.pdf
Each water molecule has 4 hydrogen bonds holding .pdf
Ad

Recently uploaded (20)

PDF
Computing-Curriculum for Schools in Ghana
PPTX
Institutional Correction lecture only . . .
PPTX
Pharma ospi slides which help in ospi learning
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
GDM (1) (1).pptx small presentation for students
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Computing-Curriculum for Schools in Ghana
Institutional Correction lecture only . . .
Pharma ospi slides which help in ospi learning
O7-L3 Supply Chain Operations - ICLT Program
GDM (1) (1).pptx small presentation for students
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Chinmaya Tiranga quiz Grand Finale.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
FourierSeries-QuestionsWithAnswers(Part-A).pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
A systematic review of self-coping strategies used by university students to ...
Supply Chain Operations Speaking Notes -ICLT Program
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
102 student loan defaulters named and shamed – Is someone you know on the list?
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Chapter 2 Heredity, Prenatal Development, and Birth.pdf

SOURCE CODEimport java.util.Iterator;public class CircularLinke.pdf

  • 1. SOURCE CODE: import java.util.Iterator; public class CircularLinkedList implements Iterable { Node head , tail; int size; CircularLinkedList() { head = null; tail = null; size = 0; } public boolean add(E e) { Node ele = new Node(e); ele.next = head; if(head == null) { head = ele; ele.next = head; tail = head; } else { tail.next = ele; tail = ele; } size++; return true; } public boolean add(int index, E e){ Node ele = new Node(e); Node ptr = head; index = index - 1 ;
  • 2. for (int i = 1; i < size - 1; i++) { if (i == index) { Node tmp = ptr.next; ptr.next = ele; ele.next = tmp; break; } ptr = ptr.next; } size++ ; return true; } private Node getNode(int index ) { return null; } public E remove(int index) { Node ret; if (size == 1 && index == 1) { ret = head; head = null; tail = null; size = 0; return ret.getElement(); } if (index == 1) { ret = head; head = head.next; tail.next = head; size--; return ret.getElement(); }
  • 3. if (index == size) { Node s = head; Node t = head; while (s != tail) { t = s; s = s.next; } ret = tail; tail = head; tail = t; size --; return ret.getElement(); } Node ptr = head; index = index - 1 ; for (int i = 1; i < size - 1; i++) { if (i == index) { Node tmp = ptr.next; tmp = tmp.next; ptr.next = tmp; break; } ptr = ptr.next; } size-- ; return ptr.getElement(); } public String toString() { Node current = head; String result = ""; if(size == 0){
  • 4. return ""; } if(size == 1) { return head.getElement().toString(); } else{ do{ result = result + current.getElement().toString(); result = result + " ==> "; current = current.next; } while(current != head); } return result; } public Iterator iterator() { return new ListIterator(); } private class ListIterator implements Iterator{ Node nextItem; Node prev; int index; @SuppressWarnings("unchecked") public ListIterator(){ nextItem = (Node) head; index = 0; } public boolean hasNext() { return size != 0; }
  • 5. public E next() { prev = nextItem; nextItem = nextItem.next; index = (index + 1) % size; return prev.getElement(); } public void remove() { int target; if(nextItem == head) { target = size - 1; } else{ target = index - 1; index--; } CircularLinkedList.this.remove(target); //calls the above class } } // Solve the problem in the main method // The answer of n = 13, k = 2 is // the 11th person in the ring (index 10) public static void main(String[] args){ CircularLinkedList l = new CircularLinkedList(); int n=13; int k=2; for(int i=1;i<=n;i++) l.add(Integer.valueOf(i)); int j = 13,i=0; while(j>0) { System.out.println(l.toString());
  • 6. i = i + k; if(i>j) i = k; l.remove(i); j--; } } } OUTPUT: 1 ==> 2 ==> 3 ==> 4 ==> 5 ==> 6 ==> 7 ==> 8 ==> 9 ==> 10 ==> 11 ==> 12 ==> 13 ==> 1 ==> 3 ==> 4 ==> 5 ==> 6 ==> 7 ==> 8 ==> 9 ==> 10 ==> 11 ==> 12 ==> 13 ==> 1 ==> 3 ==> 4 ==> 6 ==> 7 ==> 8 ==> 9 ==> 10 ==> 11 ==> 12 ==> 13 ==> 1 ==> 3 ==> 4 ==> 6 ==> 7 ==> 9 ==> 10 ==> 11 ==> 12 ==> 13 ==> 1 ==> 3 ==> 4 ==> 6 ==> 7 ==> 9 ==> 10 ==> 12 ==> 13 ==> 1 ==> 4 ==> 6 ==> 7 ==> 9 ==> 10 ==> 12 ==> 13 ==> 1 ==> 4 ==> 6 ==> 9 ==> 10 ==> 12 ==> 13 ==> 1 ==> 4 ==> 6 ==> 9 ==> 10 ==> 13 ==> 1 ==> 6 ==> 9 ==> 10 ==> 13 ==> 1 ==> 6 ==> 9 ==> 13 ==> 1 ==> 9 ==> 13 ==> 1 ==> 13 ==> 1 Solution SOURCE CODE: import java.util.Iterator; public class CircularLinkedList implements Iterable { Node head , tail; int size; CircularLinkedList() { head = null; tail = null;
  • 7. size = 0; } public boolean add(E e) { Node ele = new Node(e); ele.next = head; if(head == null) { head = ele; ele.next = head; tail = head; } else { tail.next = ele; tail = ele; } size++; return true; } public boolean add(int index, E e){ Node ele = new Node(e); Node ptr = head; index = index - 1 ; for (int i = 1; i < size - 1; i++) { if (i == index) { Node tmp = ptr.next; ptr.next = ele; ele.next = tmp; break; } ptr = ptr.next; }
  • 8. size++ ; return true; } private Node getNode(int index ) { return null; } public E remove(int index) { Node ret; if (size == 1 && index == 1) { ret = head; head = null; tail = null; size = 0; return ret.getElement(); } if (index == 1) { ret = head; head = head.next; tail.next = head; size--; return ret.getElement(); } if (index == size) { Node s = head; Node t = head; while (s != tail) { t = s; s = s.next; } ret = tail; tail = head;
  • 9. tail = t; size --; return ret.getElement(); } Node ptr = head; index = index - 1 ; for (int i = 1; i < size - 1; i++) { if (i == index) { Node tmp = ptr.next; tmp = tmp.next; ptr.next = tmp; break; } ptr = ptr.next; } size-- ; return ptr.getElement(); } public String toString() { Node current = head; String result = ""; if(size == 0){ return ""; } if(size == 1) { return head.getElement().toString(); } else{ do{ result = result + current.getElement().toString(); result = result + " ==> "; current = current.next;
  • 10. } while(current != head); } return result; } public Iterator iterator() { return new ListIterator(); } private class ListIterator implements Iterator{ Node nextItem; Node prev; int index; @SuppressWarnings("unchecked") public ListIterator(){ nextItem = (Node) head; index = 0; } public boolean hasNext() { return size != 0; } public E next() { prev = nextItem; nextItem = nextItem.next; index = (index + 1) % size; return prev.getElement(); } public void remove() { int target;
  • 11. if(nextItem == head) { target = size - 1; } else{ target = index - 1; index--; } CircularLinkedList.this.remove(target); //calls the above class } } // Solve the problem in the main method // The answer of n = 13, k = 2 is // the 11th person in the ring (index 10) public static void main(String[] args){ CircularLinkedList l = new CircularLinkedList(); int n=13; int k=2; for(int i=1;i<=n;i++) l.add(Integer.valueOf(i)); int j = 13,i=0; while(j>0) { System.out.println(l.toString()); i = i + k; if(i>j) i = k; l.remove(i); j--; } } } OUTPUT: 1 ==> 2 ==> 3 ==> 4 ==> 5 ==> 6 ==> 7 ==> 8 ==> 9 ==> 10 ==> 11 ==> 12 ==> 13 ==>
  • 12. 1 ==> 3 ==> 4 ==> 5 ==> 6 ==> 7 ==> 8 ==> 9 ==> 10 ==> 11 ==> 12 ==> 13 ==> 1 ==> 3 ==> 4 ==> 6 ==> 7 ==> 8 ==> 9 ==> 10 ==> 11 ==> 12 ==> 13 ==> 1 ==> 3 ==> 4 ==> 6 ==> 7 ==> 9 ==> 10 ==> 11 ==> 12 ==> 13 ==> 1 ==> 3 ==> 4 ==> 6 ==> 7 ==> 9 ==> 10 ==> 12 ==> 13 ==> 1 ==> 4 ==> 6 ==> 7 ==> 9 ==> 10 ==> 12 ==> 13 ==> 1 ==> 4 ==> 6 ==> 9 ==> 10 ==> 12 ==> 13 ==> 1 ==> 4 ==> 6 ==> 9 ==> 10 ==> 13 ==> 1 ==> 6 ==> 9 ==> 10 ==> 13 ==> 1 ==> 6 ==> 9 ==> 13 ==> 1 ==> 9 ==> 13 ==> 1 ==> 13 ==> 1