Skip to content
StackDecode
Stacks & queuesExplained

Infix to Prefix Conversion

Reverse, convert to postfix with swapped brackets, reverse again.

Time

O(n)

Extra space

O(n)

Use it for

Prefix (Polish) notation.

An animated walkthrough for this algorithm isn’t built yet. The summary above explains the idea; see the related animated algorithms below to practise the same technique.