Winning Team error time complexity issues in java program [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 11 hours ago.
Improve this question
Winning Team # Previous
There is a scientific competition held every year in which students participate in the form of teams. the team that solves all the problems wins. We know that every student has power Pi in a subject Si.
This Question JPEG Links - https://i.stack.imgur.com/qzF5p.jpg
It is given that quiz questions will demand powers of Qpj in subject j (where j is from 1 to k). If there are two students with power X and Y in subject Z, the power of the team in that subject will be X + Y.
You have N students and want to choose from them a team that can solve all the problems of the competition and be composed of as few students as possible. It is mandatory that you choose a successive subgroup while selecting a team
Your task is to find the smallest number of students in the team to be able to win. If it is not possible to determine the answer print -1.
Note- Actually in this question time complexity issues is coming. so please make and provide us solutions.
I want solution of this question we can't run this question time complexity issue in execution. we wrote program against this questions. but stuck in middle after 3 seconds remaining execution parts.
We Wrote Java Code

Related

Algorithm to index 2d points by clusters [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have a problem to solve for which I did not find any usable algorithms after an internet search and I have not been able to come up with a satisfying solution myself yet.
Problem definition:
I am given a set of N-many points, defined by their X- and Y-coordinates, and I am supposed to give each point a unique index between 0 and N. There are a few conditions though:
1) if the geometric distance between two points is small, the difference between their indices should be small too.
2) if point A has a higher X-coordinate as point B it should have a higher index value too.
3) if point A has a higher Y-coordinate as point B it should have a higher index value too.
Other:
The algorithm does not need to be particularly fast or efficient as the data is fairly small (50 ~ 100 points).
I need this algorithm for a user interface with only 2 buttons for navigation through a data set. With one button the user selects the next point and with the other the user selects the previous point.
All suggestions are welcome. Thanks in advance.
Example Image:
This is an example of what a result could look like. Please note how the conditions are not fulfilled for all points (as that would be impossible) but how the indices are still nicely distributed among the clusters.
Sort the points by the Morton curve aka Z-order (Wikipedia).
Then assign numbers.

java programming homework 2015 [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
i am having some issues with this question for my homework and was wondering if anyone has any ideas or insights to the answer really struggling ,,,,
You are to amend the program you created last week, this time however the program will ask you to
type the names that need to be stored. Once this is complete the program will display the names in
alphabetical order and display the number of characters for each name and the number of vowels
each name has.
Since this is homework, I'll give you a hint. If you've studied the Java Collections, you can stored the names in alphabetical order. If you've not got to collections yet, the you simply save them off as Strings as they come in.
When it's time to display them in alphabetical order you could:
- sort them before you display them
- or brute force it. Loop thru your storage of names and display all the A's. Then loop thru picking up the B's.
As for counting vowels, look at the Java documentation for the methods that are on the String class. Hint - look for methods that return an "int".

struggling with this simple java object oriented program [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
well simple to many of you i'm sure...
basically we have to create a program to process tickets for a fair. A person can buy more than 1 ticket but they need a print-out at the end for each person attending..
ex. thanks!
child: 1
adult: 1
total: $16
Our program should make just 1 object (use of arrays is not allowed) and when the object is created we will display the name of the county fair.
Kids under 12 pay $5.
Adults pay $9.
a fee of $2 is added to the sale.
i'm just confused at how to set this up because apparently we need a data definition class and a use of a constructor but I only am familiar with doing this only in the Main...
thanks for any help!
Make a Ticket class. It should take a variable age..
Use if statements to assign adult/child and make constant price for each.
As for the print out just after each order, ask if there are anymore tickets to be bought. If no, print out totals.
This is probably a homework assignment, I actually did this last year for APCS. Please just read your book and study the information. This forum is not to do your homework, its to help individuals develop an understanding of programming. Good luck.

Fibonacci Series generation using Matrices [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
There's one question posted about Fibonacci Series, which I am much familiar with it. But there are multiple answers and linked questions to it. As I was digging through it with some interest, there's a solution which is linked to here
This algorithm solves the problem by O(log(n)) quite impressive. But I couldn't understand the logic and so called Matrix exponentiation [looked wiki, but unable to relate to it].
So kindly anyone can explain exactly how they achieved with more details and better explanation [if you can explain with code, prefer in Java, much helpful].
Thanks :)
What you need to understand is the algorithm, not the implementation.
The first thing you need to understand is that this algorithm will not give you all the fibonacci numbers, only those with with a n that is a power of 2.
The second thing is that a multiplication of constantly sized matrices of course takes constant ( O(1) ) time.
The trick now is to correctly note that the n'th fibonacci number can be formed by n-times multiplication of the matrix described in your link, which i will call M.
You get the log complexity by now "reordering" the matrix operations from, for example M*(M*(M*M)) to (M*M)*(M*M). With each matrix squaring, you go to M^2n instead of M^n+1.

Can you give me a Programming problem in java [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am learning java on my own. I have books to read. but i feel i am not really coding anything significant . Can you guys give me any programming problem that would really help me get more practical experience rather than a theoretical experience with java ?
Appreciate it.
silverkid
Many people learn new languages by solving problems from Project Euler.
To give you some examples, here are the 10 first problems in the project:
Add all the natural numbers below one thousand that are multiples of 3 or 5.
Find the sum of all the even-valued terms in the Fibonacci sequence which do not exceed four million.
Find the largest prime factor of a composite number.
Find the largest palindrome made from the product of two 3-digit numbers.
What is the smallest number divisible by each of the numbers 1 to 20?
What is the difference between the sum of the squares and the square of the sums?
Find the 10001st prime.
Discover the largest product of five consecutive digits in the 1000-digit number.
Find the only Pythagorean triplet, {a, b, c}, for which a + b + c = 1000.
Calculate the sum of all the primes below two million.
I just wanted to put an idea out here for you from my own experiences.
Whilst studying I was given the task of creating a Client/Sever chat application, I found it really interesting and there are plenty of obvious ways you can extend the program to better your ability.
For instance, start with a basic server and client simply sending text to one another. And then advance to having users (from a database perhaps) who have to log in to the application. You can make it as simple and as complicated as you wish.
Hope this helps.
Tony
Try this:
Martyr2’s Mega Project List
Java exercises:
http://www.google.com/search?aq=f&sourceid=chrome&ie=UTF-8&q=java+exercise
Java examples:
http://www.exampledepot.com/
What area of Java programming are you interested in? Web, device, desktop?
Sure Why Not, Here it is : http://download.oracle.com/javase/tutorial/

Categories

Resources