Top "Algorithm" questions

An algorithm is a sequence of well-defined steps that defines an abstract solution to a problem.

How might I find the largest number contained in a JavaScript array?

I have a simple JavaScript Array object containing a few numbers. [267, 306, 108] Is there a function that would find the largest …

javascript algorithm arrays max
how to calculate binary search complexity

I heard somebody say that since binary search halves the input required to search hence it is log(n) algorithm. …

algorithm search time-complexity binary-search
What is the difference between a generative and a discriminative algorithm?

Please, help me understand the difference between a generative and a discriminative algorithm, keeping in mind that I am just …

algorithm machine-learning difference
How to determine if a point is in a 2D triangle?

Is there an easy way to determine if a point is inside a triangle? It's 2D, not 3D.

algorithm math geometry
hash function for string

I'm working on hash table in C language and I'm testing hash function for string. The first function I've tried …

c algorithm hash dictionary hashtable
Quick Sort Vs Merge Sort

Why might quick sort be better than merge sort ?

algorithm sorting
Efficient Algorithm for Bit Reversal (from MSB->LSB to LSB->MSB) in C

What is the most efficient algorithm to achieve the following: 0010 0000 => 0000 0100 The conversion is from MSB->LSB to LSB-&…

c algorithm bit-manipulation
Finding all cycles in a directed graph

How can I find (iterate over) ALL the cycles in a directed graph from/to a given node? For example, …

algorithm graph-theory graph-algorithm
How to find the kth largest element in an unsorted array of length n in O(n)?

I believe there's a way to find the kth largest element in an unsorted array of length n in O(…

performance algorithm big-o
What is the best algorithm for overriding GetHashCode?

In .NET, the GetHashCode method is used in a lot of places throughout the .NET base class libraries. Implementing it …

.net algorithm hashcode gethashcode