The memory-optimization tag has no usage guidance.
0
votes
2answers
48 views
Code for calculating shortest possible route between two given nodes
Recently I came across this problem , here is an excerpt from it,
Heroes in Indian movies are capable of superhuman feats. For example,
they can jump between buildings, jump onto and from ...
1
vote
2answers
46 views
Finding the longest palindrome from the given string
Recently I came across this problem which instructs me to find the longest substring which is a palindrome:
As we all know, a palindrome is a word that equals its reverse. Here
are some examples ...
4
votes
3answers
119 views
Calculating number of unharmed leaves
I recently came across this problem that asks you to print the number of leaves not eaten by the caterpillars:
As we all know caterpillars love to eat leaves. Usually, a caterpillar
sits on leaf,...
4
votes
1answer
183 views
Find files with content matching regex
Today I wanted to find a program that I wrote a while ago. I knew that it contained a certain regex, but I couldn't for the life of me remember the file name I saved it under. I knew I could use ...
1
vote
1answer
99 views
Brute-force password cracker
I am trying to write a program to find a zip file's password. I know the password consists of only lower-case letters and it's length does not exceed 6 characters. I wanted to check the passwords of ...
2
votes
1answer
49 views
DataTable extension methods and proper disposing of unneeded resources
I've build two extension methods, that allows me to show DataTable inside window.
Below is my code:
...
7
votes
3answers
101 views
How to decrease memory usage in codeeval Road Trip challenge
I'm solving easy CodeEval challenges in Python 2.7. Usually my solutions use around 256 bytes of memory according to CodeEval. With Road Trip however while time used is still low (30-40ms), memory is >...
3
votes
1answer
26 views
Profit sensitivity analysis in base R
Using base R, I've conducted a simple profit sensitivity analysis, i.e. measuring the impact on profit if there is a change in price, variable cost per sale, unit sales or fixed costs assuming that ...
2
votes
0answers
39 views
LinkedList of Nodes at each level - optimalization
That's already known problem: to return an array of linked lists that contain values of elements at each level. Eg for tree with depth n there should be n linked lists.
I wrote the solution:
...
3
votes
1answer
54 views
Writing a byte array image to disk with an automatically generated filename
I have the following code that that writes large images to disk. My application server is running out of memory and I'm wondering if I could somehow optimize the following:
...
-4
votes
2answers
162 views
RAM overhead on a compression program [closed]
In a program, the one below is attempting to codify into a translation of another file. The output is severely condensed. It works, and once I get it to decompress, then it will win award after award. ...
0
votes
0answers
25 views
Prefetch in ARMv7
I have to implement Khatri Rao product between 2 matrices in C. Mathematically this is a column major access of data and I can not change that. But if I use preload ( PLD instruction in ARMv7 ) to ...
2
votes
2answers
39 views
Find the best path amongst N random points
For an application with a graphical canvas, I want to generate N points. But then I want to link those points, and I want to find the best path through those points.
I wanted to use a dynamic ...
4
votes
1answer
46 views
Memory efficient Log Parser
I wrote this together for a test I'm doing that parses the Heroku access log. What I'm mainly interested is if this code follow common best practices and if there are any improvements I can make in ...
1
vote
1answer
224 views
Multiple emails and attachments, reusing memory stream
I am generating a pdf form based on user input from an MVC website form. The pdf is genrated using the Foxit .NET SDK, then attached to three separate emails, generated using Postal. It has been ...
4
votes
1answer
586 views
Memoized Collatz sequence
Here is one of my programs that utilized memoization and array to improve performance and memory usage. The performance seems satisfactory but the memory usage is ridiculous and I can't figure out ...
6
votes
3answers
383 views
Rotation of elements in an array
We had to write a program that would perform rotation of elements in an array. The array size was entered by user, so it had to be in a sense, dynamic.
Rotation or Circular Shifting
Initial Array: <...
4
votes
2answers
202 views
Memory Management Code
For a project I had to do a memory management problem without creating any custom classes or templates using the provided pool array and ...
4
votes
2answers
811 views
Binary file validity in C++/C++11: checking a binary header
I have some code for checking a binary header to see if a binary file is meant to be read by a certain program, and I could use some extra eyes to review it.
Assume the following ...
4
votes
1answer
57 views
Construct binary tree from inorder and postorder traversal
The problem is taken from here. The tree is guaranteed not to have duplicate elements.
My questions is, instead of creating new arrays leftInOrder, ...
3
votes
2answers
110 views
Find two numbers that add up to a given total, from a formatted string
The full challenge from codeeval.com can be viewed here.
Input
Your program should accept as its first argument a filename. This file
will contain a comma separated list of sorted numbers ...
3
votes
1answer
51 views
Computing the double Integral using MonteCarlo techniques using Julia
I decided to try and learn Julia for doing scientific computing, and I decided to tackle the problem of finding
$$ \int_{D_{\frac{1}{4}}} x^4 + y^2 dA $$
where \$ D_{\frac{1}{4}} \$ is the part of ...
-1
votes
1answer
148 views
Simplest linked list in C++?
My context was basically to get my linked list implementation in C++ reviewed, since I wrote it from scratch and wanted to make it as simple as possible and learn from suggestions I get. I am trying ...
6
votes
2answers
123 views
Extending Sieve of Eratosthenes beyond a billion - follow-up
Follow up form Extending Sieve of Eratosthenes beyond a billion
Taking suggestions from the comments on the previous post:
Updated Code: This takes about 22 seconds for MAX as \$10^9\$ to reach "...
12
votes
1answer
272 views
Where it all begins: Khronos
This is the main.c file for Khronos, a personal project of mine. This is basically where the whole program is setup, run and then quit. I'll post the short ...
25
votes
4answers
2k views
Extending Sieve of Eratosthenes beyond a billion
For MAX value of 1000000000 (\$10^9\$), it takes about 45 seconds to reach the line where it prints "done". How can I speed this ...
15
votes
1answer
413 views
Bruteforce MD5 Password cracker
I just started learning Go, and I wanted to created a project to learn more about concurrency in go. I heard about Go's lightweight threads, so I wanted to give them a try.
This program uses ...
8
votes
2answers
388 views
Frequency count of single words and word pairs over 20 million tweets
My application needs to read 20-million-line text files and count the word frequencies for one and two words.
For example:
A B A B SSS G D A
One word Frequency
A: 3
B: 2
SSS: 1
G: 1
Two ...
3
votes
1answer
79 views
Tic Tac Toe with Minimax (memory management optimization)
I've made a Tic Tac Toe game with minimax in Javascript. It works but I have to use location.reload(true); to automatically reload the page every time user starts a ...
7
votes
3answers
143 views
Type-agnostic BubbleSort in C
I'm trying out different sorting algorithms for learning purposes, here I'm doing a "type-agnostic" BubbleSort.
I modeled the function signature after the standart ...
4
votes
1answer
272 views
Updating number of votes with a “Like” button
I have a "Like" button in my iOS app that updates the votes every time it's tapped. Just like Facebook, Instagram, ProductHunt, etc.
I have a custom cell where that ...
4
votes
1answer
142 views
Conway's Game of Life
Inspired by this post, I decided to try to implement my own Conway's Game of Life.
I started with a non-warping board:
...
2
votes
1answer
38 views
Compare a sequence with the reference frequency of hexamers
I have written this function (and others similar to that one) But I am not sure I am using references on their full power.
My currently concerns is if I make a huge use of memory. The subroutine ...
2
votes
1answer
204 views
Extract data from large JSON and find frequency of contiguous sub lists
I have been writing some code (see component parts here and here) that:
Takes a very large JSON (15GB gzipped, ~10million records)
Extracts the relevant parts of the JSON into a list of lists
...
4
votes
1answer
173 views
Pulling data from API, Allowed memory exhausted
I'm working on a project where I pull data (JSON) from an API. I would like to manipulate this data and store this as useful information in my DB (MySQL). My code is working if I would like to make, ...
10
votes
2answers
443 views
Unique value finder
For our first assignment in our algorithm class we are suppose to solve several different questions using information from a 2D array. We are also suppose to optimize our code to get more marks on our ...
3
votes
3answers
156 views
Storing and processing large arrays to compute dot products
Problem Statement (from HackerRank)
We have two arrays \$a\$ and \$b\$ of length \$N\$, initially all values equals to
zero. We have \$Q\$ operations. Let's define three types of operations on
...
6
votes
1answer
418 views
Monitoring the recursive growth of a zombie rabbit population
Breeding like rabbits
Write a function answer(str_S) which, given the base-10 string
representation of an integer \$S\$, returns the largest n such that \$R(...
6
votes
1answer
130 views
Sieve of Eratosthenes for prime generation
I was originally going to write this intro as just being the bare-bones "here's my problem, here are some ideas, what do you recommend" format (which I am still going to follow, mind you), but I've ...
8
votes
2answers
144 views
Summation of primes for large inputs
I'm doing a problem from Project Euler to find the sum of all primes under two million.
My code manages to get a pretty good result for small inputs, but when trying inputs like million or two it ...
5
votes
1answer
299 views
CodeEval solutions to find trailing strings
This is a problem in CodeEval, moderate level. The problem is very easy for this level. But I am not able to get more than 60 points for any solution I submit. (Moderate levels highest score is 65 and ...
3
votes
3answers
1k views
Custom ArrayList class
Please review my custom ArrayList class I constructed from scratch and add any suggestions or constructive criticisms. The point of this template class is give the ...
3
votes
2answers
292 views
Memory efficient A* (AStar) Algorithm
I am writing a solved for 15 puzzle game which will find the solution path to any NxN board. For easier boards the algorithm works great solving almost any 3x3 boards, most 4x4 boards, but when I go ...
4
votes
2answers
660 views
Object-oriented JavaScript and Google Maps objects memory management
I have to draw various instances of HeatMaps, Winds and Polylines. Each layer will have one <...
3
votes
3answers
371 views
Web crawler uses lots of memory
I am developing a web crawler application. When I run the program for more than 3 hours, the program runs out of memory. I should run the program for more that 2-3 days non-stop to get the results I ...
6
votes
1answer
104 views
Pool allocator for a scripting language parser
At the moment I'm writing a parser and interpreter for a custom scripting language, to learn more about the basic concepts involved and to get more familiar with tools like ...
11
votes
0answers
329 views
Rust Brainfuck interpreter
I took the code from kostyas benchmarks for the Rust Brainfuck interpreter and tried to optimize it. There is also a discussion on Reddit about the poor performance of Rust in the Benchmark.
Before ...
3
votes
1answer
57 views
Yellow Pages Search
I've written code in Free Pascal based on a contest problem (The contest insists that I have to write with Pascal). It works like charm, but I think it still need some improvements, from memory usage ...
4
votes
5answers
291 views
Permutation of n lists
I have code which gives permutations for 10 lists. The code works fine for small number of lists with small number of values.
Result : It should return all possible permutations. I have to store the ...
2
votes
2answers
97 views
Effecient Use Sieve of Eratosthenes algorithm
Given this as a the Problem Statement
Given two numbers, find the sum of prime numbers between them, both
inclusive.
Input:
The first line contains the number of test cases T. Each ...