1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
aivan3 [116]
3 years ago
7

Can someone urgently help me with my java code (I WILL GIVE BRAINLIEST)?! Ive been working on it for hours and its not working!

(please give an actual answer...)
*examples of required output at the bottom*

code: public class CircularList
{
private ListNode head;
private ListNode tail;
private int size;







public CircularList()

{

head = tail = null;

size = 0;

}





public int size()

{

return size;

}





public boolean isEmpty()

{

return (size == 0);

}





public int first()

{

if (head != null) {

return head.getValue();

}

return -1;

}




public Integer last()

{

if (tail != null) {

return tail.getValue();

}

return -1;

}



public void addFirst(Integer value)

{

head = new ListNode(value, head);

if (tail == null) {

tail = head;

}

size++;

}





public void addLast(Integer value)

{

ListNode newTail = new ListNode(value, null);

if (tail != null) {

tail.setNext(newTail);

tail = newTail;

} else {

head = tail = newTail;

}



size++;

}





public void addAtPos(int pos, Integer value)

{

if (pos == 0) {

addFirst(value);

return;

}

if (pos <= 0 || pos > size) {

return;

}

if (pos == size) {

addLast(value);

return;

}



ListNode ptr = head;

for(int i=0; i = size) {

return retVal;

}

if (pos == 0) {

return removeFirst();

}

ListNode ptr = head;

for(int i=0; i
ptr = ptr.getNext();

}

retVal = ptr.getNext().getValue();

if (pos == size-1) {

tail = ptr;

tail.setNext(null);

} else {

ptr.setNext(ptr.getNext().getNext());

}



size--;

return retVal;

}





public int findNode(Integer find)

{

ListNode ptr = head;

for(int pos=0; pos
if (ptr.getValue() == find) {

return pos;

}

ptr = ptr.getNext();

}

return -1;

}




public void rotate()

{

addLast(removeFirst());

}




public String toString()

{

String output = "";

ListNode iter = head;

while(iter != null) {

output += String.format("%d ", iter.getValue());

iter = iter.getNext();

}

return output;

}



}

size = 6 first = 50 last = 60
50 20 10 40 30 60

removeFirst = 50
size = 5 first = 20 last = 60
20 10 40 30 60

removed = 30
size = 4 first = 20 last = 60
20 10 40 60

size = 4 first = 20 last = 60
20 10 40 60

found at -1
removed = -1
size = 4 first = 20 last = 60
20 10 40 60

size = 4 first = 10 last = 20
10 40 60 20
Computers and Technology
1 answer:
o-na [289]3 years ago
4 0

Answer:

code 345code 4537

Explanation:

You might be interested in
Why does the randomNumber function only use whole numbers between 0 and 1 (basically, 0 and 1)?
Bogdan [553]

Answer:

The randomNumber function only uses whole numbers between 0 and 1 because those are the unspecified minimum and maximums to get random numbers. If you want a larger range, <em>just specify the minimum and maximum.</em>

Explanation:

<em>Example code on how to specify a larger range, replace max and min with your maximum and minimum integers.</em>

function getRandomArbitrary(min, max) {

 return Math.random() * (max - min) + min;

}

6 0
3 years ago
Describe the difference between information poor and information rich society?​
den301095 [7]

Explanation:

The “Information poor” are consumers who use traditional mass media information such as television, DVDs, radios and magazines. ... On the opposite “information rich” stands for a new elite within the information society.

4 0
2 years ago
A low concentration of market power has positive affects. A low concentration of market share has which of the following effects
lisov135 [29]
A or b i think hope it helps good luck and i hope it helps
6 0
4 years ago
Different ____________ are assigned to track multiple reviewers of a document.
Lemur [1.5K]
It could be c or d because when you are chatting to someone through say Skype you use fonts and colors to identify who you are talking to. But in most cases it would be d
3 0
3 years ago
A program in which students learn a specific skill for a particular job is called a
Ne4ueva [31]
A certification program.
7 0
3 years ago
Read 2 more answers
Other questions:
  • Se citește un număr natural nenul N. Se umple, pe linii, partea de sub diagonală, inclusiv aceasta, a unui tabel pătratic de dim
    9·1 answer
  • write a 〕ava program to sort a random list of 10 numbers entered b y user in an array using Selection Sort technique
    5·1 answer
  • Marjorie is a 72-year-old woman who is having difficulties with cooking and bathing. Jorge provides Marjorie with tools and tech
    12·1 answer
  • What is a good technological design?
    13·1 answer
  • What term identifies the physical interface between a computer and its peripherals?
    5·1 answer
  • Meg logs into her email account without entering her user ID and password manually every time. She also finds results from searc
    11·1 answer
  • Which object event is an indication that something has been created but not committed into the database?
    13·1 answer
  • What is the primary purpose of source code editor features such as keyword hi lighting and auto-completion A.to speed up the cod
    7·1 answer
  • _________ in online education refer(s) to how fairly the particular needs of particular groups of students are met.
    9·1 answer
  • A data analyst uses _____ to decide which data is relevant to their analysis and which data types and variables are appropriate
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!