Computer Science Help C# or Java

AI Thread 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 'Voltmeter readings for this circuit with switches'
TL;DR Summary: I would like to know the voltmeter readings on the two resistors separately in the picture in the following cases , When one of the keys is closed When both of them are opened (Knowing that the battery has negligible internal resistance) My thoughts for the first case , one of them must be 12 volt while the other is 0 The second case we'll I think both voltmeter readings should be 12 volt since they are both parallel to the battery and they involve the key within what the...
Thread 'Struggling to make relation between elastic force and height'
Hello guys this is what I tried so far. I used the UTS to calculate the force it needs when the rope tears. My idea was to make a relationship/ function that would give me the force depending on height. Yeah i couldnt find a way to solve it. I also thought about how I could use hooks law (how it was given to me in my script) with the thought of instead of having two part of a rope id have one singular rope from the middle to the top where I could find the difference in height. But the...

Similar threads

Replies
3
Views
2K
Replies
5
Views
3K
Replies
3
Views
1K
Replies
10
Views
2K
Replies
3
Views
2K
Replies
1
Views
2K
Replies
2
Views
2K
Back
Top