Optimization is the act of improving a method or design. In programming, optimization usually takes the form of improving the efficiency of an algorithm, or reducing the resources it requires (space in memory, on disk, or amount of network traffic, etc.).

learn more… | top users | synonyms (2)

4
votes
1answer
20 views

How to efficiently parse HTML table using jsoup?

I am trying to parse HTML using jsoup. This is my first time working with jsoup and I read some tutorial on it as well. Below is my HTML table, which I am trying to parse. If you see my table, it has ...
3
votes
1answer
26 views

Speeding up class that uses an ODBC connection

I have created a class that gets data from an ODBC connection. The code works but it is really slow - I'm talking up to 1.20ish minutes to run. I know my code is inefficient but I'm really not sure ...
0
votes
0answers
26 views

Painting Fences - optimize for faster performance

I am attempting this problem at Codeforces. I'm stuck as it gives a time limit exceeded error for large inputs though the logic I followed is similar to that of the editorial. I'd be grateful for any ...
1
vote
1answer
79 views

Mutations and Combinations

I have recently answered one question on Stack Overflow. Problem statement: Input sequence: PEACCEL User mutation input file: ...
3
votes
1answer
43 views

Seeking improved Objective-C permutation algorithm

This algorithm seeks to find all of the possible permutations of a word: ...
0
votes
1answer
32 views

Using Comprehensions to Handle a Large Dataset in Python 2.7

I have a Python 2.7.6 script parsing large files (~60MB to ~2GB) containing lines of the following format: componentA componentB < floating point value > My goal is to sum the floating point ...
1
vote
1answer
36 views
7
votes
3answers
144 views

Getting the top 10 stores within a category

I have the following query. I know there's an easier way to do this without the sub queries, or at least optimizing how they're used. I've read about cross joins and using ...
5
votes
3answers
117 views

Cleaner or better readability in URL composition

I have a URL that is hardcoded via a config which I extract into a config: ...
3
votes
1answer
29 views

Simplifying linked list “search and delete” function

The function asks the user for a value to search for, then deletes all matching values in the list. The program runs flawlessly, but I can't figure out a simple/elegant way of separating cases for ...
1
vote
2answers
45 views

Binary Insert Method - handling edge cases

I've created a function that uses binary search to insert an element into an array (similar to this question). I haven't benchmarked it, but based on my knowledge it should get \$O(1)\$ in the best ...
4
votes
0answers
46 views

ListBox Update Handling

I have UserGroups for Users to be assigned to in a ListBox in HTML form. Items from listbox can be multi-selected or completely ...
4
votes
1answer
66 views

Put it in a bucket

You're running a jeans company. Your system is collecting detailed orders' data, but it's a bit archaic and it's storing the number of units ordered per size in a delimited string with 20 "fields", ...
1
vote
0answers
22 views

Optimizing Recursive Quadtree

I have a written a quadtree program in Python 2.7 to cross-correlate large catalogs with each other i.e. find the common objects in the catalogs based on their position. The problem is that it's still ...
6
votes
2answers
177 views

Displaying content based on the current time

I'm new to PHP and just wrote a bunch of if statements to display content based on the current time. Is there a better way of writing the following block of code ...
1
vote
0answers
15 views

C code for hash-consing: how could its performance be increased?

I've isolated this function, cons, for hash-consing in C. It is where the bottleneck of my program is. How could its performance be improved? ...
3
votes
1answer
14 views

Bit compressing in JavaScript

I have an bit array var data = []; ... and I have the following function: jsPerf ...
3
votes
2answers
67 views

Controller: Sign up action clean up

I don't know if it's just me, but I feel like my sign up action method has gotten a bit messy. I think that perhaps instead of setting error messages in a controller, I should set error codes which I ...
1
vote
0answers
15 views

NGON (many polygons) on SPOJ - Time Limit Exceeded

I am trying to solve NGON problem. I am using bottom up dynamic programming here. Recurrence function is: ...
3
votes
1answer
32 views

How to generate valid number of combinations of datacenter and its host id?

I have a list of datacenters, which are dc1, dc2 and dc3. And each datacenter has six ids as ...
1
vote
1answer
38 views

Hover effects using HTML and SASS

I recently created one of my first hover effects using HTML and SASS. Since it is my first hover effect, I'm almost positive that is it horribly inefficient. I'm sure there's a way to do this effect ...
2
votes
1answer
55 views

Rooms and trapdoors - for-loop and while-loop efficiency

I'd like to know if I can make this code more efficient in terms of line saving, or any other way: ...
11
votes
4answers
908 views

Most pythonic way to combine elements of arbitrary lists into a single list

I have a list of lists which represents the options I can chose from. I have a sequence of indices which represent which option lists I want to take elements from, and in which order. E.g. if I have ...
1
vote
1answer
95 views

Optimizing method and removing useless code

I have such function which is parsing beautiful soup elements: ...
3
votes
1answer
36 views

SPOJ is giving TLE for this solution of ROCK

I am solving ROCK problem on SPOJ. I have used bottom up dynamic programming approach for this problem. Time complexity for this is \$O(n^3)\$. ...
4
votes
4answers
365 views
5
votes
4answers
72 views

Stack implementation using only one queue in C

We start with an empty queue. For the push operation we simply insert the value to be pushed into the queue. The pop operation needs some manipulation. When we need to pop from the stack (simulated ...
2
votes
1answer
83 views

Why are these functions slower than BigInteger's included methods?

I tried writing alternative functions to Java's BigInteger.add(BigInteger.ONE), BigInteger.add(BigInteger), and ...
3
votes
1answer
116 views

Speeding up Codechef FROGV

This is my solution to the FROGV problem on Codechef: ...
2
votes
1answer
94 views

Sum the Multiples of 3 and 5

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below N. ...
5
votes
2answers
158 views

How to generate valid number of combinations basis on the rules?

I have a list of datacenters, which are dc1, dc2 and dc3. And each datacenter has six ids as ...
6
votes
1answer
50 views

How to optimize K-nearest neighbours in C# for large number of dimensions?

I'm implementing the K-nearest neighbours classification algorithm in C# for a training and testing set of about 20,000 samples and 25 dimensions. There are only two classes, represented by '0' and ...
4
votes
0answers
52 views

Decoding custom packets with Python using Twisted

This server require fast decoding of packets from clients, as I am expecting 5000 concurrent clients that is sending packets possibly every second. This is a game server (5000 players walking send ...
3
votes
1answer
46 views

Rewriting dispatch method

Is it possible to rewrite this piece of code any better when it comes to efficiency and/or readability? ...
2
votes
0answers
50 views

Code elimination once it is conditionally dead [closed]

A situation when programming code becomes dead dynamically or conditionally, such as here in this scenario. I don't want my code to be failure victim of branch prediction. ...
4
votes
1answer
70 views

A functional binary heap implementation

I've implemented a binary heap in F#. It's pure and uses zippers for tree modification. To test it out I have implemented heap sort using it but it takes 10 seconds to sort a list of 100 000. Regular ...
5
votes
2answers
231 views

How to write a generic performance efficient isEmpty method which can check for null, empty?

I am writing a utility method which can check for empty and null string, or collection or an object or any general types - ...
2
votes
1answer
36 views

PPL and AMP performing worse than sequential transform

I wrote the following short test code to test the performance of C++AMP and the PPL libraries against the sequential STL implementation of std::transform. To my ...
4
votes
1answer
51 views

Script for dynamically-loading data onto a restaurant menu for printing

I have a script which dynamically loads data onto a restaurant menu for printing. Could the following code could be shortened at all? ...
4
votes
2answers
105 views

Optimizing object-returning functions in a Contours class [closed]

I have an class Contours that contains a vector of contours. I use OpenCV to store the contours, and I have another class ...
1
vote
1answer
55 views

Solving the coin change algorithm using 10 coins

I'm solving the coin change problem having target of n and upper bound as n. Also the maximum number of coins is 10. For example. if the target is 11. then the possible outcomes are - ...
4
votes
1answer
57 views

Subnetting calculator

I'm fine with any sort of answer that helps better my code -- I'm not necessarily looking for a full refactor. I have a script that converts input (IPv4 address, submask, cidr, etc.) into usable ...
7
votes
2answers
577 views

Optimizing and improving a username regex

I have created this regular expression to validate usernames which I need in my projects: ...
5
votes
1answer
74 views

First time graphics - bad performance in software rendering

I'm writing an utility audio plugin that specializes in "fullscreen" (the window is freely resizable) visualization of audio, like spectrograms, oscilloscopes and in this instance, a vectorscope. For ...
7
votes
2answers
68 views

Validating multiple keys in the builder class based on the rules

I recently started using Builder pattern in one of my projects and I am trying to add some sort of validations on my Builder class. I have already asked a question, got some feedback and incorporated ...
1
vote
1answer
51 views

Making a URL by prioritizing the keys if multiple keys are present efficiently

I recently started using the Builder pattern in one of my projects. Below is my builder class - ...
4
votes
1answer
73 views

E-commerce product price tracker

I building a very simple price tracker web app. I am using MongoDB with pymongo. The user will enter the URL of the product he wishes to track and the desired amount, when the price goes below this ...
7
votes
1answer
125 views

How do I optimize this Java cube root function for BigInteger?

I find that this function is one of the biggest causes of slow program execution. I can write a square root version with BigInteger only, but with the cube root, the algorithm sometimes gets caught in ...
6
votes
2answers
61 views

Efficiently returning the string basis on current datacenter

We have machine hostname as - dbx111.dc1.host.com dbx112.dc2.host.com dcx113.dc3.host.com dcx115.dev.host.com Here dc1, ...
2
votes
1answer
27 views

Trie SPOJ Problem - PhoneList TLE

In this problem you are given input of phone numbers and you are supposed to determine whether any number is the prefix of another. I have an addchild method that ...