Top "Algorithm" questions

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

How to detect a loop in a linked list?

Say you have a linked list structure in Java. It's made up of Nodes: class Node { Node next; // some user …

java algorithm data-structures linked-list
How to find the lowest common ancestor of two nodes in any binary tree?

The Binary Tree here is may not necessarily be a Binary Search Tree. The structure could be taken as - …

algorithm binary-tree complexity-theory least-common-ancestor
Is it possible to get all arguments of a function as single object inside that function?

In PHP there is func_num_args and func_get_args, is there something similar for JavaScript?

javascript algorithm function arguments marshalling
Leap year calculation

In order to find leap years, why must the year be indivisible by 100 and divisible by 400? I understand why it …

algorithm calendar leap-year
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 …

algorithm colors rgb hsl
Rotating a point about another point (2D)

I'm trying to make a card game where the cards fan out. Right now to display it Im using the …

c++ algorithm
What is a loop invariant?

I'm reading "Introduction to Algorithm" by CLRS. In chapter 2, the authors mention "loop invariants". What is a loop invariant?

algorithm terminology definition clrs loop-invariant
Ukkonen's suffix tree algorithm in plain English

I feel a bit thick at this point. I've spent days trying to fully wrap my head around suffix tree …

string algorithm data-structures language-agnostic suffix-tree
What is tail call optimization?

Very simply, what is tail-call optimization? More specifically, what are some small code snippets where it could be applied, and …

algorithm recursion language-agnostic tail-recursion tail-call-optimization
Swap two variables without using a temporary variable

I'd like to be able to swap two variables without the use of a temporary variable in C#. Can this …

c# algorithm swap