slide1
Download
Skip this Video
Download Presentation
Bead-Sort - A natural algorithm for sorting

Loading in 2 Seconds...

play fullscreen
1 / 18

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


  • 168 Views
  • Uploaded on

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.

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

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


An Image/Link below is provided (as is) to download presentation

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
slide1

Bead-Sort

- A natural algorithm for sorting

slide3

Bead-Stack machine

The “tilt” operation

900

slide4

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

slide5

Bead-Sort: illustration 2

1

2

3

Sorting {2, 3, 1}

1. Drop 2 beads

(Remember, always from left-to-right)

2. Drop 3 beads

3. Drop 1 beads

slide6

Bead-Sort: illustration 3

1

2

3

Sorting {1, 3, 2}

1. Drop 1 bead

(Remember, always from left-to-right)

2. Drop 3 beads

3. Drop 2 beads

slide7

Bead-Sort: illustration 4

1

2

3

4

Sorting {1, 3, 2, 4}

1. Drop 1 bead

(Remember, always from left-to-right)

2. Drop 3 beads

3. Drop 2 beads

4. Drop 4 beads

slide8

Bead-Sort: illustration 5

2

2

3

4

Sorting {2, 4, 3, 2}

1. Drop 2 beads

(Remember, always from left-to-right)

2. Drop 4 beads

3. Drop 3 beads

4. Drop 2 beads

slide9

Simulating Bead-Sort with a program

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
  • beads in each level.
  • Finally, Level_Count will contain
  • sorted data.
slide10

Bead-Sort: Proof of correctness

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)

slide11

Bead-Sort: Proof of correctness

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

k+1th row

k rows

the smallest amongst k rows

slide12

Parallel implementation of Bead-Sort

Using a digital circuit

flip-flops

absence of bead - 0

presence of bead - 1

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

slide13

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

slide14

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

CA rules for Bead-Sort simulation

slide15

Bead-Stack machine

Loading the input (beads)

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.

slide16

Bead-Stack machine

The “tilt” operation

900

slide17

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)

Bead-Stack machine

Reading the output

slide18

Bead-Stack machine

Complexity of inputting, sorting and outputting a list

Inputting a list:Using the gadget that loads a row-of-beads, we need N (loading) operations to input a list of size N (into the frame of the Bead-Stack machine).

Sorting a list:We tilt the frame 90o (a single operation, from the Bead-Stack machine’s perspective). The time taken by the falling beads to settle down is sqrt(2h/g), where h is the height of the rods and g, the acceleration due to gravity. If we fix the height of rods to be the same as the size (N) of the list, then the time taken is given by sqrt(2N/g), i.e. O(sqrt(N)).

Outputting a list:Nothing needs to be done to explicitly output rows of beads; the user could (literally)read the output (row by row).

ad