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.
 
I multiplied the values first without the error limit. Got 19.38. rounded it off to 2 significant figures since the given data has 2 significant figures. So = 19. For error I used the above formula. It comes out about 1.48. Now my question is. Should I write the answer as 19±1.5 (rounding 1.48 to 2 significant figures) OR should I write it as 19±1. So in short, should the error have same number of significant figures as the mean value or should it have the same number of decimal places as...
Thread 'A cylinder connected to a hanging mass'
Let's declare that for the cylinder, mass = M = 10 kg Radius = R = 4 m For the wall and the floor, Friction coeff = ##\mu## = 0.5 For the hanging mass, mass = m = 11 kg First, we divide the force according to their respective plane (x and y thing, correct me if I'm wrong) and according to which, cylinder or the hanging mass, they're working on. Force on the hanging mass $$mg - T = ma$$ Force(Cylinder) on y $$N_f + f_w - Mg = 0$$ Force(Cylinder) on x $$T + f_f - N_w = Ma$$ There's also...

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