Questions tagged [processing-efficiency]
622 questions
3
votes
1 answer
Is getLine lazy?
Is getLine lazy?
Say I have a very long line on the input. It's just a sequence of numbers. I only need to sum 3 first numbers. Will getLine be efficient and read only the first part of the line, or do I have to create my own function for lazy line…

Andrzej Gis
- 13,706
- 14
- 86
- 130
3
votes
1 answer
Creating a "satisfactory" Minimum Spanning Tree (MST) given only vertices
Classic MST Problems
In the classic formulation of the Minimum Spanning Tree (MST) problem, we are given a set V of vertices and a set E of edges. Although there are
possible edges given V vertices, the number of edges is usually much smaller than…

Moshe Rubin
- 1,944
- 1
- 17
- 37
3
votes
3 answers
How do I efficiently make use of the result of a function call in a MySQL query multiple times without calling the function multiple times?
I have an SQL query like:
SELECT blah
FROM table
WHERE field1 % functCall(otherField1, otherField2) = 0
OR field2 % functCall(otherField1, otherField2) = 0
OR field3 % functCall(otherField1, otherField2) = 0
Is there a way that I can…

John Kurlak
- 6,594
- 7
- 43
- 59
3
votes
2 answers
List> vs. String[][]
I'm looking to create a 2D String 'matrix' object in Java. My two goals with this are for efficiency and code simplicity.
I've heard that using an ArrayList is quite a bit more efficient than a String[][]. Firstly, I'm wondering if that's true, and…

Bobby
- 1,416
- 1
- 17
- 30
3
votes
3 answers
Merged two dataframe columns with lists in order of lists
I'm trying to merge/concatenate two columns where both have related, but separate text data delimited by "|" in addition to replacing certain names with "" and replace the | with '\n'.
For example, the original data may be:
First Names …

wingsoficarus116
- 429
- 5
- 17
3
votes
2 answers
SELECT ... WHERE IN vs JOIN
Assume we have 4 tables A, B, C, D in some unspecified relational SQL database. A references B, also C and D as well. References means that A has column A.refX_id = X.id, X is A, B and C (common foreign key 1:N).
What I want, is to query table A…

David
- 1,055
- 8
- 23
3
votes
1 answer
Vectorize Triple Loop - MATLAB
I have the following large, very inefficient loop.
P is a [2000 x 200 x 5] matrix
D is a [2000 x 200 x 5] matrix
S is a [200 x 1005] matrix
PS is a [2000 x 1000 x 5] matrix
I want to compute the following loop:
for k=1:2000
for n=1:200
for…

phdstudent
- 1,060
- 20
- 41
3
votes
3 answers
Replace several words in a text with Python
I use the below code to remove all HTML tags from a file and convert it to a plain text. Moreover, I have to convert XML/HTML characters to ASCII ones. Here, I have 21 lines which read whole the text. It means if I want to convert a huge file, I…

Alin
- 350
- 2
- 13
3
votes
4 answers
How do I optimize sapply in R to calculate running totals on a dataframe
I wrote a function in R to calculate cumulative totals by month number, but the execution time of my method grows exponentially as the dataset gets larger. I'm a novice R programmer, can you help me make this more efficient?
The function and the…

Jonathan
- 491
- 5
- 19
3
votes
2 answers
R only using 13% of my processor
System:
OS - Windows 7
RAM - 8GB
Processor - Intel i7
R version - Always keep it up-to-date
Problem:
R is using only 13% (i.e. 1 out of 8 cores) of my Intel i7 Processor. I want to tap multiple cores for running my code faster. But unfortunately…

Pragith
- 86
- 9
3
votes
3 answers
Is manually updating a for loop iterator bad practice?
I have a program that loops over a list of vehicle co-ordinates and then performs other functions on them. I am only looking for pairs of successive co-ordinates that are not too close together. If a vehicle is stationary for a long time, there is…

Jags
- 1,639
- 1
- 16
- 30
3
votes
5 answers
Database query vs java processing
Is it better to make two database calls or one database call with some java processing?
One database call gets only the relevant data which is to be separated into two different list which requires few lines of java.

Mike
- 725
- 2
- 11
- 21
3
votes
2 answers
Efficient search for not empty intersection (Java)
I have a method that returns an integer value or integer range (initial..final) and I want to know if values are all disjoint.
Is there a more efficient solution than the following one:
ArrayList list = new ArrayList();
// For…

Tommaso DS
- 211
- 2
- 14
3
votes
1 answer
What is an efficient way to access large-ish datasets using JDBC with Clojure
EDIT
N00b problem as it turns out. I didn't realize that running lein ring server results in your app being ran in interpreted mode, which is why it was much slower.
Can the following Clojure/ JDBC fragment be optimized so that it runs (much)…

Eelco
- 1,718
- 22
- 16
3
votes
5 answers
How to insert whitespace between characters of words in a specific field in a file
I have a file containing 100000 lines like this
1 0110100010010101
2 1000010010111001
3 1000011001111000
10 1011110000111110
123 0001000000100001
I would like to know how can I display efficiently just the second field by adding whitespaces between…

saloua
- 2,433
- 4
- 27
- 37