Answer:
Explanation:
The following code is written in Java. Both functions traverse the linkedlist, until it reaches the desired index and either returns that value or deletes it. If no value is found the function terminates.
public int GetNth(int index)
{
Node current = head;
int count = 0;
while (current != null)
{
if (count == index)
return current.data;
count++;
current = current.next;
}
assert (false);
return 0;
}
public int removeNth(int index)
{
Node current = head;
int count = 0;
while (current != null)
{
if (count == index)
return current.remove;
count++;
current = current.next;
}
assert (false);
return 0;
}
The odd values in a list can be calculated by knowing the first and last number, whereas even numbers can be divided by two and the remainder is zero (0).
<h3>What are even numbers and odd numbers?</h3>
The even numbers can be found in a list because they are divisible by two and the remainder of this equation is always zero (0).
Conversely, odd numbers are those that cannot be divided exactly into exact entire numbers (e.g., 3, 5, etc).
The odd numbers in a list can be calculated by the equation ON (odd numbers): n/2 × [f + g], where 'f' is the first number and 'g' is the last number.
In conclusion, the odd values in a list can be calculated by knowing the first and last number, whereas even numbers can be divided by two and the remainder is 0.
Learn more about odd numbers here:
brainly.com/question/2263958
#SPJ1