SlideShare a Scribd company logo
1 of 6
Download to read offline
public class Deque {
private class Node {
public int data;
public Node leftNode;
public Node rightNode;
private Node(int data) {
this.data = data;
leftNode = null;
rightNode = null;
}
private Node(int data, null, Node rightNode) {
this.data = data;
this.leftNode = null;
this.rightNode = rightNode;
}
private Node(int data, Node leftNode, null) {
this.data = data;
this.leftNode = leftNode;
this.rightNode = null;
}
private Node(int data, Node leftNode, Node rightNode) {
this.data = data;
this.leftNode = leftNode;
this.rightNode = rightNode;
}
}
private Node leftEnd = null;
private Node rightEnd = null;
public Deque() {
}
public void InsertLeft(int data) {
if ((leftEnd == null) && (rightEnd == null)) {
Node item = new Node(data);
leftEnd = item;
rightEnd = item;
} else {
Node item = new Node(data, leftEnd, null);
leftEnd.leftNode = item;
leftEnd = item;
}
}
public int DeleteRight() {
int temp = rightEnd.data;
rightEnd = rightEnd.leftNode;
rightEnd.rightNode = null;
return temp;
}
}
public class Deque {
private class Node {
public int data;
public Node leftNode;
public Node rightNode;
private Node(int data) {
this.data = data;
leftNode = null;
rightNode = null;
}
private Node(int data, Node leftNode, Node rightNode) {
this.data = data;
this.leftNode = leftNode;
this.rightNode = rightNode;
}
}
private Node header = new Node(0);
public Deque() {
}
public void InsertLeft(int data) {
if (header.data == 0) {
Node item = new Node(data);
item.leftNode = item;
item.rightNode = item;
header.leftNode = item;
header.rightNode = item;
} else {
Node item = new Node(data, header.leftNode, header.rightNode);
Node old_leftEnd = header.leftNode;
old_leftEnd.rightNode = item;
Node rightEnd = header.rightNode;
temp.leftNode = item;
header.leftNode = item;
}
header.data++;
}
public Node DeleteRight() {
if (header.data == 0 ) {
} else {
Node old_rightEnd = header.rightNode; Node leftEnd = header.leftNode; // reference to leftEnd
Node new_rightEnd = old_rightEnd.rightNode; /* link new rightEnd to leftEnd */
new_rightEnd.leftNode = leftEnd;
leftEnd.rightNode = new_rightEnd;
header.rightNode = new_rightEnd;
}
header.data--;
}
Solution
public class Deque {
private class Node {
public int data;
public Node leftNode;
public Node rightNode;
private Node(int data) {
this.data = data;
leftNode = null;
rightNode = null;
}
private Node(int data, null, Node rightNode) {
this.data = data;
this.leftNode = null;
this.rightNode = rightNode;
}
private Node(int data, Node leftNode, null) {
this.data = data;
this.leftNode = leftNode;
this.rightNode = null;
}
private Node(int data, Node leftNode, Node rightNode) {
this.data = data;
this.leftNode = leftNode;
this.rightNode = rightNode;
}
}
private Node leftEnd = null;
private Node rightEnd = null;
public Deque() {
}
public void InsertLeft(int data) {
if ((leftEnd == null) && (rightEnd == null)) {
Node item = new Node(data);
leftEnd = item;
rightEnd = item;
} else {
Node item = new Node(data, leftEnd, null);
leftEnd.leftNode = item;
leftEnd = item;
}
}
public int DeleteRight() {
int temp = rightEnd.data;
rightEnd = rightEnd.leftNode;
rightEnd.rightNode = null;
return temp;
}
}
public class Deque {
private class Node {
public int data;
public Node leftNode;
public Node rightNode;
private Node(int data) {
this.data = data;
leftNode = null;
rightNode = null;
}
private Node(int data, Node leftNode, Node rightNode) {
this.data = data;
this.leftNode = leftNode;
this.rightNode = rightNode;
}
}
private Node header = new Node(0);
public Deque() {
}
public void InsertLeft(int data) {
if (header.data == 0) {
Node item = new Node(data);
item.leftNode = item;
item.rightNode = item;
header.leftNode = item;
header.rightNode = item;
} else {
Node item = new Node(data, header.leftNode, header.rightNode);
Node old_leftEnd = header.leftNode;
old_leftEnd.rightNode = item;
Node rightEnd = header.rightNode;
temp.leftNode = item;
header.leftNode = item;
}
header.data++;
}
public Node DeleteRight() {
if (header.data == 0 ) {
} else {
Node old_rightEnd = header.rightNode; Node leftEnd = header.leftNode; // reference to leftEnd
Node new_rightEnd = old_rightEnd.rightNode; /* link new rightEnd to leftEnd */
new_rightEnd.leftNode = leftEnd;
leftEnd.rightNode = new_rightEnd;
header.rightNode = new_rightEnd;
}
header.data--;
}

More Related Content

Similar to public class Deque {private class Node {public int data;public.pdf

Need Help with this Java Assignment. Program should be done in JAVA .pdf
Need Help with this Java Assignment. Program should be done in JAVA .pdfNeed Help with this Java Assignment. Program should be done in JAVA .pdf
Need Help with this Java Assignment. Program should be done in JAVA .pdfarchiesgallery
 
package DataStructures; public class HelloWorld AnyType extends.pdf
package DataStructures; public class HelloWorld AnyType extends.pdfpackage DataStructures; public class HelloWorld AnyType extends.pdf
package DataStructures; public class HelloWorld AnyType extends.pdfapleathers
 
Given BinaryNode.javapackage util;import java.util.;T.pdf
Given BinaryNode.javapackage util;import java.util.;T.pdfGiven BinaryNode.javapackage util;import java.util.;T.pdf
Given BinaryNode.javapackage util;import java.util.;T.pdfConint29
 
I need help finishing this code in JavaYou will need to create t.pdf
I need help finishing this code in JavaYou will need to create t.pdfI need help finishing this code in JavaYou will need to create t.pdf
I need help finishing this code in JavaYou will need to create t.pdfallurafashions98
 
Here is the code given in the instructionsclass AVL {.pdf
Here is the code given in the instructionsclass AVL {.pdfHere is the code given in the instructionsclass AVL {.pdf
Here is the code given in the instructionsclass AVL {.pdfmanjan6
 
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdfHere is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdfarrowmobile
 
mainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdfmainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdffathimafancyjeweller
 
To create a node for a binary search tree (BTNode, ) and to create a .pdf
To create a node for a binary search tree (BTNode, ) and to create a .pdfTo create a node for a binary search tree (BTNode, ) and to create a .pdf
To create a node for a binary search tree (BTNode, ) and to create a .pdfbhim1213
 
Link list part 2
Link list part 2Link list part 2
Link list part 2Anaya Zafar
 
Please change this method to recursive method.  public String post.pdf
Please change this method to recursive method.  public String post.pdfPlease change this method to recursive method.  public String post.pdf
Please change this method to recursive method.  public String post.pdfpallavi953613
 
The Program to find out the middle of a given linked listclass Lin.pdf
The Program to find out the middle of a given linked listclass Lin.pdfThe Program to find out the middle of a given linked listclass Lin.pdf
The Program to find out the middle of a given linked listclass Lin.pdfanushkaent7
 
usingpackage util;import java.util.;This class implements.pdf
usingpackage util;import java.util.;This class implements.pdfusingpackage util;import java.util.;This class implements.pdf
usingpackage util;import java.util.;This class implements.pdfinfo335653
 
Assignment 9 (Parent reference for BST) Redefine TreeNode by adding .pdf
Assignment 9 (Parent reference for BST) Redefine TreeNode by adding .pdfAssignment 9 (Parent reference for BST) Redefine TreeNode by adding .pdf
Assignment 9 (Parent reference for BST) Redefine TreeNode by adding .pdfFootageetoffe16
 
Rewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdfRewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdfalphaagenciesindia
 
The following is to be written in JavaThe following is the BSTree.pdf
The following is to be written in JavaThe following is the BSTree.pdfThe following is to be written in JavaThe following is the BSTree.pdf
The following is to be written in JavaThe following is the BSTree.pdfeyewatchsystems
 
Objective Binary Search Tree traversal (2 points)Use traversal.pp.pdf
Objective Binary Search Tree traversal (2 points)Use traversal.pp.pdfObjective Binary Search Tree traversal (2 points)Use traversal.pp.pdf
Objective Binary Search Tree traversal (2 points)Use traversal.pp.pdfsivakumar19831
 
Add delete at a position to the code and display it to the code- class.pdf
Add delete at a position to the code and display it to the code- class.pdfAdd delete at a position to the code and display it to the code- class.pdf
Add delete at a position to the code and display it to the code- class.pdfyrajjoshi
 
Help I keep getting the same error when running a code. Below is the.pdf
Help I keep getting the same error when running a code. Below is the.pdfHelp I keep getting the same error when running a code. Below is the.pdf
Help I keep getting the same error when running a code. Below is the.pdfmail931892
 
package edu-ser222-m03_02- --- - A binary search tree based impleme.docx
package edu-ser222-m03_02-   ---  - A binary search tree based impleme.docxpackage edu-ser222-m03_02-   ---  - A binary search tree based impleme.docx
package edu-ser222-m03_02- --- - A binary search tree based impleme.docxfarrahkur54
 

Similar to public class Deque {private class Node {public int data;public.pdf (20)

Need Help with this Java Assignment. Program should be done in JAVA .pdf
Need Help with this Java Assignment. Program should be done in JAVA .pdfNeed Help with this Java Assignment. Program should be done in JAVA .pdf
Need Help with this Java Assignment. Program should be done in JAVA .pdf
 
package DataStructures; public class HelloWorld AnyType extends.pdf
package DataStructures; public class HelloWorld AnyType extends.pdfpackage DataStructures; public class HelloWorld AnyType extends.pdf
package DataStructures; public class HelloWorld AnyType extends.pdf
 
Given BinaryNode.javapackage util;import java.util.;T.pdf
Given BinaryNode.javapackage util;import java.util.;T.pdfGiven BinaryNode.javapackage util;import java.util.;T.pdf
Given BinaryNode.javapackage util;import java.util.;T.pdf
 
PathOfMostResistance
PathOfMostResistancePathOfMostResistance
PathOfMostResistance
 
I need help finishing this code in JavaYou will need to create t.pdf
I need help finishing this code in JavaYou will need to create t.pdfI need help finishing this code in JavaYou will need to create t.pdf
I need help finishing this code in JavaYou will need to create t.pdf
 
Here is the code given in the instructionsclass AVL {.pdf
Here is the code given in the instructionsclass AVL {.pdfHere is the code given in the instructionsclass AVL {.pdf
Here is the code given in the instructionsclass AVL {.pdf
 
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdfHere is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
 
mainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdfmainpublic class AssignmentThree {    public static void ma.pdf
mainpublic class AssignmentThree {    public static void ma.pdf
 
To create a node for a binary search tree (BTNode, ) and to create a .pdf
To create a node for a binary search tree (BTNode, ) and to create a .pdfTo create a node for a binary search tree (BTNode, ) and to create a .pdf
To create a node for a binary search tree (BTNode, ) and to create a .pdf
 
Link list part 2
Link list part 2Link list part 2
Link list part 2
 
Please change this method to recursive method.  public String post.pdf
Please change this method to recursive method.  public String post.pdfPlease change this method to recursive method.  public String post.pdf
Please change this method to recursive method.  public String post.pdf
 
The Program to find out the middle of a given linked listclass Lin.pdf
The Program to find out the middle of a given linked listclass Lin.pdfThe Program to find out the middle of a given linked listclass Lin.pdf
The Program to find out the middle of a given linked listclass Lin.pdf
 
usingpackage util;import java.util.;This class implements.pdf
usingpackage util;import java.util.;This class implements.pdfusingpackage util;import java.util.;This class implements.pdf
usingpackage util;import java.util.;This class implements.pdf
 
Assignment 9 (Parent reference for BST) Redefine TreeNode by adding .pdf
Assignment 9 (Parent reference for BST) Redefine TreeNode by adding .pdfAssignment 9 (Parent reference for BST) Redefine TreeNode by adding .pdf
Assignment 9 (Parent reference for BST) Redefine TreeNode by adding .pdf
 
Rewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdfRewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdf
 
The following is to be written in JavaThe following is the BSTree.pdf
The following is to be written in JavaThe following is the BSTree.pdfThe following is to be written in JavaThe following is the BSTree.pdf
The following is to be written in JavaThe following is the BSTree.pdf
 
Objective Binary Search Tree traversal (2 points)Use traversal.pp.pdf
Objective Binary Search Tree traversal (2 points)Use traversal.pp.pdfObjective Binary Search Tree traversal (2 points)Use traversal.pp.pdf
Objective Binary Search Tree traversal (2 points)Use traversal.pp.pdf
 
Add delete at a position to the code and display it to the code- class.pdf
Add delete at a position to the code and display it to the code- class.pdfAdd delete at a position to the code and display it to the code- class.pdf
Add delete at a position to the code and display it to the code- class.pdf
 
Help I keep getting the same error when running a code. Below is the.pdf
Help I keep getting the same error when running a code. Below is the.pdfHelp I keep getting the same error when running a code. Below is the.pdf
Help I keep getting the same error when running a code. Below is the.pdf
 
package edu-ser222-m03_02- --- - A binary search tree based impleme.docx
package edu-ser222-m03_02-   ---  - A binary search tree based impleme.docxpackage edu-ser222-m03_02-   ---  - A binary search tree based impleme.docx
package edu-ser222-m03_02- --- - A binary search tree based impleme.docx
 

More from annaipowerelectronic

Structure Hydra has a tubular body, with only one opening the mouth.pdf
Structure Hydra has a tubular body, with only one opening the mouth.pdfStructure Hydra has a tubular body, with only one opening the mouth.pdf
Structure Hydra has a tubular body, with only one opening the mouth.pdfannaipowerelectronic
 
Quality management ensures that an organization, product or service .pdf
Quality management ensures that an organization, product or service .pdfQuality management ensures that an organization, product or service .pdf
Quality management ensures that an organization, product or service .pdfannaipowerelectronic
 
Microsoft Excel is a spreadsheet program used to store and retrieve .pdf
Microsoft Excel is a spreadsheet program used to store and retrieve .pdfMicrosoft Excel is a spreadsheet program used to store and retrieve .pdf
Microsoft Excel is a spreadsheet program used to store and retrieve .pdfannaipowerelectronic
 
Mean = xffS = Sqrt((x-x)2fn)intervalMidpoint(x)frequency.pdf
Mean = xffS = Sqrt((x-x)2fn)intervalMidpoint(x)frequency.pdfMean = xffS = Sqrt((x-x)2fn)intervalMidpoint(x)frequency.pdf
Mean = xffS = Sqrt((x-x)2fn)intervalMidpoint(x)frequency.pdfannaipowerelectronic
 
Moles of Be = mass of Bemolar mass of Be= (0.33 g)(9.012 gmol).pdf
Moles of Be = mass of Bemolar mass of Be= (0.33 g)(9.012 gmol).pdfMoles of Be = mass of Bemolar mass of Be= (0.33 g)(9.012 gmol).pdf
Moles of Be = mass of Bemolar mass of Be= (0.33 g)(9.012 gmol).pdfannaipowerelectronic
 
Lyme disease is a bacterial infection which is caused by bacteria ca.pdf
Lyme disease is a bacterial infection which is caused by bacteria ca.pdfLyme disease is a bacterial infection which is caused by bacteria ca.pdf
Lyme disease is a bacterial infection which is caused by bacteria ca.pdfannaipowerelectronic
 
import java.util.Scanner; import java.util.Random; public clas.pdf
import java.util.Scanner; import java.util.Random; public clas.pdfimport java.util.Scanner; import java.util.Random; public clas.pdf
import java.util.Scanner; import java.util.Random; public clas.pdfannaipowerelectronic
 
above molecule has 12 signlas. .pdf
                     above molecule has 12 signlas.                   .pdf                     above molecule has 12 signlas.                   .pdf
above molecule has 12 signlas. .pdfannaipowerelectronic
 
Hi,I have added a loop for adding values to list. Highlighted the .pdf
Hi,I have added a loop for adding values to list. Highlighted the .pdfHi,I have added a loop for adding values to list. Highlighted the .pdf
Hi,I have added a loop for adding values to list. Highlighted the .pdfannaipowerelectronic
 
D. ICANNThe Internet Assigned Numbers Authority (IANA) is a depart.pdf
D. ICANNThe Internet Assigned Numbers Authority (IANA) is a depart.pdfD. ICANNThe Internet Assigned Numbers Authority (IANA) is a depart.pdf
D. ICANNThe Internet Assigned Numbers Authority (IANA) is a depart.pdfannaipowerelectronic
 
Cracking of petrolium In petroleum geology and chemistry, cracki.pdf
Cracking of petrolium In petroleum geology and chemistry, cracki.pdfCracking of petrolium In petroleum geology and chemistry, cracki.pdf
Cracking of petrolium In petroleum geology and chemistry, cracki.pdfannaipowerelectronic
 
can you provide any aditional information apart from thisSolutio.pdf
can you provide any aditional information apart from thisSolutio.pdfcan you provide any aditional information apart from thisSolutio.pdf
can you provide any aditional information apart from thisSolutio.pdfannaipowerelectronic
 
AnswerMajority of Americans have faster advancing into above 85 y.pdf
AnswerMajority of Americans have faster advancing into above 85 y.pdfAnswerMajority of Americans have faster advancing into above 85 y.pdf
AnswerMajority of Americans have faster advancing into above 85 y.pdfannaipowerelectronic
 
AnswerA compilation error is generated The method f(int) is und.pdf
AnswerA compilation error is generated The method f(int) is und.pdfAnswerA compilation error is generated The method f(int) is und.pdf
AnswerA compilation error is generated The method f(int) is und.pdfannaipowerelectronic
 
a)   There is a cluster of SNP’s with similar p value in the intron .pdf
a)   There is a cluster of SNP’s with similar p value in the intron .pdfa)   There is a cluster of SNP’s with similar p value in the intron .pdf
a)   There is a cluster of SNP’s with similar p value in the intron .pdfannaipowerelectronic
 
A HRIS, which is otherwise called a human resource information syste.pdf
A HRIS, which is otherwise called a human resource information syste.pdfA HRIS, which is otherwise called a human resource information syste.pdf
A HRIS, which is otherwise called a human resource information syste.pdfannaipowerelectronic
 
4 (110000)^3  =  4 s^2 0.01s = 10^-5 MoleslitSolution.pdf
4  (110000)^3  =  4  s^2  0.01s = 10^-5 MoleslitSolution.pdf4  (110000)^3  =  4  s^2  0.01s = 10^-5 MoleslitSolution.pdf
4 (110000)^3  =  4 s^2 0.01s = 10^-5 MoleslitSolution.pdfannaipowerelectronic
 
1.            It will be absorbed by plant. Or remain in soil that .pdf
 1.            It will be absorbed by plant. Or remain in soil that .pdf 1.            It will be absorbed by plant. Or remain in soil that .pdf
1.            It will be absorbed by plant. Or remain in soil that .pdfannaipowerelectronic
 

More from annaipowerelectronic (20)

Structure Hydra has a tubular body, with only one opening the mouth.pdf
Structure Hydra has a tubular body, with only one opening the mouth.pdfStructure Hydra has a tubular body, with only one opening the mouth.pdf
Structure Hydra has a tubular body, with only one opening the mouth.pdf
 
Quality management ensures that an organization, product or service .pdf
Quality management ensures that an organization, product or service .pdfQuality management ensures that an organization, product or service .pdf
Quality management ensures that an organization, product or service .pdf
 
Microsoft Excel is a spreadsheet program used to store and retrieve .pdf
Microsoft Excel is a spreadsheet program used to store and retrieve .pdfMicrosoft Excel is a spreadsheet program used to store and retrieve .pdf
Microsoft Excel is a spreadsheet program used to store and retrieve .pdf
 
Mean = xffS = Sqrt((x-x)2fn)intervalMidpoint(x)frequency.pdf
Mean = xffS = Sqrt((x-x)2fn)intervalMidpoint(x)frequency.pdfMean = xffS = Sqrt((x-x)2fn)intervalMidpoint(x)frequency.pdf
Mean = xffS = Sqrt((x-x)2fn)intervalMidpoint(x)frequency.pdf
 
Moles of Be = mass of Bemolar mass of Be= (0.33 g)(9.012 gmol).pdf
Moles of Be = mass of Bemolar mass of Be= (0.33 g)(9.012 gmol).pdfMoles of Be = mass of Bemolar mass of Be= (0.33 g)(9.012 gmol).pdf
Moles of Be = mass of Bemolar mass of Be= (0.33 g)(9.012 gmol).pdf
 
Lyme disease is a bacterial infection which is caused by bacteria ca.pdf
Lyme disease is a bacterial infection which is caused by bacteria ca.pdfLyme disease is a bacterial infection which is caused by bacteria ca.pdf
Lyme disease is a bacterial infection which is caused by bacteria ca.pdf
 
import java.util.Scanner; import java.util.Random; public clas.pdf
import java.util.Scanner; import java.util.Random; public clas.pdfimport java.util.Scanner; import java.util.Random; public clas.pdf
import java.util.Scanner; import java.util.Random; public clas.pdf
 
above molecule has 12 signlas. .pdf
                     above molecule has 12 signlas.                   .pdf                     above molecule has 12 signlas.                   .pdf
above molecule has 12 signlas. .pdf
 
Hi,I have added a loop for adding values to list. Highlighted the .pdf
Hi,I have added a loop for adding values to list. Highlighted the .pdfHi,I have added a loop for adding values to list. Highlighted the .pdf
Hi,I have added a loop for adding values to list. Highlighted the .pdf
 
D. ICANNThe Internet Assigned Numbers Authority (IANA) is a depart.pdf
D. ICANNThe Internet Assigned Numbers Authority (IANA) is a depart.pdfD. ICANNThe Internet Assigned Numbers Authority (IANA) is a depart.pdf
D. ICANNThe Internet Assigned Numbers Authority (IANA) is a depart.pdf
 
Cracking of petrolium In petroleum geology and chemistry, cracki.pdf
Cracking of petrolium In petroleum geology and chemistry, cracki.pdfCracking of petrolium In petroleum geology and chemistry, cracki.pdf
Cracking of petrolium In petroleum geology and chemistry, cracki.pdf
 
can you provide any aditional information apart from thisSolutio.pdf
can you provide any aditional information apart from thisSolutio.pdfcan you provide any aditional information apart from thisSolutio.pdf
can you provide any aditional information apart from thisSolutio.pdf
 
brasstinSolutionbrasstin.pdf
brasstinSolutionbrasstin.pdfbrasstinSolutionbrasstin.pdf
brasstinSolutionbrasstin.pdf
 
AnswerMajority of Americans have faster advancing into above 85 y.pdf
AnswerMajority of Americans have faster advancing into above 85 y.pdfAnswerMajority of Americans have faster advancing into above 85 y.pdf
AnswerMajority of Americans have faster advancing into above 85 y.pdf
 
AnswerA compilation error is generated The method f(int) is und.pdf
AnswerA compilation error is generated The method f(int) is und.pdfAnswerA compilation error is generated The method f(int) is und.pdf
AnswerA compilation error is generated The method f(int) is und.pdf
 
a)   There is a cluster of SNP’s with similar p value in the intron .pdf
a)   There is a cluster of SNP’s with similar p value in the intron .pdfa)   There is a cluster of SNP’s with similar p value in the intron .pdf
a)   There is a cluster of SNP’s with similar p value in the intron .pdf
 
A HRIS, which is otherwise called a human resource information syste.pdf
A HRIS, which is otherwise called a human resource information syste.pdfA HRIS, which is otherwise called a human resource information syste.pdf
A HRIS, which is otherwise called a human resource information syste.pdf
 
4 (110000)^3  =  4 s^2 0.01s = 10^-5 MoleslitSolution.pdf
4  (110000)^3  =  4  s^2  0.01s = 10^-5 MoleslitSolution.pdf4  (110000)^3  =  4  s^2  0.01s = 10^-5 MoleslitSolution.pdf
4 (110000)^3  =  4 s^2 0.01s = 10^-5 MoleslitSolution.pdf
 
2009.88Solution2009.88.pdf
2009.88Solution2009.88.pdf2009.88Solution2009.88.pdf
2009.88Solution2009.88.pdf
 
1.            It will be absorbed by plant. Or remain in soil that .pdf
 1.            It will be absorbed by plant. Or remain in soil that .pdf 1.            It will be absorbed by plant. Or remain in soil that .pdf
1.            It will be absorbed by plant. Or remain in soil that .pdf
 

Recently uploaded

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxUmeshTimilsina1
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 

Recently uploaded (20)

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 

public class Deque {private class Node {public int data;public.pdf

  • 1. public class Deque { private class Node { public int data; public Node leftNode; public Node rightNode; private Node(int data) { this.data = data; leftNode = null; rightNode = null; } private Node(int data, null, Node rightNode) { this.data = data; this.leftNode = null; this.rightNode = rightNode; } private Node(int data, Node leftNode, null) { this.data = data; this.leftNode = leftNode; this.rightNode = null; } private Node(int data, Node leftNode, Node rightNode) { this.data = data; this.leftNode = leftNode; this.rightNode = rightNode; } } private Node leftEnd = null; private Node rightEnd = null; public Deque() { } public void InsertLeft(int data) { if ((leftEnd == null) && (rightEnd == null)) { Node item = new Node(data); leftEnd = item; rightEnd = item;
  • 2. } else { Node item = new Node(data, leftEnd, null); leftEnd.leftNode = item; leftEnd = item; } } public int DeleteRight() { int temp = rightEnd.data; rightEnd = rightEnd.leftNode; rightEnd.rightNode = null; return temp; } } public class Deque { private class Node { public int data; public Node leftNode; public Node rightNode; private Node(int data) { this.data = data; leftNode = null; rightNode = null; } private Node(int data, Node leftNode, Node rightNode) { this.data = data; this.leftNode = leftNode; this.rightNode = rightNode; } } private Node header = new Node(0); public Deque() { } public void InsertLeft(int data) { if (header.data == 0) { Node item = new Node(data); item.leftNode = item;
  • 3. item.rightNode = item; header.leftNode = item; header.rightNode = item; } else { Node item = new Node(data, header.leftNode, header.rightNode); Node old_leftEnd = header.leftNode; old_leftEnd.rightNode = item; Node rightEnd = header.rightNode; temp.leftNode = item; header.leftNode = item; } header.data++; } public Node DeleteRight() { if (header.data == 0 ) { } else { Node old_rightEnd = header.rightNode; Node leftEnd = header.leftNode; // reference to leftEnd Node new_rightEnd = old_rightEnd.rightNode; /* link new rightEnd to leftEnd */ new_rightEnd.leftNode = leftEnd; leftEnd.rightNode = new_rightEnd; header.rightNode = new_rightEnd; } header.data--; } Solution public class Deque { private class Node { public int data; public Node leftNode; public Node rightNode; private Node(int data) { this.data = data; leftNode = null; rightNode = null;
  • 4. } private Node(int data, null, Node rightNode) { this.data = data; this.leftNode = null; this.rightNode = rightNode; } private Node(int data, Node leftNode, null) { this.data = data; this.leftNode = leftNode; this.rightNode = null; } private Node(int data, Node leftNode, Node rightNode) { this.data = data; this.leftNode = leftNode; this.rightNode = rightNode; } } private Node leftEnd = null; private Node rightEnd = null; public Deque() { } public void InsertLeft(int data) { if ((leftEnd == null) && (rightEnd == null)) { Node item = new Node(data); leftEnd = item; rightEnd = item; } else { Node item = new Node(data, leftEnd, null); leftEnd.leftNode = item; leftEnd = item; } } public int DeleteRight() { int temp = rightEnd.data; rightEnd = rightEnd.leftNode; rightEnd.rightNode = null;
  • 5. return temp; } } public class Deque { private class Node { public int data; public Node leftNode; public Node rightNode; private Node(int data) { this.data = data; leftNode = null; rightNode = null; } private Node(int data, Node leftNode, Node rightNode) { this.data = data; this.leftNode = leftNode; this.rightNode = rightNode; } } private Node header = new Node(0); public Deque() { } public void InsertLeft(int data) { if (header.data == 0) { Node item = new Node(data); item.leftNode = item; item.rightNode = item; header.leftNode = item; header.rightNode = item; } else { Node item = new Node(data, header.leftNode, header.rightNode); Node old_leftEnd = header.leftNode; old_leftEnd.rightNode = item; Node rightEnd = header.rightNode; temp.leftNode = item; header.leftNode = item;
  • 6. } header.data++; } public Node DeleteRight() { if (header.data == 0 ) { } else { Node old_rightEnd = header.rightNode; Node leftEnd = header.leftNode; // reference to leftEnd Node new_rightEnd = old_rightEnd.rightNode; /* link new rightEnd to leftEnd */ new_rightEnd.leftNode = leftEnd; leftEnd.rightNode = new_rightEnd; header.rightNode = new_rightEnd; } header.data--; }