tagged [algorithm]

Recognizing handwritten shapes

Recognizing handwritten shapes I want to recognize handwriting shape and figure out which shape it probably is in the set. Simply saying, if I draw a triangle, the application should recognize it as a...

30 May at 05:30

Camera Module Focus Adjust using Contrast Transfer Function

Camera Module Focus Adjust using Contrast Transfer Function Currently I'm designing a test program for mobile phone camera module. I'm trying to control a precision motor that adjust the focus barrel ...

Sorting a linked list

Sorting a linked list I have written a basic linked list class in C#. It has a Node object, which (obviously) represents every node in the list. The code does not use IEnumerable, however, can I imple...

All Possible Combinations of a list of Values

All Possible Combinations of a list of Values I have a list of integers `List` in my C# program. However, I know the number of items I have in my list only at runtime. Let us say, for the sake of simp...

13 Feb at 07:58

Counting inversions in an array

Counting inversions in an array I'm designing an algorithm to do the following: Given array `A[1... n]`, for every `i A[j]`. I'm using merge sort and copying array A to array B and then comparing the ...

25 Oct at 09:12

How to find all possible subsets of a given array?

How to find all possible subsets of a given array? I want to extract all possible sub-sets of an array in C# or C++ and then calculate the sum of all the sub-set arrays' respective elements to check h...

16 Sep at 22:24

Finding the max/min value in an array of primitives using Java

Finding the max/min value in an array of primitives using Java It's trivial to write a function to determine the min/max value in an array, such as: ``` /** * * @param chars * @return the max value i...

13 Mar at 07:32

Quadrilateral Shape Finding Algorithm

Quadrilateral Shape Finding Algorithm I want to detect and all possible quadrilateral shapes from randomly located line segments! The photo attached is an example, the lines might always appear in ver...

I'm learning AI, what game could I implement to put it to practice?

I'm learning AI, what game could I implement to put it to practice? I have taken an AI course, and the teacher asked us to implement a game that makes use of one of the AI algorithms. Here is where I ...

Is using Random and OrderBy a good shuffle algorithm?

Is using Random and OrderBy a good shuffle algorithm? I have read [an article](http://www.codinghorror.com/blog/archives/001015.html) about various shuffle algorithms over at [Coding Horror](http://ww...

15 Oct at 19:39

Fastest way to check if an array is sorted

Fastest way to check if an array is sorted Considering there is an array returned from a function which is of very large size. What will be the `fastest` approach to test if the array is sorted? A sim...

22 May at 20:53

.NET Date Compare: Count the amount of working days since a date?

.NET Date Compare: Count the amount of working days since a date? What's the easiest way to compute the amount of working days since a date? VB.NET preferred, but C# is okay. And by "working days", I ...

3 Oct at 06:21

Overriding GetHashCode

Overriding GetHashCode As you know, GetHashCode returns a semi-unique value that can be used to identify an object instance in a collection. As a good practice, it is recommended to override this meth...

Best way to reverse a string

Best way to reverse a string I've just had to write a string reverse function in C# 2.0 (i.e. LINQ not available) and came up with this: Personally I'm not crazy

3 Mar at 22:18

What is the fastest way to transpose a matrix in C++?

What is the fastest way to transpose a matrix in C++? I have a matrix (relatively big) that I need to transpose. For example assume that my matrix is I want the result be as follows: What is the faste...

29 Dec at 03:28

Doubling a number - shift left vs. multiplication

Doubling a number - shift left vs. multiplication What are the differences between and ``` int size = length

17 Jun at 07:38

Best algorithm to test if a linked list has a cycle

Best algorithm to test if a linked list has a cycle What's the best (halting) algorithm for determining if a linked list has a cycle in it? [Edit] Analysis of asymptotic complexity for both time and s...

Formatting IPv6 as an int in C# and storing it in SQL Server

Formatting IPv6 as an int in C# and storing it in SQL Server Under `IPv4` I have been parsing the string representation of IP addresses to `Int32` and storing them as `INT` in the `SQL Server`. Now, w...

30 Mar at 13:28

.NET library for text algorithms?

.NET library for text algorithms? Do you know any .NET library for text algorithms?? Especially I'm interested in strings match, and full-text-search algorithms like - - - I know the one I have mentio...

C# Diff Algorithm for Text

C# Diff Algorithm for Text I'm looking for a diff algorithm that will produce results like SO's edit revisions page. I've more or less just started looking and I'm not opposed to doing it myself but I...

23 Sep at 12:33

C#: Seeking PNG Compression algorithm/library

C#: Seeking PNG Compression algorithm/library I need to compress or at least drop the quality of some png images that users are uploading to my site. I already resized it but that doesn't do much for ...

23 Dec at 15:35

Find common substring between two strings

Find common substring between two strings I'd like to compare 2 strings and keep the matched, splitting off where the comparison fails. So if I have 2 strings: Another example, as the string could hav...

Check if any item in a list matches any item in another list

Check if any item in a list matches any item in another list A coleague asked me to write a one-liner to replace the following method: ``` public static bool IsResourceAvailableToUser(IEnumerable reso...

24 Mar at 13:46

Algorithm for simplifying decimal to fractions

Algorithm for simplifying decimal to fractions I tried writing an algorithm to simplify a decimal to a fraction and realized it wasn't too simple. Write `0.333333...` as `1/3` for example. Or `0.16666...

27 Dec at 21:46

Python Brute Force algorithm

Python Brute Force algorithm I need to generate every possible combination from a given charset to a given range. Like, And the out put should be, I know I can do this using already in use libraries.B...

31 Jul at 19:9