# The Algorithmic problems?

## Presentation on theme: "The Algorithmic problems?"— Presentation transcript:

The Algorithmic problems?

The 3 water jug problem There are three jugs on the table - 3, 5, and 8 ltr. The first two are empty, the last contains 8 ltr. of water. By pouring water from one glass to another make at least one of them contain exactly 4 ltr. of water.

3 Water Jug Problem

The 3 water jug solution Move from 3 to 1 Move from 1 to 2
Final - Jug1: 3, Jug2: 1, Jug3:4

The Tower of Hanoi The Tower of Hanoi or Towers of Hanoi is a mathematical game or puzzle. It consists of three rods, and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape. The objective of the puzzle is to move the entire stack to another rod, obeying the following rules: Only one disk may be moved at a time. Each move consists of taking the upper disk from one of the rods and sliding it onto another rod, on top of the other disks that may already be present on that rod. No disk may be placed on top of a smaller disk.

The Tower of Hanoi

The Tower of Hanoi (Solution)
If Disks are 3: Move from Src to Dst Move from Src to Aux Move from Dst to Aux Move from Aux to Src Move from Aux to Dst

The Tower of Hanoi (Solution)
If Disks are 4: Move from Src to Aux Move from Src to Dst Move from Aux to Dst Move from Dst to Src Move from Dst to Aux Move from Aux to Src

The Tower of Hanoi (Solution)
Move top N-1 disks from Src to Aux (using Dst as intermediary peg). Move bottom disk from source to destination. Move N-1 disks from Aux to Dst (using Src as an intermediary peg).

Similar presentations