Click here to Skip to main content
15,883,705 members
Everything / General Programming / Algorithms

Algorithms

algorithm

Great Reads

by Arthur V. Ratz
In this article we'll demonstrate the implementation of k-means clustering algorithm to produce recommendations.
by Igor Ladnik
Automatic generation of optimal control policies for the basic quadcopter flight modes
by Eric Ouellet, Sani Huttunen
Fast implementations of permutation algorithms
by Dmitriy Gakh
Development in C# without care of resource consumption can lead to overloading the system. This article describes a case with large waste of memory and CPU time and how to avoid it.

Latest Articles

by Igor Gribanov
C++ iterators and algorithms work well for containers, but can we sort the Structure of Arrays?
by Henrik Vestermark
The steps needed to build an Interval Arithmetic class in C++
by Ștefan-Mihai MOGA
How to solve real-life problems using B-trees
by Nicolas DESCARTES
How to implement logistic regression in ML.NET?

All Articles

Sort by Title

Algorithms 

18 Aug 2016 by Anti-Antidote
For some reason, the replace template from does not want to work for me. See example code below:#include #include #include using namespace std;int main() { string s = "Hello, world!"; replace(s.begin(), s.end(), "l", "i"); cout
18 Aug 2016 by Jochen Arndt
Your call replace(iterator, iterator, const char*, const char *) does not match the std::replace template:template void replace(_FIter, _FIter, const _Tp&, const _Tp&);_Tp is char here because the std::string iterators are pointing to char.So you must...
13 Jan 2011 by fika_fa
Hi all!I want to write a program in C# that will convert a .dxf file to a g-code file. Can anyone help me or point me in the right direction?Best regards,[Your (screen) name here]
4 Jun 2010 by Richard MacCutchan
You could have tried this[^] first.
4 Jun 2010 by Sandeep Mewara
I googled this [^]and got below any many more links!http://www.inkscape.org/[^]http://www.rotordesign.com/servolite/body_dxf_to_gcode.html[^]BTW, how is your question related to C#?
13 Jan 2011 by stevedayus
http://www.cnc...
2 Apr 2013 by chairergs
I need to develop VC by import G-code into my software develop and output it to my machine(CNC) by used parallel port.How do we do?
13 Sep 2021 by Mircea Neacsu
Various algorithms for 2D interpolation
8 Apr 2020 by Member 10107283
Hello,Where can I find a 3D image segmentation code using Otsu thresholding or using watershed transform. In any language but preferably in MATLAB language. kindly direct me to the right placeThank you very much,
14 Jul 2013 by Sudhir Tiwari
8/15 puzzle using A* (A Star) algorithm.
6 Aug 2020 by JacksonSteel
input: babad abbd output: ad bb expected: bab bb #include using namespace std; class Solution { public: string longestPalindrome(string s) { int maxlength=1; bool ispalindromic[1000][1000]={false}; ...
4 Aug 2020 by OriginalGriff
Compiling does not mean your code is right! :laugh: Think of the development process as writing an email: compiling successfully means that you wrote the email in the right language - English, rather than German for example - not that the email...
6 Aug 2020 by Patrice T
Advice: Learn to indent properly your code, it show its structure and it helps reading and understanding. It also helps spotting structures mistakes. #include using namespace std; class Solution { public: string...
1 Oct 2015 by DP17000
A rudimentary expert system in VBA/ Excel 2013
22 Apr 2016 by Darryl Bryk
C# code for a low-pass Butterworth filter is presented
2 Jan 2019 by Octavio Loyola-González, Miguel Angel Medina-Pérez, Andres Eduardo Gutierrez Rodriguez, Milton García Borroto
In this article, we introduce a framework in C# for fingerprint verification, we briefly explain how to perform fingerprint verification experiments and how to integrate your algorithms to the framework.
12 Jan 2016 by shijo joseph
An ADO.NET Layer for SQL Server and Oracle which makes it easier for interfacing with database
11 Dec 2023 by JorgeLuisOrejel
This article describes the implementation of Dijkstra's Smoothsort as a generic sorting algorithm in C#.
6 Sep 2016 by George Swan
An artificial life algorithm that attempts to solve a problem by flying a swarm of entities through a range of possible solutions where each entity is guided by the performance of other members of the swarm
20 Dec 2015 by shijo joseph
An easy to implement yet powerful logging library which requires absolute zero learning curve
16 Jan 2016 by Mathew_wwx
This tip will introduce a library written in C++ that wraps up a 2d polygon triangulation algorithm with time complexity of O(N*logN), the algorithm works on both self-intersected and non self-intersected polygons.
28 Mar 2012 by yamen-nassif
can any one help me by finding a wayhow to right a program to check whether the number belongs to fibonacci serieswithout counting the whole fibonacci numbers?????fibonacci series math code is f(x)=f(x-1)+f(x-2) x>=2the counting code is easy but i need to check a number...
28 Mar 2012 by Bernhard Hiller
That's described in wikipedia:http://en.wikipedia.org/wiki/Fibonacci_number[^], chapter "Recognizing Fibonacci numbers".
28 Mar 2012 by chandanadhikari
hi,ask the user to input a number, store that in a variable.In a loop,start generating fibonacci number one by one using your formula and compare each number with users input, if this is same as users input,then display mesage accordingly. if its NOT same,then generate next number of the...
29 Mar 2012 by Resmi Anna
suppose you input the value to the variable NThen following code checks whther N belongs to Fib seriesdouble dRes1 = sqrt((5*pow(N, 2))-4);int nRes1 = (int)dRes1;double dDecPoint1 = dRes1 - nRes1;double dRes2 = sqrt((5*pow(N, 2))+4);int nRes2 = (int)dRes2;double dDecPoint2 =...
29 Mar 2012 by aayushraina
As suggested by Resmi the mathemaical approach is the best for your question.However, if memory is not a constaint and you want your application for repetitive use.I suggest go for a simplified approach of Dynamic programming 1)Keep a Dynamic Array []2)Whenver input is given do a...
30 Jan 2012 by Dirk Bahle
UI and code-behind is executed in different threads. Long running processes need asynchronous execution. This artice shows a way of doing this in a ViewModel approach.
12 Feb 2014 by charles henington
This is an alternative for "Send Mail With Attachment File"
13 Oct 2013 by Member 9294701
A simple, portable yet efficient Quicksort implementation in C
2 Feb 2011 by George Tryfonas
Assembler and Simulator for Don Knuth's MIX Computer from The Art of Computer Programming.
28 Jul 2014 by Mostafa Eissa
This article explains the concept of graph coloring and how to use graph coloring to solve Sudoku Puzzles.
9 Jul 2022 by captnmac
A Tiger hash Implementation for C#, invocable through dotnet's HashAlgorithm class
21 Jan 2012 by Member 8586072
Hi...I wanna write a program in java that can count the number of balanced matrix of N*N...the only way that I know is to consider all the possible assginments for the matrix and then choose the answers...I searched the topic and found something about it in wikipedia...it solved the problem with...
22 Jan 2012 by TorstenH.
It's using recursive methods.2 articles / tutorials to this:http://www.hostitwise.com/java/java_recursion.html[^]http://www.javaworld.com/javaworld/javatips/jw-javatip62.html[^]
24 Feb 2019 by WhiskeyBeforeWater
This article instructs on how to implement a basic binary search tree using Excel VBA with insert, delete, search, traversal, minimum, and maximum. For a recursive answer please go to https://www.codeproject.com/Tips/1277790/A-Recursive-Binary-Search-Tree-For-VBA
24 Feb 2019 by WhiskeyBeforeWater
An unbalanced basic recursive Binary Search Tree for Excel VBA with functions (insert, search, delete, in order, pre-order, post-order, minimum, and maximum)
3 Jul 2016 by Mohammad_Jalili
Hello:i need simple implementation of A* algorithm in c# or java for understand it . because how much try to understand it's not successfully.tank all for help me.What I have tried:I reading content and article from Wikipedia and etc but anything like a simple example.
3 Jul 2016 by Peter Leow
Check this out: A Simple A* Path-Finding Example in C#[^]
3 Jul 2016 by OriginalGriff
No, that isn't what happens here.We don't do your homework, or your work - we aren't a code writing service.And as for "need simple implementation ... for understand it" that's not going to help you at all. An implementation of anything doesn't tell you why it's like it is, what decisions...
25 Nov 2010 by Mike$7
Hey Guys, I've used the A* algorithm to find the shortest path in C#, I gave it a maze but it does a loop instead of doing the most direct way. Is that normal? I'm calculating H with the Manhattan method.Here is a picture of the path it takes[^]The Yellow dot is the starting point, the...
25 Nov 2010 by JF2015
Hi,have a look at this implementation of the algorithm. Maybe this can help you:http://www.codeproject.com/KB/recipes/fast_astar_2D_algorithm.aspx[^]
11 Dec 2010 by Pallab_GT
Hi there. Can anyone tell me, where can i get the detail specification and implementation of the GSM security algorithms A3/A8 COMP128-3. Help would be highly appreciated.Thanks in advance.
11 Dec 2010 by Sandeep Mewara
Did you had a look at: GSM Security Algorithms [^]Looks like it had all the details.
28 May 2020 by kavinderrana121
I stuck at a problem SPOJ.com - Problem ABSYS[^] I executed my program on all the test cases ,I am getting correct answer. But still I am getting as "wrong answer" on spoj What I have tried: Breaking stream into strings storing them into vectors ,so we can say that our vector will have 5...
22 Jan 2019 by Arnav Varshney
I wouldn't be posting the entire code here, but I can surely help. This is how I would have had implemented the algorithm. First, take input in a string STR. Then break the string into 3 parts = NO1, NO2, ANS Now check in each string, if it contains the string "machula" Parse the string with...
22 Jan 2019 by Patrice T
Quote: But still I am getting as "wrong answer" on spoj Some site give logs of tests, any idea of the failing test ? Quote: Breaking stream into strings storing them into vectors ,so we can say that our vector will have 5 strings (numstring,+,numstring,=,numstring) Where have you seen that...
6 Nov 2023 by lock&_lock
I am back with my hackerrank problem. I am trying to exercise with this question: Between two sets. I need to make two arrays of integers and determine all integers that satisfy the following two conditions: The elements of the first array are...
25 Oct 2023 by OriginalGriff
Just as Richard found, if I copy and paste your code verbatim into an online compiler - OnlineGDB.com[^] - and run it, then enter this text:2 2 3 4 24 48 What do I get? "1", exactly the same as Richard. So ... it's an initialization problem, or...
6 Nov 2023 by Rick York
When I run this code I get 1 also. I think the key is your list_results vector. When I run this it has these values : 6 8 12 16 and the answer is obviously 1 because those numbers are factors of only one value : 12. This means you need to...
7 Apr 2015 by Member 11580516
I have a problem with counting small objects on the image. In example I used BlobCounter class (from AForge framework). But it doesnt recognize splitted objects. Here is the function outputhttp://s3.postimg.org/cwkexxucj/result.jpg[^]Here is the treshold that method...
7 Apr 2015 by Sergey Alexandrovich Kryukov
There is no such thing as "splitted" objects. From the blob recognition standpoint, they are just different objects (calculated correctly, for this matter). It's just your scenery is not well defined. You can play with contrast and other filters before applying blob recognition. Such...
16 Feb 2015 by Eric Z (Jing)
Evaluation order matters!
19 Aug 2020 by MehreenTahir
In this article we create a web app that trains the classifier on the go and recognizes grumpy facial expressions.
21 Dec 2021 by DomenTu
I would like to know if there is an anlgorithm that could help me solve the following example problem. First of we have a list of 1 and 0 : 011001010111 of length 12. Then we have an x number of 1 to inject anywhere in the list, for instance...
8 Mar 2022 by Member 15047625
A is a set of strings defined by alphabet {a, b, c}. Can it be represented as composition of two other sets of strings B and C? A = BC, but A != C and A != B. Composition means joining each string of set B with each string from set B (which...
8 Mar 2022 by Greg Utas
I thought the term for this was the product, not the composition, of two sets. But I don't know what the reverse operation is called. One approach would be to factor |C| (the cardinality of C). In your example, this yields 4x1 or 2x2, so you'd...
8 Mar 2022 by Arthur V. Ratz
Here's an algorithm: Alphabet: {a,b,c} Strings: aba ca abb cb The most complete solution to this is to build a dictionary M, mapping each string onto the letters, that existed in {a,b,c}, which have been occurred once or multiple times. Here,...
4 Jan 2015 by Sergey Alexandrovich Kryukov
If this is your home assignment, your next step should be to understand and then to convince your teacher that this is not a fully-defined problem.—SA
24 Apr 2016 by raddevus
Step by step walk-through with progressive versions of code downloads will take you from the basics of drawing on HTML5 Canvas while studying an interesting point-connecting algorithm.
26 Apr 2016 by raddevus
Adding more methods (select points, draw triangles, etc) which allow us to do some specialized drawing on the HTML5 Canvas so we can investigate the Calc Convex Hull algorithm.
27 Apr 2016 by raddevus
We learn how to generate random points (easy) and we enable functionality which allows the user to grab any point on the grid and move it around in real-time (see animated gif).
5 Dec 2010 by sai supriya
Can anyone help me with writing the code for agglomerative fuzzy k-means clustering algorithm. The language can be Java or Javascript.At least, I want some guidence on how to write the code please.Thank you!
7 Dec 2010 by sai supriya
i tried google but i didn't get it.i have an idea about java & javascript.
17 Nov 2013 by CoolStagram Pole
Need a good algorithm book with example written in C or C++ or C# language .pls suggest me
17 Nov 2013 by OriginalGriff
Knuth: The Art of Computer Programming[^]
17 Nov 2013 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
Some good answers - Books on Algorithms taught in C#[^] and one book - Data Structures and Algorithms[^].
17 Nov 2013 by thatraja
Useful Reference Books[^]
17 Nov 2013 by CPallini
A good introductory book is the oldie goldie Wirth's Algorithms + Data Structures = Programs[^] (it uses Pascal, however is very well written).You may also consider Sedgewick's books (I have no direct knowledge of them).Finally, the are (as already suggested by OriginalGriff) the Knuth's...
14 Apr 2016 by Member 12460800
I have letters in a string, I would like in result get all possible sets of those letters and convert them to numbers, each set should use all numbers, each number can occur only once in a set. numbers automatically should increment until 9. and output all possible combinations
14 Apr 2016 by xszaboj
I am not sure if this is what you need.But have a look on this problem:[^]and if this is the problem you are facingsolution is here:[^]it is in c#but general alghoritm is described here:Steinhaus Johnson Trotter permutation algorithm explained and implemented in Java...
25 Sep 2016 by Member 11846821
What would be the algorithm for following question- If you are given input(a,b) is it possible to reach(c,d) i.e from (a,b) you can go (a+b,b) or (a,a+b) n number of times .Answers should be in ‘yes’ or ‘No’. eg- i.e if ur (a,b) is -(1,4) it can move to (5,4)==>> (5,9)==>>(5,14) and so on....
25 Sep 2016 by CarelAgain
(x0, y0) can reach (x1, y1) if x0 can reach x1 and y0 can reach y1, assuming x0
25 Sep 2016 by Patrice T
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 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...
11 Dec 2013 by Member 10238389
I have an assignment bugging me. It's about a heap but not minHeap or maxHeap. It's average heap. Detailed explanation is here: http://homes.ieu.edu.tr/ocagirici/CE221/assignment4.pdf I am asking for an idea, how can i create that data structure.
11 Dec 2013 by OriginalGriff
Perhaps, before you try to get us to do your homework for you you might want to sit down and think about how it makes you look when your "question" to us consists of "here is my homework question - go look at it and give me an idea".For my perspective, it looks like someone too lazy to even...
16 Feb 2017 by Amir Hossein Hmd
Hey there, i want to write an algorithm for a pizza shop (c#) i wrote and i showed it to my friend, my friend said: your algorithm is wrong. and he wrote another algorithm. and right now i want to know which one of our algorithm is better? tell me which one is better and correct?...
16 Feb 2017 by OriginalGriff
Well, there is no algorithm there in either case - it's a "style thing" and your mate's version would fail most code reviews just for using goto unnecessarily.Me? I'd set the price of each as a constant value above the method, and set it once inside a switch instead of adding values on. I'd...
16 Feb 2017 by Patrice T
second code is definitively worse. Using goto's for such a simple problem is a sign that your friend need to improve its understanding of programming.Your code is barely better, but both of your codes are overly complicated.minimum code would look like this, assuming user input is...
29 Jan 2015 by forccyy
User enters 3 or 4 digit number say - X.I need a+b+c=X where,a,b,c are 3 digit numbers and all digits are unique among all 9 digits. That is a,b,c does not have any repetitive digit on any position. I need all possible combinations/solutions for 'X'. That is all possible a+b+c...
29 Jan 2015 by CHill60
Try this wiki article[^] as a starting point
29 Jan 2015 by OriginalGriff
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.Try it yourself, you may find it...
17 Sep 2013 by Abhinav Chitre
Do the following inductive proof:Let d1, d2, ..., dn, with n at least 2, be positive integers. Use mathematical induction to explain why, if d1+ d2+…+dn = 2n-2, then there must be a tree with n vertices whose degrees are exactly d1, d2, ..., dn. (Be careful with reading this statement. It is...
17 Sep 2013 by OriginalGriff
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.If it's an interview question,...
16 Feb 2011 by Archimedes24
Hi,I would like to find out a simple solution to the following problem:I have two time series data sets, in terms of discrete points. Now without involving extensive regression mathematics, i need to find out the point of intersection of these two data series. A close approximation would...
16 Feb 2011 by Albin Abel
Hi consider each point pair(vertices) form a edge. In that way construct a list of edges for time series 1 and another list for time series 2 for example the series goes like edge1(pt1,pt2) edge2(pt2,pt3) ....so on one vertex overlap with the previous edge.Now in a double loop...
16 Feb 2011 by CPallini
You may:Assume the points of each time series lie on a curve (and the curves have analytical representation: for instance a straight line).Use the method of least squares[^] to find the parameters of the curves.Find (either analytically or numerically) the intersection of the two...
8 Jul 2014 by riccardo68
I am searching an Algorithm for design a 2D map with a fixed tile set I must resolve a problem such as Windows 8 UII means I have a set of rectangle tiles of different size, NO FRACTIONAL.I have to compose a rectangle, using these tiles randomly.The size of the map could be 10x10...
8 Jul 2014 by George Jonsson
Maybe this can help you alonghttp://en.wikipedia.org/wiki/Metro_(design_language)[^]http://www.windows8designhandbook.com/[^]http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202948(v=vs.105).aspx[^]
18 Oct 2011 by spunkwire
what type of algorithm implemented on a event manager application made using C#
28 Feb 2014 by dhiwatdg
I'm writing a code that identifies the highest-scoring local alignment between a substring X' of X and a substring Y' of Y that has at least one column in which a C from X' is aligned to a W from Y'. Example: if X=:HCEA and Y=:HWEA, then some of the local alignments with a column that aligns...
4 Aug 2019 by OriginalGriff
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you. So we need you to do the...
4 Aug 2019 by CHill60
There is no "algorithm" - you need to apply some data analysis techniques to the problem - and that is no subject for a "Quick Answers" forum! Start here : Simple Statistical Analysis | SkillsYouNeed[^] You might want to specifically look at Time-to-Event analysis e.g. Time-To-Event Data...
4 Aug 2019 by MadMyche
At this time you have neither a code problem nor a code question; what you actually have is a programming need, and the hardest part for the users here to help you with. First thing you need to do is to identify what the actual need is ...to prepare the vehicle ahead of time and leap to the...
4 Aug 2019 by oronsultan
Hi guys, our company's product deals with automated parking solutions for lots of sites in the US. As part of the enhancement mechanism of the product, we want to study the regular users of the system and analyze their entry and exit times from the car park in order to prepare the vehicle ahead...
11 Sep 2013 by satish koladiya
Can any one suggest algorithm or code for random polygon generation. Condition is that polygon sides are not intersect (means it should be like a convex polygon).
10 Sep 2013 by Sergey Alexandrovich Kryukov
As the random distribution is not specified, I would suggest the following simple approach: start with a triangle, which is always a convex polygon except the case when all three point are on the same line, so throw out the cases when it happens. (As you are dealing with approximate...
11 Sep 2013 by Sergey Alexandrovich Kryukov
I just got an idea of an alternative, simpler algorithm.Start with a random triangle, as in Solution one, and, in a random number of steps, create a N+1-side polygon from an N-side using the "cut of a corner" operation. For this purpose, take two random but adjacent sides. In each side,...
11 Sep 2013 by Sergey Alexandrovich Kryukov
Now, one more, pretty obvious algorithm.Create N points in same range, for example, the square on the points (0,0) and (1, 1), where N is a random number >= 3. For the obtained set of points, build a convex hull. You can find some algorithm if you read this:...
2 Aug 2011 by jyoti87
Our project deals with searching for a video file and playing it from the given date and given time in minutes and seconds.The amount of audiovisual information available in digital format has grown exponentially in recent years. Gigabytes of new images, audio and video clips are generated...