

Apologies for the shouting but this is important.
When answering a question please:
 Read the question carefully
 Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
 If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
 If the question is inappropriate then click the 'vote to remove message' button
Insults, slapdowns and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers, Chris Maunder
The Code Project Cofounder Microsoft C++ MVP





For those new to message boards please try to follow a few simple rules when posting your question. Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
 Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
 Keep the subject line brief, but descriptive. eg "File Serialization problem"
 Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
 Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
 Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
 If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
 Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
 Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
 Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
 If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
 No advertising or soliciting.
 We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers, Chris Maunder The Code Project Cofounder Microsoft C++ MVP





Hi everyone, If there is anything you don't understand in what I'm about to explain, feel free to express it, as english is not my mother language.
I'm working on a bus routing problem. I've been reading few papers about vehicule routing problem, network designing and stuff like that, in order to pick the algorithm that will fit the most what I want.
Seems like genetic algorithm is the most used for that kind of problem. However, I don't know if it fits with my specific demand, cause I have less constraints than in the applications covered in the papers, so I was wondering maybe there are "simpler" algorithms out there that can do the job.
Thing is I don't have no constraints regarding traffic or vehicle capacity nor designing the network itself : in fact, my input data are :  Predefined bus lines with all the stops  Distance between each point  Schedules for each lines
So my work consists in determining how much buses do I need to optimize use time and distance for each bus used.
My real question is, should I keep looking into genetic algorithms even if I have less constraints than in the applications of it i've seen, or do you feel that there can be a more effective algorithm.
Thanks a lot for reading this





You should read about Linear Programming. Linear programming  Wikipedia[^]
Patrice “Everything should be made as simple as possible, but no simpler.” Albert Einstein
modified 21Nov16 13:09pm.





I would find it hard to pick an algorithm until I had defined what it means to "optimize use time and distance".
That's the type of statement a "salesman" would come up with; and which winds up sinking a project because nobody knows what it means (although everyone assumes everyone else knows what it means).





Hey guys, Im stuck on this algorithm or problem for which I have to come up with a solution and create psuedocode for this. Any help would be appreciated. "The Big British Brass Barrel Consortium (BBBBC) has a lot of barrels (made of brass). Every day they receive a large set of orders from other companies for their barrelling needs. Each company will send them a list of different fluids that they have, for which they need barrels to transport the fluids. The various amounts of fluids will be specified in terms of their volume in cubic metres. The BBBBC have a large stock of barrels and they store the height and diameter of their barrels in a database. Every day they need to work out if they have enough barrels in stock to fulfil the orders. If they don’t then they need to compile a list of the number and capacity of barrels that they’ll need to borrow from their competitors. Propose a solution to solve this problem." Thats what I got to DO! Also, Private messages would be appreciated.





A public message: this is your homework so you are expected, at the very least, to make an effort to solve it yourself.





We do not do your HomeWork. HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them. Any failure of you will help your teacher spot your weaknesses and set remedial actions. So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.
As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better. When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Patrice “Everything should be made as simple as possible, but no simpler.” Albert Einstein





Hi there, I am interested in reading about the prediction of schedules/calendars. However, I am pretty sure I am looking for the wrong terminology (often finding papers to do with processor instruction scheduling etc.).
An example of something I want to achieve is: a user is logging each time they exercise during the day and for how long, over time this builds up a past schedule of their exercise routine. Based on that past routine, I would like to predict what the next day's exercise may be like taking into account patterns that emerge (for example, only swimming on thursday afternoons for 1hr).
What should I be looking for? What would this area be called? Any good examples of papers in this area? Thanks for your help!
Thanks, Ronan






Neural networks.
You define a model: any perceived relationships between inputs and outputs; you "train" the model using historical data; then have the model "predict" an outcome based on new inputs. e.g.
Test Run  Dive into Neural Networks[^]





Hello, For my new project, I have to develop an algorithm called frequency sweep. The function parameters are nFreqStart, nFreqEnd and dSweepTime'. As an example: for nFreqStart = 800Hz, the period T of this signal is 1.25ms, for nFreqEnd = 1600Hz, T is 0.625ms and the sum of all frequencies from nFreqStart to nFreqEnd must not be higher than dSweepTime.
My first version of this function is:
uint16_t nFrequencies;
void sweep_initialize(const uint16_t nFreqStart, const uint16_t nFreqEnd, const double dSweepTime)
{
double dTotalTime = 0.0;
double dIncrement = 0.0;
uint16_t nStep = 0;
double dTmpFreq = 0.0;
bool bSweep = true;
double dInitialTime = (1.0 / nFreqStart) + (1.0 / nFreqEnd);
nFrequencies = 2;
while (bSweep == true)
{
dTotalTime = dInitialTime;
dIncrement = (double)(nFreqEnd  nFreqStart);
dIncrement /= (double)(nFrequencies);
dTmpFreq = (double)nFreqStart;
nStep = nFrequencies  1;
for (uint16_t i = 0; i < nStep; i++)
{
dTmpFreq += dIncrement;
dTotalTime += 1.0 / dTmpFreq;
}
nFrequencies += 1;
if (dTotalTime >= dSweepTime)
{
bSweep = false;
break;
}
}
}
The next thing is, I need a counter (cpu clocks) for each frequency:
uint16_t* pSweep_Array;
void sweep_getCounter()
{
if (pSweep_Array != NULL)
{
free(pSweep_Array);
pSweep_Array = NULL;
}
pSweep_Array = (uint16_t*)malloc(sizeof(uint16_t) * nFrequencies);
if(pSweep_Array != NULL)
memset(pSweep_Array, 0, sizeof(uint16_t) * nFrequencies);
double dFrequency = (double)nFreqStart;
double dIncrement = (double)(nFreqEnd  nFreqStart);
dIncrement /= (double)(nFrequencies  1);
double dCounter = 0.0;
for (uint16_t i = 0; i < nFrequencies; i++)
{
dCounter = 65536  (F_CPU / dFrequency);
pSweep_Array[i] = (uint16_t)round(dCounter);
dFrequency += dIncrement;
}
}
But as a result, the computation complexity is O((n1)! * n^{2}), where n is the number of frequencies between nFreqStart and nFreqEnd, including nFreqStart & nFreqStop.
I need help for a less complex solution (function).





What I don't understand is why you do your first counter.
I guess my first question is: Why are you trying to calculate the frequencies of your CPU, but also how? You're just simply increasing an integer every time it loops?
In your first loop, your initialize, you set the nStep to one less than your frequencies? Literally all I'm seeing is that you are getting the summation of all numbers between 800 and 1600.
If all you need to do is calculate "the computation complexity... O((n1)! * n2)" then you should do exactly that. But you're not doing that. You're doing: ∑_{k=1}^{800}0.001875/k
Instead just set n1 to nFreqEnd  nFreqStart and n2 to nFreqStop  nFreqStart. Then plug it in. I don't understand what O is, but plug that in too. It would be helpful to know what you are returning exactly...





Hello, so I have to write a term paper on the subject of Root sorting. Google doesn't give me anything useful so I am here to ask someone who understands data structures and algorithms to give me some pointers on the subject. As far as I got is that I figured out it has something to do with sorting a binary tree and using the root of a binary tree. Can you please give me some insight on what algorithms should I look for or what book should I read?





Is that really what they said? It doesn't look like it's a thing.





Radix is Latin for root > Radix Sorting!
Cheers!
"I had the right to remain silent, but I didn't have the ability!"Ron White, Comedian





Excellent, now it makes sense





It is really called Radix Sorting[^]. Radix is Latin and means root. So it seems to me someone bungled this up and it got "lost in translation".
Cheers!
"I had the right to remain silent, but I didn't have the ability!"Ron White, Comedian





You can read Corman to understand the basics of algorithm.





Why are you repiying to me?
Are you confused?
"I had the right to remain silent, but I didn't have the ability!"Ron White, Comedian





I am doing an introductory course on algorithms. I've come across this problem which I'm unsure about. I would like to know which of the 2 are dominant
f(n): 10 log n or g(n): log(n^2)
Given the definitions of each of: Ω, Θ, O
I assumed f(n), so fn = Ω(g(n)) Reason being that log(n^2) is equivalent to 2 log n, so 10 log n is dominant.
Could somebody verify or offer an alternative?





Why don't you draw the graph and see which one is closer to the bottom? Basically, these are just the grading system of the algorithms (used to classify the algorithms based on their complexity), to find out which is better as compared to which is not. I personally use only Big O notation (instead of others, lower bounds, both bounds etc. instead of all of that just consider Big O, and draw the graph). Go here and do that, https://www.desmos.com/calculator[^]. The larger that a function grows with each input, the more time and space that it consumes (time and space might be relative to the data source or the algorithm being used). That is why, a better algorithm is the one that doesn't take much time. In my opinion, log (n^{2}) is a better function — look at the slopes that each of them makes.
Secondly, Quote: which of the 2 are dominant What do you mean by dominant? The better algorithm would have a lower slope as compared to the one with a higher slope (the higher slope one is a bad algorithm depending on the data source).
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out  Eminem
~! Firewall !~





thanks for the link. I assumed that a "dominant" function is equivalent to f = Ω(g), where f is 10 log n. So we are in agreement, since conversely g is O(f), where g is log(n^2). I was simply attempting to use a mathematical approach to prove or disprove.





hello all
i found this task:
"Given an undirected graph G = (V,E), and an integer k, the cycleelimination problem is to decide if all the cycles of the graph can be eliminated by deleting at most k edges from the graph. Either show that the problem is NPcomplete, or describe a polynomialtime algorithm for it "
do you have some ideas for the solution ? shall i reduce the task to Feedback arc set problem ?
Thank you very much




