tagged [algorithm]

Encoding a number, C# implementation of z-base-32 or something else?

Encoding a number, C# implementation of z-base-32 or something else? I need to encode/decode an integer which is up to 9 digits long but most often 7 digits long. I'd like to make it easier to communi...

7 Oct at 05:49

Nice & universal way to convert List of items to Tree

Nice & universal way to convert List of items to Tree I have list of categories: ``` ╔════╦═════════════╦═════════════╗ ║ Id ║ Name ║ Parent_id ║ ╠════╬═════════════╬═════════════╣ ║ 1 ║ Sports ...

19 Aug at 14:45

Finding the second highest number in array

Finding the second highest number in array I'm having difficulty to understand the logic behind the method to find the second highest number in array. The method used is to find the highest in the arr...

11 Aug at 13:5

How to calculate rounded corners for a polygon?

How to calculate rounded corners for a polygon? I'm looking for an algorithm that allows me to create rounded corners from a polygon. I have an array of points that represents the polygon (outlined in...

Finding the position of the maximum element

Finding the position of the maximum element Is there a standard function that returns the position (not value) of the maximum element of an array of values? For example: Suppose I have an array like t...

13 Jul at 22:13

Algorithm for intersection of 2 lines?

Algorithm for intersection of 2 lines? I have 2 lines. Both lines containing their 2 points of X and Y. This means they both have length. I see 2 formulas, one using determinants and one using normal ...

23 Jun at 15:2

Converting a Uniform Distribution to a Normal Distribution

Converting a Uniform Distribution to a Normal Distribution How can I convert a uniform distribution (as most random number generators produce, e.g. between 0.0 and 1.0) into a normal distribution? Wha...

6 Jun at 20:56

Breadth First Vs Depth First

Breadth First Vs Depth First When Traversing a Tree/Graph what is the difference between Breadth First and Depth first? Any coding or pseudocode examples would be great.

How can building a heap be O(n) time complexity?

How can building a heap be O(n) time complexity? Can someone help explain how can building a heap be complexity? Inserting an item into a heap is , and the insert is repeated n/2 times (the remainder ...

What's the algorithm to calculate aspect ratio?

What's the algorithm to calculate aspect ratio? I plan to use it with JavaScript to crop an image to fit the entire window. : I'll be using a 3rd party component that only accepts the aspect ratio in ...

How to round to nearest even integer?

How to round to nearest even integer? My last goal is always to round to the . For example, the number `1122.5196` I want as result `1122`. I have tried this options: At the end, what I would like to ...

22 Apr at 19:8

Find if point lies on line segment

Find if point lies on line segment I have line segment defined by these two points: and . I have point . How can I check if the point lies on the line segment?

8 Apr at 22:23

Which is better: O(n log n) or O(n^2)

Which is better: O(n log n) or O(n^2) Okay so I have this project I have to do, but I just don't understand it. The thing is, I have 2 algorithms. and . Anyway, I find out in the project info that if ...

How does one make a Zip bomb?

How does one make a Zip bomb? [This question](https://stackoverflow.com/questions/1459080/how-can-i-protect-myself-from-a-zip-bomb) about zip bombs naturally led me to the [Wikipedia page](http://en.w...

16 Mar at 20:42

Creating a power set of a Sequence

Creating a power set of a Sequence I am trying to create a program that is a base for creating possible combinations of a sequence, string or a number. This is some sort of encryption / decryption pro...

11 Mar at 23:38

Peak signal detection in realtime timeseries data

Peak signal detection in realtime timeseries data --- The best performing algorithm [is this one](https://stackoverflow.com/questions/22583391/peak-recognition-in-realtime-timeseries-data/22640362#226...

C# - Add watermark to the photo by special way

C# - Add watermark to the photo by special way I need add watermark to the photo by special way. I know how to do it, but I don't know, how to do it the same way as in [this](http://www.photoshopessen...

What is the complexity of the sorted() function?

What is the complexity of the sorted() function? I have a list of lists and I am sorting them using the following Was wondering what is the runtime complexity of this python function?

18 Feb at 17:28

Standard Normal Distribution z-value function in C#

Standard Normal Distribution z-value function in C# I been looking at the recent blog post by Jeff Atwood on [Alternate Sorting Orders](https://blog.stackoverflow.com/2009/10/alternate-sorting-orders/...

18 Jan at 12:38

What is the difference between a generative and a discriminative algorithm?

What is the difference between a generative and a discriminative algorithm? What is the difference between a and a algorithm?

HSL to RGB color conversion

HSL to RGB color conversion I am looking for an algorithm to convert between HSL color to RGB. It seems to me that HSL is not very widely used so I am not having much luck searching for a converter.

24 Nov at 03:8

Construct polygons out of union of many polygons

Construct polygons out of union of many polygons Supposed that I have many polygons, what is the best algorithm to construct a polygon--maybe with holes- out of the union of all those polygons? For my...

How to implement a binary tree?

How to implement a binary tree? Which is the best data structure that can be used to implement a binary tree in Python?

Breadth First Search time complexity analysis

Breadth First Search time complexity analysis The time complexity to go over each adjacent edge of a vertex is, say, `O(N)`, where `N` is number of adjacent edges. So, for `V` numbers of vertices the ...

Is it more efficient to copy a vector by reserving and copying, or by creating and swapping?

Is it more efficient to copy a vector by reserving and copying, or by creating and swapping? I am trying to efficiently make a copy of a vector. I see two possible approaches: ``` std::vector copyVecF...

1 Aug at 03:16