Computer Science Help C# or Java

In summary, C# and Java are both popular object-oriented programming languages used for developing software and applications. C# is mainly used for Windows applications, while Java is platform-independent. Both languages are suitable for beginners, but Java may have a simpler syntax. It is possible to use C# and Java together in a project, but it may require additional tools. Professionals with knowledge of both languages have a strong job outlook, and there are many online resources available for learning C# and Java.
  • #1
dan2222
6
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
  • #2
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.
 

FAQ: Computer Science Help C# or Java

What is the difference between C# and Java?

C# and Java are both object-oriented programming languages, but they have some key differences. C# is primarily used for developing applications on the Microsoft platform, while Java is more versatile and can be used on multiple platforms. Additionally, C# is more closely tied to the .NET framework and has a simpler syntax, while Java has a larger standard library and is more verbose.

Which language is better for beginners, C# or Java?

Both C# and Java are good languages for beginners to learn. C# may be slightly easier to pick up due to its simpler syntax, but Java has a larger community and more resources available for beginners. Ultimately, the best language for a beginner to learn will depend on their personal preferences and goals.

Can C# and Java be used together?

Yes, it is possible to use both C# and Java in the same project. This is often done through interoperability, where code written in one language can be accessed and used by the other language. For example, a C# application can call a Java library or vice versa.

What are some common applications of C# and Java?

C# is commonly used for developing Windows desktop applications, web applications, and games. Java, on the other hand, is used for a wide range of applications including web development, mobile development, enterprise software, and scientific computing. Both languages are also popular for developing backend systems and server-side applications.

Is it necessary to learn both C# and Java?

No, it is not necessary to learn both C# and Java. While they are both popular and widely used languages, they have similar principles and concepts, so learning one will make it easier to learn the other if needed. It is more important to focus on learning the fundamentals of programming and problem-solving, which can then be applied to any language.

Similar threads

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