Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have just started programming with Java and noticed I might need to improve my math skills if i'm to do anything worthwhile with it. I just noticed that some of the exercises should be easy for someone with a solid understanding in math as there seems to be some math formulae running the show. I finished high school two years ago and did not get any opportunity to do math at the highest level there. I'm deeply worried by this and so i'm looking for pointers from more experienced and knowledgeable people on what I should study to get a basic grasp of mathematics before indulging in deep waters.
I was generally a sharp student in math and I have got a real quick mind. My goal is to become a certified and well-experienced Java programmer by the end of the year. I know people will say experience takes time and effort but i'm willing to sacrifice whatever that I have towards fulfilment of this goal. I have programmed with PHP and MySQL a bit before and got a general understanding but Java gave me a real kick when I read about it. If you know any other stuff that may help me in this endeavour, please let me know.
Thanks.
I strongly encourage you to read Steve Yegge's Math for Programmers.
If you're looking for some books, I recommend Concrete Mathematics and The Art of Computer Programming.
If you're looking for some problems to practice with, check out Project Euler.
Do not be discouraged by challenging problems. It's is only through overcoming challenges that you will grow. The community here is quite willing to give you assistance and nudges when you reach a roadblock.
Let's also not forget the famous quote:
Whatever your difficulties in mathematics, I can assure you mine are far greater.---Albert Einstein
My goal is to become a certified and well-experienced Java programmer by the end of the year.
Finally, the only way to become well-experienced is to write code, and lots of it.
Discrete Mathematics is what you are most likely needing. Understanding base 2 (binary) base 16 (hex) number systems is helpful a must. You don't have to get bogged down in discrete mathematics as some of that is way too deep and makes math majors cringe. Look over basics such as sets and logic.
As for trig/calculus... I have taken all these in college and have never relied on these extensively... or well, at all.
Mathematical aptitude is not necessarily a prerequisite for being a good programmer. There is a strong association though in that good programmers tend to be good at math. That doesn't mean that learning more math will necessarily make you a better programmer. To become a better programmer usually takes a lot of coding. So with that in mind:
Code much and often and with best practices, try not to "cheat"
Challenge yourself
Try working through some problems on Project Euler
Trying doing advanced Sudoku in your head to practice deduction and to warm up
Linear equations, matrix algebra, Base 2, 8 ,18, and 10 conversions, logarithms, and set theory (intersections, unions, etc) will give you a basic foundation. If your algebra is sound, look into discrete mathematics, precalculus, and trig. Once you've gotten that far, you should have no trouble continuing if you wish.
Honestly, it may be worth your time to take a placement test at a local community college to get an honest evaluation of your skills. From there, you have the choice of enrolling in a class or learning their curriculums through self-instruction.
Go through http://www.khanacademy.org/ math section. Most people graduate high school with only Calculus I under their belt.
If you go through all math here, you will have almost satisfied math requirements for a bachelors in CS. What remains is discrete math, algorithms, finite automata.
Check out MIT Open Courseware for that as well.
IF you have any free time left after all these great suggestions, I might throw Head First Statistics on your reading list as well.
http://www.amazon.ca/Head-First-Statistics-Dawn-Griffiths/dp/0596527586
While not directly related to core Java programming, statistics finds many uses in some areas of computer science. For example, i"ve found this book very useful in some of the data mining projects I've been a part of.
I recommend this book because it is very easy and fun read, and serves as a good intro to statistics without bogging you down. This is that "before bead" reading you can do with minimal effort.
This isn't recommendations so much as general encouragement; I learn by doing. Reading books on mathematics, out of the context of some problem to solve, is boring, dry and generally not conducive to learning. I find if I set myself a programming challenge, one that is above my current level of competency, I will learn a lot and open up new areas of knowledge as a consequence of solving the problem. Perhaps it's harder/slower this way, but I find it gives me a solid, practical grounding in a subject. For example, back in the days I learned a lot about modulo mathematics by trying to find the simplest way to do human Vs computer rock-paper-scissors game.... My two cents.
I've quite often tried working through books, and have a good selection of partly read maths books. I gained a lot doing a second-year Open University pure maths course (M208) a couple of years ago - it's well structured, you have to do all the exercises, and it was both wide enough to introduce a few things I wouldn't have looked at off my own bat, but deep enough to be satisfying.
"Concrete Mathematics" would be a book suggestion on this topic.
Related
I have a challenge that my teacher gave to beat an army of his soldiers on a 18x24 grid, with random obstacles placed on the board. The game is turn based and I have an army of 50 soldiers, each of which needs to either move or attack on their turn.
My problem is I only have access to creating a class of soldiers to fight in this environment. Currently I have a method that evaluates the board position by looking at how many soldiers there are left from each team and does yourTeam - enemyTeam to get the current score, and I have a method that will produce the legal moves for the soldier.
I want to know how I would create a reinforcement learning agent in Java with what I have access to. If you know any ways to do this or any resources that may help that would be great. Thank you for the help!
Java is not a good language for doing math heavy computation (which is what you will need to do for RL). You could attempt to implement the Q-Learning, value-iteration or policy-iteration algorithms but I would avoid doing anything with neural networks/modern deep RL approaches here as your work load will increase dramatically.
With regard to your problem, if you are to implement one of the old-school algorithms. Think about your state and action space. I have serious concerns about the size of your action space, even with a small number of moves for each solider (say 3 - attack, move up, move down) with 50 soldiers the action space will be very large - 50^3, even this many will be difficult to deal with, any more (even 4 or 5) will send you deep into some complex topics in RL.
Other problems are - defining a good reward signal, efficiently running (potentially millions) of simulated games.
The short answer is, this is not something to be taken lightly, it would be challenging and time consuming even for someone who has experience in the field and using Java is a no-no (Python is better). Given you probably don't have long to find a good solution, I would recommend trying a different approach - planning based maybe, or hard coding a reasonable strategy.
If you still want to go ahead and read up on the topic here are some good resources:
Reinforcement Learning an Introduction (Sutton & Barto) - any edition is fine
Selected chapters in Artificial Intelligence: A Modern Approach (Russel & Norvig)
Hope this helps and sorry it may not have been the answer you we hoping for!
Does anybody know how these 2 solvers, (Oj algorithms) from Java and SCIP for Python, relate to each other performance wise (as in: which one is the fastest), when dealing with a typical MILP (Mixed Integer Linear Programming) problem? On first sight, I can't seem to find anything online that can point me in the right direction, and I'm curious!
Thanks in advance!
The SCIP Optimization Suite is one of the fastest MIP and MINLP solvers available in source code. PySCIPOpt, its interface to Python, might be a bit slower when constructing the model but solving times are still good since it's running the pure SCIP C library in the background.
To be honest, I have no experience with oj! Algorithms and cannot say how good this solver is. Apparently it allows to link to Gurobi or CPLEX, so guess in this case it's mainly a modelling wrapper around those APIs providing high performance.
In the end it comes down to your modelling preferences/requirements and your specific problem instances.
Disclaimer: Not Homework
I've written very basic calculator parsers in Java using tokenizers, but I have recently started writing a problem to help me understand chemistry. As I began writing more and more formulas, it became increasingly apparent that the complexity required to solve for each equation is almost more tedious than mastery of the equations themselves. Take the equation PV = nRT, how could I write a parser that would allow me to input all know variables and solve if it was solvable? I can do the logic behind solvability, but here are a few requirements:
must be able to solve for any unknown variable.
parsing should be capable for formulas of any size (ex: I want to implement more than one formula, such as π = MRT and formulas of increasing complexity, and only want to have to define them once.)
Once again this is purely for my enjoyment and to be used as a learning tool. Any help would be appreciated, as searching Google and StackOverflow for this problem have given me either vague or inapplicable answers.
As you have posted no code I will speak my thoughts.
I used to have an hp48G calculator which had a library with many formulas covering different areas.
Instead of parsing a single line, you had to choose through menus which was the formula to apply, then the calculator would ask for each parameter separately, and apply it to the formula to provide the result.
If you follow this approach, and helped with java's interfaces I think you can do something like you are asking.
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 6 years ago.
Improve this question
I'm Working on document classification tasks in java.
Both algorithms came highly recommended, what are the benefits and disadvantages of each and which is more commonly used in the literature for Natural Language Processing tasks?
At the very basics of it, the major difference between the porter and lancaster stemming algorithms is that the lancaster stemmer is significantly more aggressive than the porter stemmer. The three major stemming algorithms in use today are Porter, Snowball(Porter2), and Lancaster (Paice-Husk), with the aggressiveness continuum basically following along those same lines. Porter is the least aggressive algorithm, with the specifics of each algorithm actually being fairly lengthy and technical. Here is a break down for you though:
Porter: Most commonly used stemmer without a doubt, also one of the most gentle stemmers. One of the few stemmers that actually has Java support which is a plus, though it is also the most computationally intensive of the algorithms(Granted not by a very significant margin). It is also the oldest stemming algorithm by a large margin.
Porter2: Nearly universally regarded as an improvement over porter, and for good reason. Porter himself in fact admits that it is better than his original algorithm. Slightly faster computation time than porter, with a fairly large community around it.
Lancaster: Very aggressive stemming algorithm, sometimes to a fault. With porter and snowball, the stemmed representations are usually fairly intuitive to a reader, not so with Lancaster, as many shorter words will become totally obfuscated. The fastest algorithm here, and will reduce your working set of words hugely, but if you want more distinction, not the tool you would want.
Honestly, I feel that Snowball is usually the way to go. There are certain circumstances in which Lancaster will hugely trim down your working set, which can be very useful, however the marginal speed increase over snowball in my opinion is not worth the lack of precision. Porter has the most implementations though and so is usually the default go-to algorithm, but if you can, use snowball.
Snowball - Additional info
Snowball is a small string processing language designed for creating
stemming algorithms for use in Information Retrieval.
The Snowball compiler translates a Snowball script into another
language - currently ISO C, C#, Go, Java, Javascript, Object Pascal,
Python and Rust are supported.
History of the name
Since it effectively provides a ‘suffix STRIPPER GRAMmar’, I had toyed
with the idea of calling it ‘strippergram’, but good sense has
prevailed, and so it is ‘Snowball’ named as a tribute to SNOBOL, the
excellent string handling language of Messrs Farber, Griswold, Poage
and Polonsky from the 1960s.
---Martin Porter
Stemmers implemented in the Snowball language are sometimes simply referred to as Snowball stemmers. For example, see the Natural Language Toolkit: nltk.stem.snowball.
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
When interviewing college coops/interns or recent graduates it helps to have a Java programming question that they can do on a white board in 15 minutes. Does anyone have examples of good questions like this? A C++ question I was once asked in an interview was to write a string to integer function which is along the lines of the level of question I am looking for examples of.
Is there any reason why it has to be on a whiteboard? Personally, I'd rather sit them in front of a keyboard and have them write some code. Our test used to be a simple 100 (IIRC) line Swing text editor. We then broke it a few simple ways, some making the code not compile and some a little more subtle, and gave the candidates half and hour and a list of problems to fix.
Even if you can't have them do anything hands on make sure that you do give them some explicitly technical questions. In another round of interviews there were a surprising number of recent graduates who were just buzzword-spouting IDE-jockeys, so they could look OKish waving their hands around in front of a whiteboard talking about Enterprise-this and SOA-that, but when given a simple Java fundamentals multiple choice exam asking things about what final and protected meant did horrifyingly badly.
I've always thought that algorithmic questions should be language agnostic. If you want to test the java level of a student, focus on the language: its keywords (from common one like static to more exotic one, like volatile), generics, overloading, boxing/unboxing of variable, standard libraries.
Some stuff that has showed up on SO:
IsPalindrome(string s)
ReverseWordsInString(string s): "I know java" --> "java know I"
Other stuff that springs to mind:
multiply a Vector with a Matrix (can this be done OO-Style?)
echo (yes, a simple clone of the unix tool)
cat (15 min should be enough, should weed out the clueless)
a simple container for ints. Like ArrayList. Bonus question: Generic?
Write a function to swap variable values using pointers (Really poor ones will fall for this)
Write a program to find the distance between two points in the XY plane. Make use of a class to store the points.
Demonstrate the use of polymorphism in java using as simple program.
Write a program to print the first n prime numbers.
Write a program to replace a string in a file with another.
If you don't know what questions to ask them, then may be you are not the right one to interview them in Java. With all due respect, I hate when people ask me questions in interviews which they themselves don't know answers for. Answers for most of the questions can be found online by googling in a few secs. If someone has experience in Java, they will definitely know Abstract class, interface etc as they are the core building blocks. If he/she does not know 'volatile' keyword - big deal.
I agree with Nicolas in regards to separating the algorithmic questions from the actual language questions.
One thing that you might want to consider is giving them a couple simple algorithm questions that they can write up the pseudo code for on the white board (ex. "Explain to me the Bubble sort and show me the pseudo code for it."
Then once they have demonstrated their algorithmic knowledge you can move on to the Java questions. Since some people work better in front of a computer than in front of the whiteboard, I would give them something simple, but leveraging their knowledge of Java, that they can implement in 30 minutes or so in using the same IDE that you are using at the company. This way if they claim to know the IDE you can also get an idea of how well they know it.
Write a function that merges two sorted lists -- stopping at limit. Look for the easy optimizations and correct boundary checks / sublist calls. Tell them T implements compareTo.
public List<T> merge(List<T> one, List<T> two, int limit)
Write a function that returns true if any two integers in the array sum to the given sum. Have them try to do better than n squared using some sort of set or data structure.
public boolean containsSum(int[] nums, int sum)
I would avoid asking them questions that would have been covered in their undergrad classes. I would be more curious about their ability to apply everything they've learned to solve complex technical problems. If your business has a specific need for an IT solution you could use that as a starting point. You could ask the candidate what technologies they would use and the pros and cons of using those technologies versus alternate technologies. As the discussion progresses you could get a feel for their technical skills, problem solving skills, interpersonal skills, etc. I think it is important to avoid coaching them, even in awkward moments. This is important to weed out the BSers.