Programming questions are off-topic here. Do not ask questions about how to write code in Java. However, conceptual questions about computer science are more appropriate. See our help center for the scope of this site.
Questions tagged [java]
116 questions
11
votes
2 answers
Why is the Java HashMap load factor 0.75?
I can't understand why the Java HashMap load factor is 0.75. If I understand well, the formula for the load factor is n/m, where n is the number of key and m is the number of position in the hash table.
Since HashMap utilize bucket (i.e., a linked…
Bender
- 367
- 2
- 11
8
votes
1 answer
What fragment of Martin-Löf dependent type theory can be expressed using generic types in Java?
I have recently come to realize that a number of problems I had a few years ago trying to implement various mathematical theories in Java came down to the fact that the typing system in Java is not sufficiently strong to model all of Martin-Löf…
John Gowers
- 183
- 1
- 5
7
votes
2 answers
Formal model of execution for Java (or general imperative language)
I'm trying to prove some statements about execution in Java programs under some heavy restrictions (basically I have a conjecture that if two methods satisfy a set of constraints for a given input then the are they equivalent - i.e., that return…
Ben Kushigian
- 387
- 2
- 7
7
votes
3 answers
Inheritance, and dynamic access to members/attributes and methods in Java-like languages
I have a question about inheritance in Java-like OO programming languages. It came up
in my compiler class, when I explained how to compile methods and their invocation. I was using Java as example source language to compile.
Now consider this Java…
Martin Berger
- 8,358
- 28
- 47
7
votes
0 answers
Are type constructors always injectives even in presence of quantified type variables (subtyping)?
Are type constructors, in a language that feature subtyping and quantification of type variables, like scala or Java, always injective?
That is, is an equivalent of haskell lower function, as seen here, safe in such a language? (even if the…
JbGi
- 71
- 2
5
votes
2 answers
Version of knap sack problem
The are cuisenaire rods with N differnt lengthes $x_1,x_2,...,x_n$ (each length is a natural number), the number of the Cuisenaire rods is unlimited. Given a natural number B. you should tell if you can pick a bunch of Cuisenaire rods with exactly…
Error 404
- 211
- 2
- 8
4
votes
2 answers
How is the formula for calculation in row/column major obtained?
In my book, this formula is given for calculation of address of row major order's element $[I,J]$:
Address of $[I,J]$th element in row major order $= B + W[n(I-L_r)+ [J-L_c]]$
where B denotes base address, W denotes element size in bytes, n is the…
Archer
- 175
- 1
- 1
- 7
4
votes
1 answer
Contracts for Java Bytecode
Introduction
For a paper I need contracts, which are also referred to as Design by Contract (DbC)1, and conceptually go back to Hoare[2]. For my work I need to apply contracts to Java bytecode. The question is only about using contracts on Java…
mrsteve
- 661
- 1
- 4
- 10
4
votes
1 answer
Linked list: advantages of preventing movement of nodes and invalidating iterators on add/remove
C++ and Java include native classes for linked lists, C++ std::list and Java LinkedList
For C++ std::list, nodes can be "moved" within a list, or from list to list (if the lists are compatible), via std::list::splice(), which in turn is used by…
rcgldr
- 364
- 2
- 12
3
votes
1 answer
Is the type inference here really complicated?
There's a question on SO asking why in Java the right type doesn't get picked in a concrete case. I know that Java can't do it in such "complicated" cases, but I'm asking myself WHY?
The (for simplicity slightly modified) line failing to compile…
maaartinus
- 473
- 2
- 9
3
votes
2 answers
What is the Time Complexity of Least Topological Ordering?
I knew the time complexity of Topological ordering is O(V+E) since we don't need to do sorting during the selection of node whose incoming degree is 0. But what about the least topological ordering that make sure every node to delete is always the…
san zhang
- 45
- 5
3
votes
0 answers
How to visualize complex algorithm, like Split Array Largest Sum
I am trying to do the leetcode question
I got the answer and trying to understand a systematical way to come up with the answer using the DP bottom-up approach, and I am having a hard time to understand it, up to m=2.
What would be the best way to…
Jaxox
- 131
- 3
3
votes
1 answer
Sum of unique integers to cnf constraint
As a study project I try to solve the kakuro puzzle problem using SAT SOLVER.
I can't really find an efficient way to convert the sum of k unique integers (1...9) to a CNF constraint.
What I had in mind:
for a group of k cells (1,...k) and a sum of…
misha312
- 209
- 1
- 6
3
votes
1 answer
algorithm to find all values that occur more than n/10 times
I took an algorhytm course on coursera and there some optional questions for student enrichment. I can't solve the following task:
Decimal dominants. Given an array with n keys, design an algorithm to find all values that occur more than n/10…
gstackoverflow
- 131
- 3
2
votes
0 answers
Novel escape analysis algorithm for Java
Today I read a very interesting article about escape analysis in Java called Escape Analysis for Object Oriented Languages: Application to
Java
I think I have some grasp on how escape analysis works and how it is implemented, but I don't understand…
Gaslight Deceive Subvert
- 1,302
- 1
- 9
- 15