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)

2
votes
0answers
35 views

Web page based on a sample from a book

I've created a web page based on a sample from a book. It works fine, but seems to have become too complicated. ...
6
votes
1answer
51 views

Algorithm to calculate semi perfect integers, lack of effeciency

I'm working on an algorithm to calculate weird numbers, and to do so there are several properties that needs to be calculated, one of them being, if it is NOT a semi-perfect/pseudoperfect number. My ...
5
votes
2answers
63 views

Finding prime numbers in a range

Finding the prime numbers between two given integers in the minimum number of comparisons: ...
8
votes
2answers
57 views

Contest code for a maze problem

I would like to ask your comments on my contest code for the following problem: We're going to have a slightly more logical puzzle today. We're going to write a program that will find a path through ...
4
votes
2answers
73 views

“Sherlock and queries” challenge

I'm writing some Java code for some pretty large datasets, in a puzzle I'm trying to solve. The output is correct, but the program doesn't run within the time limit for all the test cases. I've ...
3
votes
0answers
22 views

Factorial using trampolines

I've translated this Java code into Delphi code: ...
3
votes
1answer
33 views

Removing of star-args [on hold]

I have such functional code: ...
3
votes
1answer
108 views

Optimizing and clarifying nested list appending

I have such part in my script, how can I optimize such parts? I don't want to use many local variables. ...
0
votes
0answers
24 views

Optimizing TSP branch and bound algorithm in C [on hold]

I implemented this Branch and Bound algorithm below but I can't get optimal results, not even with 5 points. It just works on the right child but not on the left. ...
0
votes
0answers
36 views

Java GS Collections ImmutableList implementation [on hold]

The following code is taken from GS Collections implementation of immutable Lists. Is it good practice to perform the above chain of construction for small lists of size <=10 ? ...
4
votes
2answers
50 views

Deep pick using lodash/underscore

Use Case _.pick creates a shallow clone of an object given a predicate that identifies which keys to keep. pickDeep would ...
1
vote
1answer
26 views

Optimization of recursive jQuery images swap function

There's this website I'm working on that needs to swap images every few seconds, like a slideshow or image fade swap in a way, except that you need to target 5 IMG tag elements. I was able to make a ...
3
votes
4answers
101 views

Returns values for a specific array and key

This code is intended to take an array and a key as inputs, and return an array of the values paired with that key. ...
8
votes
3answers
350 views

Finding the largest of a series of numbers being XORed

I'm working on solving a problem involving finding the largest of a series of numbers being XORed. This is the actual problem: Xorq has invented an encryption algorithm which uses bitwise XOR ...
4
votes
2answers
73 views

Getting the unique factors of a number recursively

I have written the below code to get the unique factors. Please offer suggestions for better results. ...
5
votes
4answers
71 views

Optimizing nested loop in run length encoding function

I'm currently working on a tool that needs to decode, modify data, then re-encode that data using the Yaz0 format. Everything has been in a working state, but after running some code analysis on my ...
3
votes
1answer
28 views

Processes and Handling (Piping)

I basically have 3 processes which I loop through. The first process is encoding Video. It's actually 2 processes but they are connected, so I don't need to worry about how it handles the other one. ...
3
votes
1answer
30 views

Connected components algorithm does not scale past 10,000 nodes

I found a connected components algorithm posted here on SO and modified it for my own purposes. It runs well for small input sets, but doesn't scale as well as I would like. The largest set I've ...
8
votes
4answers
166 views

Adding two sides of an array

The purpose of the program is to add 2 sides of an array starting from the bottom and top of both ends and to find the lowest difference at equal decrements of iteration. The program functions but ...
4
votes
1answer
40 views

Website parsing optimizations: cleaner way to deal with special cases and improving data transfer between classes

I have a DiningHall class that has the 3 properties: openingTime, closingTime, and ...
3
votes
2answers
48 views

Multiple loops versus multiple stringbuilders

I've come across the following piece of code in a Razor view ...
2
votes
2answers
42 views

Calculating the number of prime numbers to solve the puzzle

How can the following program execution time improved? I have used dynamic programming in both "recursive" as well as "prime" function, but I'm not getting the efficient execution time. There is ...
11
votes
6answers
1k views

Dynamic programming with Fibonacci

I have written the following code using a dynamic programming technique. Can I use ArrayList here? Please let me know if I can improve this code. ...
6
votes
2answers
147 views

How can I quickly find unique list items?

I use the loop-every-single-list-item approach to filter out unique elements in a given list, which tends to be very inefficient way as a list grow in size, or as function call frequency increases. ...
5
votes
1answer
61 views

Interpolate then maximize

I need to optimize $$ \max_{a',\ m'} f(a, m, e, m', a') $$ I have approximated \$f\$ with a grid \$F\$ — it has shape \$(nA, nM, nE, nM, nA)\$. Now, I want to interpolate over the last two ...
2
votes
2answers
171 views

Acquiring and formatting data from a JSON file

I have a JavaScript function that is getting data out of a JSON file and then doing some formatting to it. The code works but I feel like it just an awful way of doing it. All criticism and help ...
3
votes
1answer
40 views

Ajax for RESTful web service

I wrote an Ajax function, which should be used in a framework to interact with a webserver. The (self-written) Java-Webserver can be used to fetch files and folder-contents, create files and folders, ...
4
votes
1answer
69 views

Optimizing display of various famous quotes

If it is possible, I'd like to be able to mash all of my arrays into one array, but still have the same functionality within my function (pick quote, pick creator, set padding). Pastebin ...
5
votes
3answers
93 views

Simplifying logic of overlapping predicates

I have 3 simple predicates and 3 simple actions to be taken based on those predicates. In my actual application they are not based on integer arithmetic, and in fact are rather expensive to compute ...
6
votes
1answer
61 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, ...
4
votes
1answer
35 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 ...
2
votes
1answer
82 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 ...
2
votes
1answer
89 views

Mutations and Combinations

I have recently answered one question on Stack Overflow. Problem statement: Input sequence: PEACCEL User mutation input file: ...
4
votes
1answer
58 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
43 views

Convert 2D list to dict of list of index

I have a 2D list like this: ...
7
votes
3answers
147 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
126 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
38 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
49 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
1answer
55 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 ...
6
votes
2answers
92 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
23 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
181 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 ...
2
votes
0answers
22 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
16 views

Bit compressing in JavaScript

I have an bit array var data = []; ... and I have the following function: jsPerf ...
3
votes
2answers
69 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
19 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
35 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 ...