Hey, I am in need of urgent help! My teacher is REALLY bad at his job (no exaggeration) and if I dont get a 100 on this lab, I will fail the class. Please help me, thank you!!!


This link contains the instructions and classes needed for the lab:
https://www.dropbox.com/sh/469usrw1vctot52/AAARAgfqC63k3OPksAkvdRsGa?dl=0

Please put the code in the Circular List Class, the rest is already done, thanks!

Answers

Answer 1

Answer:

public class CircularList

{

  private ListNode head; // front of the LinkedList

  private ListNode tail; // last node of the LinkedList

  private int size; // size of the LinkedList

   

  // constructs a new CircularList

  public CircularList()

  {

    head = tail = null;

    size = 0;

  }

   

  // returns the size of the array

  public int size()

  {

     return size;

  }

   

  // returns whether the list is empty

  public boolean isEmpty()

  {

     return (size == 0);

  }

   

  // returns the value of the first node

  public Integer first()

  {

     if (head != null) {

       return head.getValue();

     }

     return -1;

  }

   

  // returns the value of the last node

  public Integer last()

  {

     if (tail != null) {

       return tail.getValue();

     }

     return -1;

  }

  // adds a node to the front of the list

  public void addFirst(Integer value)

  {

    head = new ListNode(value, head);

    if (tail == null) {

      tail = head;

    }

    size++;

  }

   

  // adds a node to the end of the list

  public void addLast(Integer value)

  {

    ListNode newTail = new ListNode(value, null);

    if (tail != null) {

      tail.setNext(newTail);

      tail = newTail;

    } else {

      head = tail = newTail;

    }

     

    size++;

  }

   

  // adds a node at the position pos  

  public void addAtPos(int pos, Integer value)

  {

     if (pos == 0) { // Add at the start

       addFirst(value);

       return;

     }

     if (pos <= 0 || pos > size) { // Ignore attempts to add beyond the ends

       return;

     }

     if (pos == size) { // Special case, tail has to be adjusted

       addLast(value);

       return;

     }

     // size and pos are guaranteed both non-zero

     ListNode ptr = head; // ptr is the node before the new one

     for(int i=0; i<pos-1; i++) {

       ptr = ptr.getNext();

     }

     ListNode newNode = new ListNode(value, ptr.getNext());

     ptr.setNext(newNode);

     size++;

  }

   

  // removes the first node and returns the value of the removed node or -1 if the list is empty

  public Integer removeFirst()

  {

     Integer retVal = -1;

     if (head != null) {

       retVal = head.getValue();

       head = head.getNext();

       size--;

     }

     if (size == 0) {

       head = tail = null;

     }

     return retVal;

  }

   

  // removes the node at position pos and returns the value of the removed node or -1 if pos is not a valid position

  public Integer removeNode(int pos)

  {

     Integer retVal = -1;

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

       return retVal;

     }

     if (pos == 0) {

       return removeFirst();

     }

     ListNode ptr = head; // ptr is the node before the deleted

     for(int i=0; i<pos-1; i++) {

       ptr = ptr.getNext();

     }

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

     if (pos == size-1) { // Is it the last element?      

       tail = ptr;

       tail.setNext(null);

     } else {

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

     }

     

     size--;

     return retVal;

  }  

   

  // finds and returns the position of find, or -1 if not found

  public int findNode(Integer find)

  {

     ListNode ptr = head;

     for(int pos=0; pos<size; pos++) {

       if (ptr.getValue() == find) {

         return pos;

       }

       ptr = ptr.getNext();

     }

     return -1;

  }  

   

  // rotates the list by placing the first element at the end

  public void rotate()

  {

     addLast(removeFirst());

  }

   

  // returns the list of values in the LinkedList

  public String toString()

  {

     String output = "";

     ListNode iter = head;

     while(iter != null) {

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

       iter = iter.getNext();

     }

     return output;

  }

         

}

Explanation:

Enjoy. Linked list are always more complex than you expect. It is a good exercise to try once, then start using libraries. Life is too short to debug linked lists!


Related Questions

What is the advantage of using the Selection pane to modify SmartArt?
O It can insert or edit individual graphic boxes on a slide.
O It helps to reorder or remove on-screen elements that overlap.
O It adds a new overlay for creating overlapping graphics and text.
Olt automatically aligns graphic elements to on-screen guidelines.

Answers

Answer:

B

Explanation:

Bc I said so

Answer:

It helps to reorder or remove on-screen elements that overlap

Explanation:

edge 2022

The strength of gravity on the Moon is 1.6
Newtons per kilogram. If an astronaut's mass is 80
kg on Earth, what would it be on the Moon?​

Answers

Answer:

[tex]Mass = 80kg[/tex]

Explanation:

Given

On Earth

[tex]Mass = 80kg[/tex]

On the moon

[tex]g = 1.6N/kg[/tex]

Required

The astronaut's mass on the moon

The mass of an object do not change base on location

So, if the mass of the astronaut is 80kg on earth, it will be 80 kg on the moon.

Hence:

[tex]Mass = 80kg[/tex]

After saving a chart, where can you find it again to use it for a different data set?

sparklines
saved charts
templates
formats

Answers

Answer:

C. Templates

Explanation: Edge 20201

Answer:

templates

Explanation:

Convert the given for loop to while loop and find the output of the program assuming the
value entered for num is 15.
num = int (input ("Enter a value"))
sum =0
count=0
for i in range (1, num):
if i%2 == 0:
count += 1
sum += i
print(sum)
print(count)

Answers

Answer:

Explanation:

num = int (input ("Enter a value"))

sum =0

count=0

i = 1

while i < num:

 if i%2 == 0:

        count += 1

        sum += i

        i += 1

 i += 1

print(sum)

print(count)

The output assuming num is 15 would be

56

7

Define an array and why it is needed in programming

Answers

Answer:

An array is a data structure, which can store a fixed-size collection of elements of the same data type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.

Explanation:

Happy to help :-)

Answer:

An array is a data structure, which can store a fixed-size collection of elements of the same data type. a array is used to store a collection of data, but it´s often more useful to think of an array as a collection of variables of the same type.

Explanation:

Multiple choice:
Select the terms relating to comparisons for equality.


A) ==

B) ^=

C) <>

D) =

E) <

F) !=

G) <=

H) >=

Answers

Answer:

Well there is only 1

"==" is checking for equality and "=" is assigning a value to a variable. Although "==" should be the only answer, since the question is asking you to select multiple, I'd select both of those

Jim needs to ensure that a list of items includes the information regarding suppliers in the same report. Which control should he add in Design view? subreport text box combo box label

Answers

Answer:

Labels

Explanation:

The label can be used to attach information. This feature can be used by applying it to the Design View Form. The property sheet feature contains a list of adjustments such as color, font size, and name that the user can apply to the text.

Labels meant for headings can also be used to display commands on the form. Most label controls have a fixed text by default. When a user wishes to attach information to a list, the label control can be used to achieve that.

How do you play game on phone

Answers

You download a game from the App Store
Download it and play it

I need help now I really do what is the answer thank you

Answers

the answer is c
just replace the y with the y value and the x with the x value

While many instruments have been "electrified", there is no such thing for the drums.
Group of answer choices

True

False

Answers

False, because they are called percussion group
False. Because it is fake not true

3.4 lesson practice quiz edhesive

Answers

3.4 lesson practice quiz edhesive :

Write a program to check if user inputs "yellow"

Answer:

In Python:

col = input("Enter Color: ")

if col == "yellow":

   print("True")

else:

   print("False")

Explanation:

This prompts the user for color

col = input("Enter Color: ")

This checks if color is yellow

if col == "yellow":

If true, this prints true

   print("True")

If otherwise, this prints false

else:

   print("False")

How would someone know if their were communication devices placed in their homes illegally. Cameras and USB controlling devices?

Answers

Explanation:

Among the recommended options often suggested by IT experts includes:

In the case of cameras, using a cell phone around the home switch results in unusual signal interference possibly indicates a special radio frequency coming from the illegally implanted device.The use of a mobile app designed for detecting hidden cameras. For example, the ”detect hidden cameras” app available on iPhone or Android mobile devices is a good tool. This app automatically senses  the radio frequencies of any hardware within the device range.

How many days are depicted in the movie stand by me?

I need the answer

Answers

Answer:

I have no idea

Explanation:

2. The
is the main and usually largest data storage hardware device in a computer​

Answers

The answer you are looking for is either Hard Drive or SSD (Solid State Disk).

who is your favorite ducktales character
a. webby vanderquack
b. huey dewey and louie
c. Donald Duck
d. Scrooge McDuck

Answers

Donald Duck for sure.....

Answer:

this is not supposed to be on brainly

Explanation:

i really need help with this:((
Write a program that uses an initializer list to store the following set of numbers in an array named nums. Then, print the array.

14 36 31 -2 11 -6

Sample Run
[14, 36, 31, -2, 11, -6]

Answers

Answer:

sorry i dont know

Explanation:

Fill in the blanks to complete a summary of this part of the passage. For the power of Patents

Answers

i’m confused . what do i do?

Answer:

??

Explanation:

3. Describe the types of input the peripheral nervous system receives in each of the three scenarios.

Answers

Answer:

espanel hjcrkl cuecls oob

Write a function named buildArray that builds an array by appending a given number of random two-digit integers (10-99). It should accept two parameters — the first parameter is the array, and the second is an integer for how many random values to add, which should be input by the user.

Answers

Answer:

The function in C++ is as follows:

void buildArray(int arr[], int n){

   srand(time(NULL));

   for(int i = 0;i<n;i++){

       arr[i] = rand() % 99 + 10;    }

   for(int i = 0;i<n;i++){

       cout<<arr[i]<<" ";

   }

}

Explanation:

This defines the function

void buildArray(int arr[], int n){

This klets the program generate different random numbers

   srand(time(NULL));

This iterates from 0 to n - 1 (n represents the length of the array)

   for(int i = 0;i<n;i++){

This generates random 2 digit integer into the array

       arr[i] = rand() % 99 + 10;    }

This iterates through the array and print the array elements

   for(int i = 0;i<n;i++){

       cout<<arr[i]<<" ";

   }

}

See attachment for complete program that includes the main

Select the correct images Jane has to pick images that portray action photography. Which of these images would she pick? please help me​

Answers

Answer: i think its the horse the basketball and the bike hopefully i helped

Explanation:

ONCE AGAIN Can somebody explain the difficulties and hardships of being a computer engineering?

Answers

Answer:

The only thing I can think of, is stress. I cannot tell you how frustrating it is when you're writing code and it decides to bug out because of some little mistake. For hours you're writing and find out that you're missing a single ";" or an indent.

When you're writing out code in order to solve a problem, you need to break it down step by step in order to actually write it. Otherwise, you'll miss a bunch of steps

an obstacle or barrier that may prevent you from accomplishing your goal is called

Answers

Answer:

a roadblock

Explanation:

A roadblock because it is

Demographics and psychographics influence database marketing.


False

True

Answers

Answer:

true is the correct answer

5.
1 point
*
*
dog#
Choose
This is a required question

Answers

Answer:

WHAT IS YOUR QUESTION ⁉️⁉️

SO I CAN HELP YOU

BECAUSE I APPLIED IN BRAINLER HELPER

1. Many photographs tell a story. What is the story of this photograph? What is happening? Where is the photograph taken? Why is the photograph taken?

2. Good photographs create an emotion or feeling. What emotion does this photograph make you feel? How does the photographer create this emotion in the photograph?

Answers

Answer:

Answer below! Hope I am correct!( I know what happened in that picture, I am sure!)

Explanation:

What is the story of this photograph?

The story is... I think there is a earthquake going on in San Francisco...

What is happening?

There is a earthquake and people are trying to run away & trying to stay safe...

Where is the photograph taken?

Looks like a long time ago, maybe it’s in California (San Francisco) April 19 or 18, 1906.

Why is the photograph taken?

It was a really important & significant earthquakes! So it will be part of history & will be remembered....

What emotion does this photograph make you feel?

It makes me feel really horrible to see that there is a earthquake, I think many people died :( ......

How does the photographer create this emotion in the photograph?

By all the smokes... I can also see people trying to run away from the earthquake.. also I can tell they are really scared!

Hope this helps!

By:BrainlyAnime

Please help!
The ExperimentalFarm class represents crops grown on an experimental farm. An experimental farm is a rectangular tract of land that is divided into a grid of equal-sized plots. Each plot in the grid contains one type of crop. The crop yield of each plot is measured in bushels per acre.

A farm plot is represented by the Plot class. A partial definition of the Plot class is shown below.

public class Plot

{

private String cropType;

private int cropYield;



public Plot(String crop, int yield)

{

/* implementation not shown */

}



public String getCropType()

{

return cropType;

}



public int getCropYield()

{

return cropYield;

}

}

The grid of equal-sized plots is represented by a two-dimensional array of Plot objects named farmPlots, declared in the ExperimentalFarm class. A partial definition of the ExperimentalFarm class is shown below.

public class ExperimentalFarm

{

private Plot[][] farmPlots;



public ExperimentalFarm(Plot[][] p)

{

/* implementation not shown */

}



/** Returns the plot with the highest yield for a given crop type, as described in part (a). */

public Plot getHighestYield(String c)

{

/* to be implemented in part (a) */

}



/** Returns true if all plots in a given column in the two-dimensional array farmPlots

* contain the same type of crop, or false otherwise, as described in part (b).

*/

public boolean sameCrop(int col)

{

/* to be implemented in part (b) */

}

}

(a) Write the getHighestYield method, which returns the Plot object with the highest yield among the plots in farmPlots with the crop type specified by the parameter c. If more than one plot has the highest yield, any of these plots may be returned. If no plot exists containing the specified type of crop, the method returns null.

Assume that the ExperimentalFarm object f has been created such that its farmPlots array contains the following cropType and cropYield values.

The figure presents a two-dimensional array of Plot objects with 3 columns and 4 rows. The columns are labeled from 0 to 2, and the rows are labeled from 0 to 3. Each plot is labeled with a crop name and crop yield as follows. Row 0. Column 0, "Corn" 20. Column 1, "Corn" 30. Column 2, "Peas" 10. Row 1. Column 0, "Peas" 30. Column 1, "Corn" 40. Column 2, "Corn" 62. Row 2. Column 0, "Wheat" 10. Column 1, "Corn" 50. Column 2, "Rice" 30. Row 3. Column 0, "Corn" 55, Column 1, "Corn" 30. Column 2, "Peas" 30.
The following are some examples of the behavior of the getHighestYield method.

Method Call Return Value
f.getHighestYield("corn") ​farmPlots[1][3]
f.getHighestYield("peas") farmPlots[1][0] or farmPlots[3][2]​
f.getHighestYield("bananas") null
Write the getHighestYield method below.

/** Returns the plot with the highest yield for a given crop type, as described in part (a). */

public Plot getHighestYield(String c)

Answers

Answer:

See explanation. I divided it up into part a and b.

Explanation:

PLOT CLASS CODE:

public class Plot

{

private String cropType;

private int cropYield;

public Plot(String crop, int yield)

{

  this.cropType = crop;

  this.cropYield = yield;

}

public String getCropType()

{

return cropType;

}

public int getCropYield()

{

return cropYield;

}

public String toString() {

  return this.cropType+", "+this.getCropYield();

}

}

EXPERIMENTAL FARM CLASS CODE:

public class ExperimentalFarm

{

private Plot[][] farmPlots;

public ExperimentalFarm(Plot[][] p)

{

  this.farmPlots = p;

}

/** Returns the plot with the highest yield for a given crop type, as described in part (a). */

public Plot getHighestYield(String c)

{

  Plot plot = null;

  int highest = this.farmPlots[0][0].getCropYield();

  for(int i=0;i<4;i++)

  {

     for(int j=0;j<3;j++)

     {

        if(farmPlots[i][j].getCropType().equalsIgnoreCase(c) && farmPlots[i][j].getCropYield()>highest)

        {

           highest = farmPlots[i][j].getCropYield();

           plot = farmPlots[i][j];

        }

     }

  }

  if(plot != null)

  return plot;

  else

  return null;

/* to be implemented in part (a) */

}

/** Returns true if all plots in a given column in the two-dimensional array farmPlots

* contain the same type of crop, or false otherwise, as described in part (b).

*/

public boolean sameCrop(int col)

{  

  boolean check = true;;

  String crop = farmPlots[0][col].getCropType();

  for(int i=0;i<4;i++)

  {

     if(!farmPlots[i][col].getCropType().equalsIgnoreCase(crop))

        {

        check = false;

        break;

        }

  }

  return check;

/* to be implemented in part (b) */

}

}

MAIN CLASS CODE:

public class Main {

  public static void main(String[] args)

  {

     Plot p1 = new Plot("corn",20);

     Plot p2 = new Plot("corn",30);

     Plot p3 = new Plot("peas",10);

     Plot p4 = new Plot("peas",30);

     Plot p5 = new Plot("corn",40);

     Plot p6 = new Plot("corn",62);

     Plot p7 = new Plot("wheat",10);

     Plot p8 = new Plot("corn",50);

     Plot p9 = new Plot("rice",30);

     Plot p10 = new Plot("corn",55);

     Plot p11 = new Plot("corn",30);

     Plot p12 = new Plot("peas",30);

     Plot[][] plots = {{p1,p2,p3},

                 {p4,p5,p6},

                 {p7,p8,p9},

                 {p10,p11,p12}};

     ExperimentalFarm f = new ExperimentalFarm(plots);

     Plot highestYield = f.getHighestYield("corn");

     Plot highestYield1 = f.getHighestYield("peas");

     Plot highestYield2 = f.getHighestYield("bananas");

     try {

     System.out.println(highestYield.toString());

     System.out.println(highestYield1.toString());

     System.out.println(highestYield2.toString());

     }

     catch(Exception e)

     {

        System.out.println("null");

     }

     System.out.println("The method call f.sameCrop(0)");

     System.out.println(f.sameCrop(0));

     System.out.println("The method call f.sameCrop(1)");

     System.out.println(f.sameCrop(1));

  }

}

Anna has taken up her first job as an IT help desk technician. Which certification will help her advance her career?

A. Microsoft Certified Solutions Expert
B. CompTIA A+
C. Cisco Certified Network Professional
D. Oracle Certified Professional

Answers

B, I think.

Cisco = networking
Oracle =
Networking as well I think

Hope these points help you.
I love.

Answers

Answer:

Explanation:

thanks, have a great day

Answer:

Thank you so much for the free points! You are so kind.

Explanation:

I hope you have a wonderful rest of your day and if these points were not for me then I must have misunderstood. Have a good one!

(ɔ◔‿◔)ɔ ♥

15.A telecommunication company wants to start a business in Dera Ghazi khan. For Information technology (IT) support, they hired an IT Staff and want to buy hardware from the market. Choose the hardware name which is important for the company.

Answers

Answer:

The company should have computer with secured bandwidth and LAN system which can connect employees on one network.

Explanation:

Telecommunication company will require a network setup which can connect employees on a single network. The network security should be efficient which keeps the LAN network secure from cyber attacks. The IT staff should buy Telecoms equipment and hardware and keep them in a secured control room whose access is limited to certain users only.

What type of malicious software tries to gather information about you without your consent?
Select one:
a. Spyware
b. Viruse
c. Malware
d. Ransomware

Answers

Answer:

B-malware

Explanation:

I do tech and i help work on computars.

Other Questions
Which of the following is an advantage of using stratified random sampling?A-Stratified random sampling saves time and money.B-Stratified random sampling requires knowledge of the entire population.C-Stratified random sampling can be used even when there is not a list of the populationD-Stratified random sampling provides more precise estimates than simple random sampling. What are the correct steps for evolution by natural selection? Write an inequality to express the fact that a checking account balance of $56 is less than a balance of $21. What is the difference in the balances? will give brainliest Mechanical energy that has been lost' to friction isn't really lost. It just is no longer in its mechanical form. True or False Which ordered pair is a solution of the equation 3x y = 10?A. (3, 19)B. (10, 19)C. (10, 21)D. (3, 2) PLEASE HELP MEEEEE THAnK YOU Laila took a very long Math exam and got 24 questions wrong out of 120 questions. What percentage of the total questions did she get correct? Can someone help me???? I would really appreciate some help, please!The graph shows the distance, y, in miles, of a moving motorboat from an island for a certain amount of time, x, in hours:What is the speed of the motorboat? (5 points)Select one:a. 198 miles per hourb. 22 miles per hourc. 44 miles per hourd. 66 miles per hour In which situation would a certificate of deposit (CD) be the best banking choice? Which hormone is responsible for the development of the male secondary sex characteristics?O estrogenO progestinO progesteronetestosteroneThe answer is D on 2021 edge :) Jack held a balloon 12 feet off the ground, straight above his head. NIGEL is standing 18 feet directly to the right of Jack.Write an equation that you could use to calculate the distance from NIGEL's feet to the balloon. Let x represent the unknown distance.x2+122=182 x2+122+182182+122=x2x2+182=122 what is 5.2x10^2 in standard form How did pharaoh khufu proclaim his glory ? What is the probability of rolling an even number on a number cube and flipping a head with a fair coin? Which of the following sentences use an idiom incorrectly? It was then that we decided to call it a day and stop working. John said that he could care less if he doesn't get the job. Lisa is the kind of person who will stick with you through thick and thin. Rich reminded me that it takes two to tango when I complained about our latest argument. Problem 2Label the diagrams that show these two methods for calculating 19x50 Please solve quickly! Qestion: c - 1.5 = 7 Imagine you are going on a trip to a jungle safari. What items do you pack in your suitcase?