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.
 
The book claims the answer is that all the magnitudes are the same because "the gravitational force on the penguin is the same". I'm having trouble understanding this. I thought the buoyant force was equal to the weight of the fluid displaced. Weight depends on mass which depends on density. Therefore, due to the differing densities the buoyant force will be different in each case? Is this incorrect?

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