Computer Science Help C# or Java

Click For Summary
The discussion centers on a user's challenge in implementing a second method in C# after successfully completing the first method for deleting a node from a linked list. The user shares their code for the deletion method, which navigates through the list to remove a specified node. They seek assistance in counting the length of a sequence and tracking the longest sequence found. The forum emphasizes the importance of showing attempts to encourage collaborative problem-solving. Overall, the user is looking for guidance on advancing their coding skills in C#.
dan2222
Messages
6
Reaction score
0
Homework Statement
1. A method gets a linked list of integers: 'lst', a reference position - 'p' to one of the values in the list, and a positive integer number.
The method updates the list in the following way - deletes several values from place p.

2. A method gets a list of integers and looks for the longest sequence arranged in ascending order) Suppose there is one maximum sequence.
The method should delete the maximum sequence from the given list and return the list after the change. Suppose as a sequence that actually rises is considered larger than 1.

Example 1:
lst ={ 3, 1, 2, 3, 2, -3, -1, 2, 4, 7,2 }
The maximum sequence is { -3, -1, 2, 4, 7}
The action will return lst = {3, 1, 2, 3, 2, 2 }

Example 2:
lst ={ 1, 0, 1, 6, 12, 23, 90 }
The maximum sequence is: {0, 1, 6, 12, 23, 90}
The action will return: lst = {1 }
I succeded to do the first method, but I could not do the second one.
The first method:
Code:
   public static Node<int> Delete(Node<int> lst, int num)       
        {
            Node<int> p = lst.GetNext();

            for (int i = 1; i < num; i++)
            { 
                p = p.GetNext();
            }

            p.SetNext(p.GetNext());

            return p;
        }

Thanks for those who can help!
 
Last edited by a moderator:
Physics news on Phys.org
Per forum rules, you need to show an attempt.
Start by finding a way to count the length of a sequence.
Then consider how you might keep track of the longest sequence found so far.
 
Thread 'Correct statement about size of wire to produce larger extension'
The answer is (B) but I don't really understand why. Based on formula of Young Modulus: $$x=\frac{FL}{AE}$$ The second wire made of the same material so it means they have same Young Modulus. Larger extension means larger value of ##x## so to get larger value of ##x## we can increase ##F## and ##L## and decrease ##A## I am not sure whether there is change in ##F## for first and second wire so I will just assume ##F## does not change. It leaves (B) and (C) as possible options so why is (C)...

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 10 ·
Replies
10
Views
2K
Replies
8
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K