Optimization is the act of improving a method or design. 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
10 views

Optimizing image generation in Perlin noise generator

I've created a simple Perlin noise generator in JavaScript and am trying to find ways to optimize it. It lives inside a webpage and generates an image using nothing more than random number generator ...
-2
votes
0answers
14 views

OSX to iOS screen streamer. Streaming realtime video over LAN [on hold]

I know there are already apps out there that do this better, but I thought this kind of app should be free, so I tried writing one on my own. It takes a screen recording of your OSX screen using ...
2
votes
3answers
76 views

Creating lightning bolt effects

Which one of these are better for the memory? ...
1
vote
2answers
43 views

Quicksort algorithm

I have reimplemented the quicksort algorithms that takes a list and sorts it in non-decreasing order: ...
1
vote
4answers
68 views

Coupon collector

This is a coupon collector code to analyze the running time. I need some suggestions on improving the running times of this code. I have used the data structure dictionary, but is there any other data ...
2
votes
1answer
26 views

CREATE Service Call

I'm a relatively new (~6 mos) developer, and I'm hoping for some feedback on my code style/structure. While I'm particularly interested in efficiency and maintainability, I'm open to feedback ...
5
votes
1answer
56 views

Effective use of branch prediction in terrain generator

I am trying to learn how branch optimization works. For an experiment, I have a recursive fractal terrain generation and I have moved all if statements to binary ...
4
votes
1answer
42 views

Data-checking class supporting letters

I'm starting to learn OOP with PHP, and all I've learned so far is just by searching and reading. So I have this need to check input data for certain things like min of chars, max of chars, spaced or ...
3
votes
2answers
172 views

Determining if a pair exists in a large sorted array

I'm doing practice interview questions from here. Here is the one I am currently on - if you are given a very large sorted int array, then check of there exists a ...
2
votes
3answers
375 views

Finding duplicates in two sorted arrays

This is an interview question from here. Specifically, the second asked for a function that took in two sorted arrays of integers with no duplicate values within a single array and which returned an ...
3
votes
3answers
83 views

Project Euler 35: Circular primes below 1 million

I'm doing another Project Euler problem, number 35, and I need help improving my code speed: The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, ...
1
vote
2answers
97 views

Traverse all switch branches without goto

I'm wondering wether there is a way to walk through every branch of this switch without using goto ...
2
votes
0answers
20 views

One-dimensional convolution using Data.Vector

As part of some code I've written, I needed to perform a 1-D convolution. This convolution ends up happening quite often, so I wanted to optimise it (in some way other than using a FFT, though I could ...
8
votes
3answers
181 views

Breadth-first search for clusters of pixels in a given color range

I am a beginner in programming languages, so I apologise if my code is badly formatted or doesn't make any sense. My program gets an image and a RGB color range as input and it counts how many pixels ...
3
votes
3answers
116 views

SQLite insert code optimization

I just started working with SQLite in C# to test various features of an application. In building my first SQLite example I wanted to insert a large csv into a table (Person) with two columns, A and B. ...
-1
votes
1answer
50 views

Merge sort optimization and improvement

How to optimize this merge sort code to make it run faster? And how to call merge_sort function without user input by declaring necessary array in the code? ...
3
votes
1answer
63 views

Wait for System.IO.StreamReader.ReadLineAsync

I want to wait for a line to be read, but only for so long before timing out. This is what I came up with. Is there a better way to do it? ...
2
votes
1answer
44 views

Is this an optimal implementation of merge sort?

I am taking an algorithm course and we are to implement merge sort that handles list of elements with even or odd number of elements and handles duplication, so I wrote this function: ...
6
votes
3answers
145 views

Chess puzzle improvement

Is it possible to optimize this solution to the N-queens puzzle? ...
3
votes
3answers
87 views

Find intersection of two arrays without duplicates

A = [9, 1, 4, 2, 5] k unique integers B = [3, 1, 8, 7, 6, 5] n unique integers Intersection => [1, 5] Find an algorithm that uses \$O(1)\$ space (the space used by the return variable is not ...
-4
votes
1answer
65 views

Is this a better loop? [closed]

My team has a lot of code written with fairly traditional for-loops: for(int i=0; i < Something.GetSize(); ++i) { /* do work */ } But recently, some devs ...
3
votes
1answer
52 views

Check if string can be rearranged into a palindrome

I created a function to test whether a single word string can be a rearranged into a palindrome (doesn't have to be a real word). My logic was if the string has an even number of letters, then each ...
5
votes
3answers
123 views

Bresenhams line algorithm optimization

Based on these guidelines I optimised Bresenhams line algorithm, it now fits for all kinds of line cases like images a, b, c, d, e, f, g, h show in those guidelines. This is my test.txt input file ...
5
votes
3answers
108 views

Counting letters as quickly as possible

I received a task, of taking a known text file (Linux dictionary), use threads to count the different letters in it, and present the results in an array. The code doesn't have to be pretty, elegant, ...
3
votes
2answers
81 views

Implementation of Dijkstra's algorithm to find the shortest path in graph

This is my implementation of Dijkstra's algorithm in C++. Please clarify Whether the class design is proper or if it needs to be improved. I am just hard coding the vertex based on the priority of ...
2
votes
1answer
41 views

Books Algorithm Dealing with Square Digit Sums

A little context: Book has 411 Pages Read a random number of pages on the first day which is unknown Number of pages to read next day is the square of the sum of the digits of the page ...
1
vote
2answers
64 views

Book pages algorithm dealing with digit sum and squares [closed]

I would like some help condensing this code to make it more efficient. Could someone also help me output the number of pages she reads instead of the page number she is on... ...
4
votes
1answer
73 views

Water generating waves and reflection

For the last few days I have been working on wave generation script. As there are a lot of calculations involved I was looking for possible optimizations to improve the performance of the code. This ...
6
votes
4answers
2k views

Swapping two integer numbers with no temporary variable

I tried to swap 2 integer numbers without using an additional variable as a traditional swap. Is it legal in C++? My VC compiler doesn't complain nor gives any warning about it. If so, how can I ...
8
votes
1answer
148 views

Python-based Git pre-commit hook to manage multiple users/Git identities

A couple of months ago I posted a bash script to manage multiple Git identities as a solution on Stack Overflow but soon found the hook isn't flexible enough. Thus I decided to rewrite the hook in ...
5
votes
1answer
45 views

Kendo grid optimization

I have two kendoGrid(s) named: ...
18
votes
8answers
1k views

Optimize custom double.parse()

In my company's code, they use double.tryParse() which is quite good but sets too much security for our needs. As we sometimes have to parse a few billion strings, ...
2
votes
1answer
35 views

SQL query to order by the difference between FIRST and BEST scores

Can anyone help me optimise this query? I have the following table: ...
2
votes
3answers
126 views

Calculate the square root of the sum of the squares of the prime factors of an input number

This question is related to another one that I have asked here. I need to find ways to improve the runtime performance of the following piece of C-code. I want to increase ...
1
vote
1answer
75 views

Executing URL using Apache HttpClient

I have XML below which is stored as a String in xmlData variable and I need to pass this String to my URL in ...
5
votes
2answers
139 views

Knight's Tour with Heuristics

When someone suggested that I solve Knight's Tour, I did so with heuristics and recursion. It takes a lot of time to solve even a 8x8 board: N-A1 N-C2 N-E1 ... N-E6 N-F4 Time ...
0
votes
2answers
53 views

Modulo problem code

This prints out the sum of the numbers that have same remainder and quotient according to the input number. It's an online judge problem, and it currently throws a time-out since it's taking too long. ...
2
votes
1answer
75 views

Very slow graph walking

My code is very very slow. Could you give me hints on how I can make it much faster? ...
2
votes
4answers
65 views

Selecting three stylesheets in a specific order

I'm somewhat new to SQL (only had to use it in Database classes). I have a simple table of stylesheets, from which I want to select specific ones in a specific order (e.g. reset, then layout, then ...
6
votes
2answers
88 views

Name filtering in Java

I have a search box for searching for people in a list of names. Here is the code that runs every time the query changes. I could not find anything open-sourced for this, so I wanted to make sure ...
4
votes
0answers
66 views

Optimization of sparse matrix multiplication for billion by billion matrices

I have to do multiplication of two billion by billion sparse matrices (on a CPU), hence any help or hints in optimizing the below given code would be extremely useful. Note: I am only showing the ...
1
vote
1answer
41 views

Python Koans multiplayer Greed Game (dice)

I finished the Python Koans because I wanted to practise Python and I completed the extra assignment which is the Greed Game (see the rules here). Here is the code, I think there are no flaws but you ...
3
votes
0answers
68 views

Project Euler #14 — longest Collatz sequence

I was reading this question and realized that I didn't know Python well enough to critique the algorithm. So I wrote a Java solution instead, which is inappropriate for that question. Since there's ...
1
vote
3answers
59 views

Python greed roll

I am doing the Python Koans to practise Python a bit more and I got to the greed dice project. It is a very simple dice game that scores a set of up to five rolls. These are the rules: ...
4
votes
2answers
110 views

Importing different type of files into Lists

I am using a recursive directory scan to find all objects inside a Unity3D project. After that, I wish to move all these files to a sorted List. Is there a cleaner ...
3
votes
1answer
62 views

Project Euler #14 (Longest Collatz sequence)

A Collatz sequence for a given positive integer \$n\$ is to take half of \$n\$ if even and \$3n+1\$ if \$n\$ is odd; repeat until the value goes to \$1\$. The question is which number from 1 to ...
6
votes
3answers
324 views

Optimizing an Anagram Solver

I've built an anagram solver in Python 2.7. It goes through a text file with over 100,000 words and checks if any permutations of the input matches the line. It works great, except it is very slow. ...
5
votes
4answers
397 views

Project Euler #12 - first triangle number with more than 500 divisors

I tried to solve Project Euler 12 with a first very naive solution by myself. It took nearly 30 minutes to run until it found the solution. Then I made a change in the function ...
1
vote
0answers
39 views

AI for an online contest

I'm actually creating an AI for the online contest Vindinium. The fact is that's also an exam for my school because I'm going to have a note with that work. I created an AI based on ants pheromones ...
2
votes
1answer
52 views

Checking if a directory exists in FTP without relying on exception handling?

I've written a method to check if a directory already exists on an FTP server. The only way I could see to make this work was to return a different result from the method if an exception is thrown - ...