Posts Tagged ‘Java’

Google Code Jam Templates

Google Code Jam Logo Thumbnail

Here are some templates that are a good start for Google Code Jam. C++ Compile Execute Python Input: input, raw_input() String parsing: strip(), split() Execute Java This is an ajusted version of mystics solution for “Dancing with Googlers”. You might want to take a look at Scanner and PrintWriter. Adjust the path and execute it [...]

What does volatile mean?

C - programming language - thumb

You might have read the variable modifier volatile in C, C++ or in Java. But do you know what it means? C Programming Language The C Programming language by Kerninghan and Ritchie (second edition) contains this keyword only 13 times. Here are the most important ones: [...] declaring it volatile announces that it has special [...]

How to check if two line segments intersect

Line segments bounding boxes - thumbnail

You have to line segments and you want to know if they intersect. I’ll give you an algorithm how to do it. Test cases First of all, we should think about how lines can be arranged: Bounding boxes You can draw boxes around line segments such that the edges of the boxes are in parallel [...]

What can ArrayList / LinkedList do what List can’t?

Java Thumbnail

I’ve told my students to write instead of as this allows them to switch to any Class that implements List without having to change more code. This does always make sense, except if you need methods from ArrayList or LinkedList. But which methods does ArrayList / LinkedList offer that List doesn’t have? ArrayList has: Object [...]

Basic Multithreading in Java

Multithreading - Thumbnail

A lot of computing power is wasted in many programs as most programs use only one core. If your program is computation intensive, you might want to put some extra effort in your program and make use of this wasted computing power. There are two ways to execute your code on multiple cores: Multiprocessing and [...]

Part II: The Strassen algorithm in Python, Java and C++

Strassen algorithm - Thumbnail

This is Part II of my matrix multiplication series. Part I was about simple implementations and libraries: Performance of Matrix multiplication in Python, Java and C++ The usual matrix multiplication of two matrices has a time-complexity of . This means, if doubles, the time for the computation increases by a factor of 8. But you [...]

How to sort with Java

Java Thumbnail

Sorting is a very basic task that every programmer should be able to solve. In Python, you have sort and sorted. In C++, you can use operator overloading. I’ll now tell you how to do basic sorting with Java. I will not write about natural language sorting or language-aware sorting. This is only about simple [...]