Performance is a subset of Optimization: performance is the goal when you want the execution time of your program or routine to be optimal.
0
votes
0answers
11 views
produce all multiples of a set of primes up to a certain limit
I have some python code that generates all possible multiples and combinations of a given set of primes up to a certain limit. The code runs and does exactly what I intend it to do, now I am trying to ...
2
votes
1answer
25 views
Which definition of power is better?
I needed to write a simple function that could raise a value x to the n'th power. I found out I could write this function in 2 ...
0
votes
0answers
19 views
Dijkstra's algorithm using priority queue running slower than without PQ
I need to implement dijkstra's algorithm and I've done so using this Wikipedia page. I've done it both with priority queue and without.
Both versions work 100% correct, however I need the faster one ...
3
votes
1answer
35 views
Insert node in sorted doubly linked list
Description:
Given a reference to the head of a doubly-linked list and an integer,
create a new Node object having data value and insert it into a
sorted linked list.
Code:
...
2
votes
0answers
18 views
Knapsack greedy algorithm in Python
I implemented the well-known knapsack problem and now I would like to improve it using list comprehension or lambda. I don't want to use NumPy. Could you help me?
...
0
votes
1answer
31 views
Creating points in specific size [on hold]
The method is in a new class and i use it from form1:
In the top of the new class:
public int numberOfPoints = 100;
The class Init method:
...
4
votes
2answers
408 views
9
votes
2answers
699 views
Let's speed that file sentence searching program
Intro:
I've written a small piece of Python program which is looking after a given sentence in multiple sub directories of a given path.
I'm looking for improvements regarding the speed of my ...
1
vote
2answers
53 views
1
vote
0answers
35 views
PHP Trait constructors
I've been rewriting parts of my own framework and eventually came back to where it all began, making traits more useful and implementing auto initializing traits and I am wondering if someone has a ...
7
votes
1answer
73 views
“Connect four” code to check for horizontals, verticals, and diagonals
My textbook (David Liang's Introduction to Java Programming) asks me to write a program which
prompts a user to specify the number of rows and columns in a matrix
prompts the user to enter each ...
0
votes
1answer
54 views
Validation on two different classes and passing one object including everything to another class
I have two consumers and each consumer has their own validation logic entirely different from one other so I am using two validator class for that, one for each other.
...
3
votes
1answer
52 views
Huffman tree decoding
Description:
Huffman coding assigns variable length codewords to fixed length input
characters based on their frequencies. More frequent characters are
assigned shorter codewords and less ...
9
votes
1answer
93 views
Large Number Limit Extravaganza
I am writing a program that computes
$$n-n \cdot \left(\prod_{i=1}^n (1-\frac{1}{p_i})\right)$$
which is rewritten in my code as:
$$\left(1-\left(\prod_{i=1}^n(1-\frac{1}{p_i})\right)\right) \cdot ...
3
votes
1answer
73 views
Epidemic simulation over a large population
This is a follow-up to my question about epidemic simulation. The accepted answer works, but also mentions that I should look at modifying the external_function_call. Here's the complete working code, ...
4
votes
1answer
41 views
Stack class in Ruby to calculate maximum number, get the average, pop, push
Is the class optimized enough to accept 1 million items in the stack?
...
7
votes
1answer
60 views
Reduce amount of calls to database for authentication
I'm currently having a bit of code, which I just know can be improved a lot. I am just blind to it. All of my code looks quite neat to me, except these parts... The login + authentication process is ...
11
votes
4answers
2k views
Country code lookup for each line in a CSV file
I'm trying to write a program that has a for loop, inside of which I have lambda expression to get a certain value. The loop has about 20,000 iterations. Including ...
5
votes
1answer
71 views
Webscraping calendar events using Python 3, with or without BeautifulSoup
I'm trying to find out why my web-scraping code with BeautifulSoup (BS) is slower than my code without BS. I would think that BS code would be faster than the other code - so, maybe I'm doing ...
24
votes
2answers
2k views
Regex to parse horizontal rules in Markdown
I'm the current maintainer of Showdownjs, a markdown parser off which PageDown (stackexchange's markdown parser) is based on.
Showdown uses the following regex to parse horizontal rules:
...
11
votes
5answers
902 views
Zero-initializing large dynamically allocated arrays of double
Arrays of double can be zero-initialized with the { 0 } initializer, which works even on systems that have a binary ...
-4
votes
0answers
45 views
Does replacing if-else statements decrease performance? [on hold]
I have a habit of shortening if-else statements from
if(bool){
int = 1
} else {
int = 2
}
to
...
1
vote
1answer
39 views
Merge sort and linked list implementation
I implemented merge sort with my own linked list for a school project. I was not allowed to use anything but the methods you see in the list. It seems to work properly, however, when running the ...
1
vote
0answers
26 views
Optimizing string concatenations and checking for unique subsets
This code accurately completes my task. However, it does not scale very well. I have been doing my best to optimize the big O complexity; however, I'm not able to make any big improvements. I have the ...
4
votes
1answer
67 views
Using two maps and making a new map by applying all the transformations
I have two JSON and each JSON I am loading in a Map.
First JSON
{
"abc": "2",
"plmtq": "hello+world",
"lndp": "def+ooo",
"yyt": "opi"
}
I am ...
3
votes
1answer
56 views
Multiple numbers calculator
This is my first ever Python program so I would really like to know if it's any good (I mean if it is well writen), and if not then how to make it better.
I would also like to know if there is a way ...
2
votes
1answer
60 views
Monty Hall simulator in Python 3.x
I've been working on Python for the past few weeks trying to get my head around it's syntax/naming conventions/style/etc. I decided to make a monty hall sim to see how it looks in python. For those ...
2
votes
1answer
48 views
C++ Dirent.h “Wrapper”
I do not want to call this a wrapper, but no other name comes to mind right now, so I'll use it incorrectly for the rest of the question - It's just a class that adds C++ functions to ...
1
vote
0answers
24 views
A routing heuristic: improving function speed
I am currently constructing a heuristic to solve a routing problem. Routes are represented by vector<int> of customer ID's, which are stored in the class <...
0
votes
0answers
25 views
SPSS JSON Conversion very slow
I stored several values two variables, that contain raw JSON strings.
To split the values into SPSS-variables i wrote a simple python script.
Everything works as expected, but it takes a long time.
...
4
votes
1answer
111 views
Calling 5 APIs to pick the cheapest hotel prices
I am using 5 Hotels APIs and trying to combine and pick min price hotel with unique hotels from all APIs. I am following these STEPS
Call All 5 APIsand wait for response.
get all static data from ...
1
vote
0answers
57 views
Node Server Pages
I wrote a small script that lets you run node.js inside .html files (the same as PHP). CGI-Node already does this, but uses CGI rather than FastCGI, which doesn't work with Nginx. Here's my code (...
7
votes
2answers
102 views
Epidemic simulation
The purpose of this code is to simulate epidemics across a population. There are 625 (pop) individuals at random locations. The epidemic parameters are infectious period (inf_period), trans (...
6
votes
2answers
590 views
Algorithms to find statistical information of an array
I was working on a program that creates an array, then gives statistical information about that array such as std dev, median, mode average etc.
I have written a method for each statistical value, ...
3
votes
0answers
37 views
4
votes
2answers
52 views
Simple prime number search with trial division
I made a primality tester with trial division. I'm trying to make it as fast as possible and have reached the point now where I'm out of ideas.
I use the generator approach and not lists because I ...
1
vote
1answer
30 views
Transfer of data instead of copy.paste.clear used
I am using this code in a worksheet to check the condition, and based on the condition, copying the entire row of values in a different range of particular condition if true.
For copying I am ...
1
vote
0answers
14 views
Fast HashIndex (HashTable) “template” for indexes and arrays C++
Another in the long line of data structures I'm writing for my 2D isometric game. This is a hashtable that only handles indexes, hence eHashIndex. It does not copy ...
3
votes
1answer
51 views
C++ LinkedList Implementation
I've been studying data structures and making implementations for different types. This is my linked list code. Please let me know if there's anything here that could be improved upon or changed for ...
2
votes
0answers
18 views
Mesh Modifier System in the Unity Game Engine using C#
The system is meant to replicate the deformers and modifiers commonly used in 3D modeling programs like 3DS Max, Maya, Blender and Cinema 4D. I made a post on Reddit, explaining the features and ...
3
votes
2answers
68 views
Constructing expressions that produce integers by only using digits in string '2017' and high school level operators and functions
At school, we have a competition where the winner is determined by the length of their unbroken sequence of expressions that evaluate to integers 0 to n.
You must use the next year's number in the ...
4
votes
2answers
66 views
Writing a thread-safe queue in C++
I created a SafeQueue class, which stores pointers. It has two methods:
push: Adds a new pointer to the queue
next: If the queue is empty, returns nullptr. ...
4
votes
2answers
98 views
Serial Port Communication
This is an efficiency question to the following code, written in MS Visual in C#. If any explanation is missing, please let me know and I will add. What this part of the program does is:
Button is ...
2
votes
1answer
52 views
Find a substring count in an string
This code is written to find substring count in a string in Python 3. The original problem description is here. Please suggest better ways of solving this.
...
2
votes
2answers
46 views
Finding the longest path in an equally-weighted tree
Its purpose is to find the longest path in an equally-weighted tree denoted as such:
3
1 2
2 3
The first number denotes both the number of vertices and the ...
0
votes
1answer
57 views
Three function Calculator 2.0
A week ago I did a three function calculator, I took the input from you guys and made it better. Overall it works fine, I didn't find any problems. But as a beginning programer I'd like some imput on ...
3
votes
1answer
169 views
Finding line numbers of duplicate lines in a log file
I have a log file with a million lines, and my task is to code something that outputs the lines that have duplicates, and the line numbers.
I've thought of two ways to approach this :
1) Use python'...
1
vote
0answers
21 views
Arduino sketch running on Arduino Mega as a web server
I have Arduino Mega with Ethernet shield mounted on top running as a web server.
It reads temperature, humidity, rain or not and pot soil moisture and then displays on web page. Can you please review ...
3
votes
2answers
82 views
Percolation using quick union connectivity algorithm
This is my attempt to solve the percolation problem for the Princeton Algorithm-I course, the problem is well-defined here. My implementation is in C++ not Java and the following procedure is followed:...
3
votes
3answers
174 views