Showing posts with label dancing numbers. Show all posts
Showing posts with label dancing numbers. Show all posts

Wednesday, May 11, 2016

Dancing numbers: (Math Circus)

Dancing numbers: Numbers Circus: Modulo choreography.
( And:  Circus for to tame numbers, too )

After the post dedicated to dancing sort algorithms,  I think it's time to show a program made and published in 2004, which it could be useful in teaching elementary mathematics.


Is the "Dancing numbers

Originally made for MathCats.com , it never has been published. Finally I posted it on my page so do not be missed for the moment.

The program allows you to manipulate a lot of integers (up to 2000) with some simple rules: decide the number of columns that are to line up neatly from lowest to highest.
(Also possible to arrange smaller amounts of numbers)

The program allows for reflection on the divisibility of numbers and remainders:

It is also advisable to use the mode 9 columns, that shows the rule of divisibility for 9.
(The sum of all members of any number equals the heading number of the column)

And all the rules explained in https://en.wikipedia.org/wiki/Modular_arithmetic
(related to addition, subtraction, multiplication and division (sometimes), and congruence).

Here is a sample of how the program works:




You can use the application here: http://www.nummolt.com/obbl/dancingnumbers/modular_xtd_01.html

I hope its use will be useful to teach elementary mathematics.

Saturday, October 31, 2015

Dancing Sort Algorithms

Post, only to illustrate the most common types of sorting algorithms:
Graphically, Dance, and Code:

(Graphic from http://www.sorting-algorithms.com/ )
(Videos from: https://www.youtube.com/user/AlgoRythmics )
(Pseudocode: http://visualgo.net/ )
(Pseudocode Shell: https://courses.cs.washington.edu/courses/cse326/03wi/lectures/RaoLect14.pdf )
(Main Links (titles): Wikipedia: https://en.wikipedia.org/wiki/Sorting_algorithm

Sorting Algorithms general animated image:
(Algorithms race)



1.-  Insert:

mark first element as sorted
for each unsorted element
  'extract' the element
  for i = lastSortedIndex to 0
    if currentSortedElement > extractedElement
      move sorted element to the right by 1
    else: insert extracted element



2.- Select:

repeat (numOfElements - 1) times
  set the first unsorted element as the minimum
  for each of the unsorted elements
    if element < currentMinimum
      set element as new minimum
  swap minimum with first unsorted position



3.- Bubble:

do
  swapped = false
  for i = 1 to indexOfLastUnsortedElement
    if leftElement > rightElement
      swap(leftElement, rightElement)
      swapped = true
while swapped


4.- Shell:

                                # Start with the largest gap and work down to a gap of 1
                                     foreach (gap in gaps){
                                # Do a gapped insertion sort for this gap size.
                                                     # The first gap elements a[0..gap-1] are already in gapped order
                                                     # keep adding one more element until the entire array is gap sorted  
                                     for (i = gap; i < n; i += 1){
                                            temp = a[i]
                                            for (j = i; j >= gap and a[j - gap] > temp; j -= gap){
                                                  a[j] = a[j - gap]
                                            }
                                            a[j] = temp
                                      }
                                }


5.- Merge:

split each element into partitions of size 1
recursively merge adjancent partitions
  for i = leftPartStartIndex to rightPartLastIndex inclusive
    if leftPartHeadValue <= rightPartHeadValue
      copy leftPartHeadValue
    else: copy rightPartHeadValue
copy elements back to original array


7.- Quick:

for each (unsorted) partition
  set first element as pivot
  storeIndex = pivotIndex + 1
  for i = pivotIndex + 1 to rightmostIndex
    if element[i] < element[pivot]
      swap(i, storeIndex); storeIndex++
  swap(pivot, storeIndex - 1)