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)

5
votes
2answers
88 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. ...
2
votes
2answers
23 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 ...
1
vote
2answers
75 views

Any way to optimize this already fast Python solution to Project Euler 31 (coin sums)?

This is a Python solution for all general cases. Any suggestions at all would be appreciated; in my opinion it's already quite good! Here's a link to the problem. ...
9
votes
4answers
922 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. ...
2
votes
2answers
149 views

is there a way to write this shorter

i need opinion, is there a way to write this shorter ...
3
votes
1answer
996 views

Find missing numbers in a range, with duplicate numbers in a sorted array

Suggestions for cleanup and optimization request. This question is a follow-up question on this post. Lets assume the range of 1, 2, 3, 4. This function takes in an array of repeated ...
5
votes
3answers
213 views

Simplifying and optimizing chat logger

I'm developing a Java EE project which uses Redis through the Jedis library. I'm retrieving the chat history of a particular channel from the servlet context and if absent, from Redis. The PMD ...
3
votes
1answer
45 views

Remapping Heading Angle to Coordinates to Move By

I wrote the following code to take the heading of an object, and determine which direction (x,y) it needs to move to be heading forward in a 2D plane. I have ...
2
votes
2answers
163 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 ...
4
votes
0answers
32 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 ...
1
vote
0answers
132 views

Optimizing URL router behaviour

I'm trying to create an URL-router, where the website language is defined by the first two chars in the domain. Example: domain.com/en (the site will then display content in English). The ...
8
votes
3answers
365 views
2
votes
1answer
73 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 ...
4
votes
1answer
247 views

Hackerrank Gem Stones

I am working on some problems on Hackerrank. John has discovered various rocks. Each rock is composed of various elements, and each element is represented by a lowercase Latin letter from 'a' to ...
3
votes
1answer
36 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
67 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
86 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
45 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, ...
3
votes
1answer
1k views

Usability of sliding panels

Is there a better way to do what I'm doing? If not, I'd like just a general review of how I did it and the usability of it (how it works and functions, not artistically how it looks). Here is the ...
7
votes
1answer
342 views

Timing analysis of many test cases in Python

I am learning about timing analysis in Python. I used time module before it was pointed out that timeit module would be better ...
2
votes
1answer
88 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
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 ...
10
votes
2answers
214 views

Finding an element in multiple sorted lists efficiently

I have \$k\$ sorted Lists, each of size \$n\$. Currently I have hard-coded 5 sorted Lists each of size 3, but in general that is ...
4
votes
1answer
50 views

Seeking improved Objective-C permutation algorithm

This algorithm seeks to find all of the possible permutations of a word: ...
7
votes
3answers
146 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 ...
2
votes
2answers
69 views

Importing tab delimited file into array

I am needing to import a tab delimited text file that has 11 columns and an unknown number of rows (always minimum 3 rows). I would like to import this text file as an array and be able to call data ...
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 ...
5
votes
3answers
123 views

Cleaner or better readability in URL composition

I have a URL that is hardcoded via a config which I extract into a config: ...
1
vote
1answer
42 views
1
vote
0answers
56 views

Lagging JavaScript - opportunity for optimization or profiling?

I have this code and it works exactly as I want. The menu bar sits on top and recognizes the section it is on or in. You can click the links in the yellow menu to move between the sections. JSFiddle ...
2
votes
0answers
27 views

Downloading and parsing list of Getcachine CWGs

I'm building a page that downloads a list of Geocaching CWGs for my country in XML, and then parse it. The structure of the XML looks like this: ...
4
votes
2answers
4k views

Decoding binary coded decimal (BCD) value

I have 3 questions, all of them are concerned with binary coded decimal (BCD) conversion. My coding snippets are listed as follows. But I don't like my algorithm because it takes too long when dealing ...
7
votes
2answers
136 views

Simple and efficient boost::unordered_set intersection

I wrote this function to do unordered_set intersection using templates. I have seen this answer but I thought that is was overkill. I would like the method to take ...
2
votes
1answer
328 views

TicTacToe in Java

I created this game in Java: ...
1
vote
1answer
271 views

“Guess my Number” game in C++

I have recently created my first game in C++: ...
3
votes
1answer
15 views

Bit compressing in JavaScript

I have an bit array var data = []; ... and I have the following function: jsPerf ...
3
votes
1answer
31 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
46 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
72 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 ...
4
votes
1answer
69 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", ...
4
votes
0answers
47 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 ...
1
vote
2answers
203 views

Taking input from push buttons

I want to know if what I have coded is good enough or if there is any simpler/faster/better/less size taking substitute. I am trying to take input from push buttons and I also want to remove repeated ...
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
180 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
16 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
2answers
68 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 ...
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 ...
1
vote
1answer
160 views

Could this CyberFaze app be more efficient than O(n)?

I had an efficiency problem like I thought and I didn't have the best solution here. My solution was \$O(n)\$ and directly a more experienced member told me a solution that is \$O(1)\$, that only ...
5
votes
1answer
69 views

Can I reduce the bloat in my Google Spreadsheet form script?

Long story short I feel my code should be able to be reduced a whole lot, I just don't know how. The form updates a spreadsheet with agents(employees) hours worked for a specific date. The form has 4 ...