Bead-Sort - A natural algorithm for sorting

1 / 18

Bead-Sort - A natural algorithm for sorting - PowerPoint PPT Presentation

Bead-Sort - A natural algorithm for sorting. Beads sort themselves out. Bead-Stack machine The “tilt” operation. 90 0. Bead-Sort: illustration 1. 1. 2. 3. Sorting {3, 1, 2}. 1. Drop 3 beads. (Remember, always from left-to-right). 2. Drop 1 bead. 3. Drop 2 beads.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

PowerPoint Slideshow about ' Bead-Sort - A natural algorithm for sorting' - eithne

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

- A natural algorithm for sorting

The “tilt” operation

900

1

2

3

Sorting {3, 1, 2}

(Remember, always from left-to-right)

1

2

3

Sorting {2, 3, 1}

(Remember, always from left-to-right)

1

2

3

Sorting {1, 3, 2}

(Remember, always from left-to-right)

1

2

3

4

Sorting {1, 3, 2, 4}

(Remember, always from left-to-right)

2

2

3

4

Sorting {2, 4, 3, 2}

(Remember, always from left-to-right)

0

0

Level_Count

1

3

2

1

1

Rod_Count

• Two linear arrays used.
• Rod_Count keeps track of number
• of beads in each rod.
• Level_Count records number of
• Finally, Level_Count will contain
• sorted data.

x + i

x

x

i

1 row (k = 1)

(i)

i

(iii)

x

x

x + i

(ii)

Mathematical induction on number of rows of beads

• Claims:
• Rows of beads represent the same set of positive integers before and after dropping down.
• After dropping, each row has beads less than (or equal to) that on the row directly below it.

2 rows (k = 2)

the smallest amongst k+1 rows has already emerged on top

k+1th row

k rows

the smallest amongst k rows

Using a digital circuit

flip-flops

cn

cn

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

1

1

1

1

1

1

0

Data entry register

c2

c2

0

0

0

Input from corresponding cell in

data entry register

1

1

c1

c1

0

0

1

1

1

cit

Cit+1

0

1

1

ci-1

1

1

1

1

1

1

Parallel implementation

Using an analog circuit

1/2 A

1/3 A

1/6 A

sorted data

Trim

Trim

Trim

v1

1 V

1 

1

1

0.5 V

0.3 V

0.2 V

3 2 1

Trim

Trim

Trim

2

2

v2

2 V

V1

V2

V3

2 

1 V

0.7 V

0.3 V

Trim

Trim

Trim

v3

3 V

3

3

3 

1.5 V

1 V

0.5 V

‘Trim’ Voltage :

Trim( v ) =

1 if v >= 0.5

0 otherwise

1 1 1 (no. 3)

1 0 0 (no. 1)

1 1 0 (no.2)

Calculating current

Resistor chain 1:

I1 = V1/R = 3/(1+2+3) = 1/2 A

Resistor chain 2:

I2 = V2/R = 2/(1+2+3) = 1/3 A

Resistor chain 3:

I3 = V3/R = 1/(1+2+3) = 1/6 A

1 1 0

2 1 0

3 2 1

1

1

0

DATA ENTRY

(strings of 1’s similar to balls)

Increase voltage by 1 unit every time a ‘1’ is sent

Parallel simulation

Using a cellular automaton (CA)

0

0

0

0

0

0

1

1

1

1

0

0

1

0

0

1

1

0

initial configuration

{2,1,3}

final configuration

{1,2,3}

1

1

0

1

1

1

0

1

0

1

0

1

0

1

0

0

0

1

1

0

1

0

0

0

0

1

1

1

1

1

0

0

0

0

1

1

1

1

1

2

3

4

5

6

7

8

1

2

3

4

Pushing button-1 will make one bead to drop down, pushing button-2 will make two beads to drop down (in parallel), and so on.

The “tilt” operation

900

Beads rolled down along rod-1 will have the label “1”, those rolled down along rod-2 will have “2”, and so on.

1

1

2

1

2

3

1

2

3

4

only label ‘3’ is seen

labels stuck on the sides (of the beads)