In a given array of elements like

[a_{1}, a_{2}, ..., a_{n}, b_{1}, b_{2}, ..., b_{n}, <X>_{1},<X>_{2}, ..., <X>_{n}]

without taking a extra memory swap elements in the array so the outcome will be like

[a_{1}, b_{1}, … <X>_{1}, a_{2}, b_{2}, … <X>_{2}, …, a_{n}, b_{n}, …, <X>_{n}] Continue reading

# Tag Archives: cpp

# Algorithms: Puzzle called “Falling egg”

Assume you are given 2 eggs.

You have access to a 100-floors high building

Eggs can break if dropped from the first floor or may not even break if dropped from 100th floor.

Both eggs are identical.

*You need to figure out the highest floor of a 100-storey building an egg can be dropped from without breaking.
The question is how many drops you need to make. You are allowed to break 2 eggs in the process Continue reading *

# Floyd’s Cycle-Finding Algorithm

If you want to check if your linked list is circular you can use Floyd’s Cycle-Finding Algorithm aka `Tortoise and the Hare Algorithm`

.

*It’s quite efficient as **It has O(n) complexity.
Continue reading *

# Algorithms: Binary tree

Simple implementation of binary tree in C++ Continue reading

# Algorithms: Queue

Simple implementation of Queue with exception handling in C++ using templates Continue reading

# Algorithms: Stack

Simple implementation of Stack with exception handling in C++ using templates Continue reading

# Algorithms: Two-way linked list

Simple implementation of *Two-way linked list* in C++ Continue reading