Math algorithms
Newton Raphson Algorithm to Calculate the Square root
- Read a number from the input list, and let x be the name of a memory cell whose initial value is this number.
- Write the value in memory cell x. This is called the output.
- If the value in x is less than zero, execute instruction 11. Otherwise continue to instruction 4.
- Let s be the name of a memory cell whose initial value is 1.
- Let i be the name of a memory cell whose initial value is 3.
- Calculate the value of (s+(x/s))/2. Let t be the name of a memory cell whose value is the calculated quantity; that is, set t equal to the value of (x+(x/s))/2.
- Assign the value in to to memory cell s. That is, set s equal to the value in t and forget the old value associated with s.
- Decrease the value in memory cell i by 1.
- If the value in i is positive, execute instruction 6. Otherwise, continue to instruction 10.
- Write the value in s on the output answer sheet.
- Stop; you have finished.
graph TD
A[Start] --> B[Read input x]
B --> C[Output x]
C --> D{x < 0?}
D -->|Yes| K[Stop]
D -->|No| E[s = 1, i = 3]
E --> G[t = s + x/s / 2]
G --> H[s = t]
H --> I[i = i - 1]
I --> J{i > 0?}
J -->|Yes| G
J -->|No| L[Output s]
L --> K
Código:
- C++ bubblesort_arreglos.cpp // Usando arreglos estáticos
- C++ bubblesort_vectores.cpp // Usando vectores
- C bubblesort.c
- Python bubblesort.py
- Racket bubblesort.rkt
Código:
- C++ selectionsort_arreglos.cpp // Usando arreglos estáticos
- C++ selectionsort_vectores.cpp // Usando vectores
- C selectionsort.c
- Python selectionsort.py
- Racket selectionsort.rkt
Código:
- C++ insertionsort_arreglos.cpp // Usando arreglos estáticos
- C++ insertionsort_vectores.cpp // Usando vectores
- C insertionsort.c
- Python insertionsort.py
- Racket insertionsort.rkt
Código:
- C++ heapsort_arreglos.cpp // Usando arreglos estáticos
- C++ heapsort_vectores.cpp // Usando vectores
- C heapsort.c
- Python heapsort.py
- Racket heapsort.rkt
Código:
- C++ countingsort.cpp
- C countingsort.c
- Python countingsort.py
- Racket countingsort.rkt
Código:
- C++ radixsort.cpp
- C radixsort.c
- Python radixsort.py
- Racket radixsort.rkt
Código:
- C++ mergesort.cpp
- C mergesort.c
- Python mergesort.py
- Racket mergesort.rkt
Código:
- C++ quicksort.cpp
- C quicksort.c
- Python quicksort.py
- Racket quicksort.rkt