Posts by Jefferson Quesado • 22,370 points
421 posts
-
4
votes2
answers5665
viewsA: Doubt in While with two conditions
Under stopping condition, while, semantics of the language and the title of the question Like the @Maniero spoke, the error lies in its interpretation and how to express it in the programming…
canswered Jefferson Quesado 22,370 -
2
votes3
answers536
viewsA: Instanceof with List in JAVA
In the reply by @Sorack, it provides two alternatives on how to treat the issue. A Reply from @Victorstafusa provides more details and offers the solution via toString() mentioned by @Sorack. I’m…
-
7
votes3
answers39830
viewsA: Configure . gitignore to not upload certain files
I would like to add a few more considerations than there are in the @Guillhermenascimento and of @Brunofelipe. These are general considerations of the structure of .gitignore for extra…
gitanswered Jefferson Quesado 22,370 -
9
votes4
answers3512
viewsA: What do reticence in the parameters of a method mean?
Note: that answer initially I gave in a question that was later identified as a copy of this question from here. Since the answers given in this question do not exemplify how to use varargs (just…
javaanswered Jefferson Quesado 22,370 -
0
votes1
answer899
viewsA: Newton-Raphson algorithm
The error is in the definition of Abs. Currently, Abs(4) will return -4. So just find the first f(x) positive that will come out of the loop. The correction is as follows: float Abs( float x ){…
-
3
votes1
answer319
viewsA: java.lang.Stackoverflowerror: stack size 1038KB
The problem here is the recursion size. Its recursion is approximately 621,000 calls, given the 788 x 788 image. Each recursive call at least inserts the call arguments into the stack. In this case,…
-
20
votes3
answers2716
viewsA: How to prove the asymptotic order of an algorithm?
The complexity of algorithms is given by a function. When we are dealing with classic nonrecursive problems, we usually come across polynomials. TL;DR, the @Isac response shows in a very elegant way…
-
4
votes2
answers282
viewsA: Almost prime numbers
A number k-quasi-primo is given because it consists of a product of primes with k factors. Examples: 15 = 3 * 5 is 2-quasi-primo, 9 = 3 * 3 is 2-quasi-primo, 16 = 2 * 2 * 2 * 2 is 4-quasi-cousin, 5…
-
4
votes2
answers466
viewsA: How to merge two multidimencional arrays, disregarding repeated values?
To solution from @Wictorchaves is sufficient for the question given the size of the data. The solution I propose below is Overkill, with an entry some orders of magnitude above what is being used…
-
1
votes1
answer220
viewsA: How to generate an Insert string from json
Taking into account that you want to turn JSON into a query INSERT valid in Sqlite, we have to cross the object passed and save the keys and their values. I will store these values in two vectors,…
-
2
votes1
answer278
viewsA: Iterate over two List optimally - Algorithm Optimization O(n²) C#
whereas graph.Connections have size n and primaries have size k, has an approach that runs in time o(n log(n) + m log(m) + (n + m)). This approach is divided into two steps: data preparation (o(n…
-
1
votes2
answers442
viewsA: How to calculate the percentage of Likes?
You want to know what the occurrence of a certain feature in a set. If every element has equal weight, the formula is: Contagem de indivíduos com a característica / total de indivíduos In case, you…
-
1
votes2
answers254
viewsA: Problem when compiling c++ Singleton
Basically, you are trying to compile a file to become an executable. It is not being compiled for library (neither static nor dynamic), using an object file as an intermediate. Analyzing the…
-
0
votes2
answers105
viewsA: Error trying to imprint the return of a two-dimensional matrix
Let’s see what kind of r: int*. This means that it is only a pointer. A simple is pure pointer. Pointers basically have two operations: De-referencing (operator *), which returns the type pointed;…
-
6
votes1
answer1224
viewsA: What is the best implementation of 'Mergesort Algorithm'?
TL;DR I optimized the creation of the auxiliary work vector and the expected time to run the merge Sort v3 is 4.29 ms +- 0.78 ms Look at the data I got: Repetições do experimento de BUBBLE SORT: 100…
-
0
votes2
answers91
viewsA: Is it possible to assign the first column of a row of a/a vector/matrix?
When you put v2[0] or v2[1], you are not yet referring to a character. To refer to a character, you need to put the two indexes, such as v2[0][0], or v2[1][0]. The guy char[2][] needs two indexes to…
-
0
votes2
answers67
viewsA: How to perform an arithmetic operation by changing numerous database fields efficiently?
The point here is to get the item n and decrease it from p. In this case, the elements of the range [n - p, n) need to be incremented. In SQL, these two update operations would be the following…
-
0
votes1
answer75
viewsA: How to paint certain lines in a totalcross.ui.Grid
Yes, the Grid.CellController allows control the way you want it. If you downloaded Totalcross from the site, then you must have noticed a folder src in the place where you install it. Inside, look…
totalcrossanswered Jefferson Quesado 22,370 -
4
votes3
answers241
viewsA: Identifying SQL brothers
My idea is similar to idea by @Sorack, but I am trying to do without joining by the name of the parents. In this case, I define a IRMANDADE (name borrowed from proposal by @Alexandrecavaloti) and…
-
1
votes1
answer451
viewsA: Slowness during JSON List Conversion using Jsonfactory
The first point here is to identify the problem, not to fall into the problem of Maslow hammer. If we start to try to solve the problem by space solution (that is, start to solve from known…
totalcrossanswered Jefferson Quesado 22,370 -
1
votes2
answers322
viewsA: Doubt about how to iterate on an Arraylist
Item D wants you to simply scroll over the list. You can iterate in several different ways at java, but my favorite is the following: ArrayList<Contato> agenda; // preenche agenda for (Contato…
-
1
votes2
answers1174
viewsA: Data Comparison in Files [C]
You want to create the following set C: To do so, you need to answer two questions: How to identify e belonging to A? How to identify e not belonging to B? As in our case A is a file then e belongs…
-
4
votes2
answers271
viewsA: What defines a neural network as perceptron?
The perceptron is a single, solitary processing neuron with supervised learning. It receives pulses from various stimuli, then applies the relative weights of its synapses and then emits an output…
-
21
votes2
answers45560
viewsA: What is the correct way to use the float, double and decimal types?
About float and double These are types defined by the IEEE. Their representation is given by the sign, exponent and mantissa. Without taking the details, if you have 3 digits to represent the…
-
3
votes2
answers202
viewsA: SQL query with duplicate items
By my understanding, you want to ask the following: What are the queries that had parameters within 14 days after your registration? If that’s the question, then the relationship is incomplete. I…
-
5
votes1
answer295
viewsA: Stackoverflow in Quick Sort
The problem is an infinite recursion. I’ll put the original code and then fix: static Musica[] ordenarMusicosIDQuickSort(Musica[] musica, int left, int right){ if(left<right){ int posicaoPivot =…
-
2
votes1
answer808
viewsA: Send Image with Socket Java
Using pure and raw socket, this issue deals with 4 points: file reading socket writing open server socket reading from a server socket NOTE: for simplicity and brevity I am not using buffered…
-
2
votes2
answers413
viewsA: Reverse
To swap two integer numbers of variables, we can do the following: int a = 2; int b = 4; int swapAux = a; a = b; b = swapAux; We can use the same logic to swap integers at vector positions. Let i a…
-
3
votes2
answers2437
viewsA: Invert Simple List
There are several alternatives to this inversion. Keep in mind that you cannot lose the next element of the list, you should always keep a reference to it. I like the recursive alternative to this…
-
1
votes1
answer46
viewsA: SQL - Crossing tables within tables
Let’s start connecting the tables A and C, so we will definitely have a pcs_novo valid: SELECT coalesce(A.pcs_novo, C.pcs_novo) as pcs_novo, A.pcs_antigo, A.outros_a FROM A LEFT JOIN C ON…
-
0
votes2
answers1178
viewsA: How to define Enumeration in JSON
JSON is not a syntax-rich format to indicate several semantics. He leaves it to whoever is interpreting him, who is responsible enough to interpret it correctly. JSON only sends information back and…
-
1
votes2
answers3232
viewsA: Assign one class to another in C++
You are trying to treat a mother class object as an object of the daughter class. It does not work. Concrete example Imagine you have the classes animal, gato (inherited from an animal) and…
-
2
votes1
answer860
viewsA: Typeerror: can’t Multiply Sequence by non-int of type 'float'
In Python 3, divisions return real numbers. For entire division, use //: (l + (r - 1)) / 2 # se (l + (r - 1)) for ímpar, retorna x.5 (l + (r - 1)) // 2 # se (l + (r - 1)) for ímpar, retorna o x…
-
6
votes2
answers699
viewsA: What would be a tree and a forest?
All are graph-based data structures. Roughly speaking, a graph is a structure defined by a set of points P and a set of edges A, where an element a of the whole A has two attributes, a.origem and…
-
7
votes2
answers605
viewsQ: Why do I need './' to run Unix commands?
I noticed that every executable that I Gero I need for a ./ to run it on both Linux and Macos (Unix/Unix systems-like). For example, to compile a C file with GCC and run it right away, I do the…
-
4
votes1
answer244
viewsQ: Set MIME-type of a file on Android
I need to dynamically figure out what the MIME-type of a file is. Initially, I only need to identify videos, but I intend to use this to identify HTML pages, photos, PDF etc.
-
4
votes1
answer244
viewsA: Set MIME-type of a file on Android
Information extracted and mined from of this answer in the international SO If you do not have direct access to the file (such as being available via FTP or HTTP), you can try to rescue MIME-type by…
-
4
votes1
answer3315
viewsA: Revert a git reset hard
Tidying up this data starts with the git fsck. This command checks the git database to see if everything is right. its name is derived from the tools used to check sanity in file systems, File…
gitanswered Jefferson Quesado 22,370 -
4
votes1
answer66
viewsA: Problems with Nullpointerexception
Start the value of alunosFiltrados in the declaration of the attribute: private List<Aluno> alunosFiltrados = new ArrayList<>(); If you need to define this variable externally, put it in…
-
0
votes1
answer557
viewsA: Visual G : What does the character ' mean and how does it influence the results?
By the documentation, the visualg is following the Pascal model of writing. Anything, see the documentation in Pascal About the code: x:4:1 means four characters at the most on the output, one after…
-
12
votes4
answers6112
viewsA: VHDL is a programming language?
VHDL is a programming language? Do you consider an Unrestricted Grammar a programming language? Each of these grammar solves a problem in the same way that a Turing machine solves a problem. You can…
vhdlanswered Jefferson Quesado 22,370 -
15
votes2
answers930
viewsA: What is a meta language?
In short? A language used to describe other languages. BNF describes derivation rules for context-free grammars, so it is possible to write any context-free language (such as the Java language, or…
-
5
votes6
answers14517
viewsA: How to define the largest prime number within a given number?
UPDATE: Anderson Carlos Woss has a great answer about Crivo, answered a month before mine: /a/206144/64969 I was a member of the Programming Marathon team at my college. We were the Balloon…
pythonanswered Jefferson Quesado 22,370 -
5
votes1
answer423
viewsA: Implementing Regular expression in Java
Believe me, what you want to do is called compilação. Yes, you need to compile the code to make the perfect count. No, you do not need to generate a bytecode with this compilation. I know of no…
-
1
votes1
answer1462
viewsA: Group duplicate Sql Server lines
When you use grouper function (such as SUM), it will take into account all lines that are differentiated by GROUP BY. In case, your GROUP BY included in its column clause est.EstoqueAtual. If you…
-
5
votes1
answer461
viewsQ: Rescue all nodes from an Sqlite database tree
I have a serialized tree in my database in the table arvore. Like any good tree, every node can have at most a single parent node. Your data is in this format: id | id_pai | valor…
-
6
votes1
answer461
viewsA: Rescue all nodes from an Sqlite database tree
To solve this, we need to make a recursive query. To make a recursive query, we use the Common Table Expression (CTE). Note that the Sqlite documentation itself informs that Ctes are part of the…
-
7
votes1
answer802
viewsA: How to center map in the middle of polygon?
The idea is to calculate the barycenter of a polygon and use it as a map coordinate. The baricentro of a polygon is given by the arithmetic mean of the coordinates (cartesians!, important detail for…
-
5
votes1
answer355
viewsA: Get all data with the same id without knowing the id
You can get this information by making a join of the table with itself: SELECT t2.* FROM josyo_rsform_submission_values t1 INNER JOIN josyo_rsform_submission_values t2 ON (t1.id = t2.id) WHERE…
-
3
votes3
answers2728
viewsA: How to select this piece of text in Regex
I recommend making regular expressions always gradually, by parts. Look how I built a expression to validate emails. Come on, get the more general: .* Here we marry everything, so let’s filter. It…
regexanswered Jefferson Quesado 22,370