Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Therefore, even those who have studied algorithms do not know how to
design algorithms; because mathematics and programs are too
complicated. It is more complicated to want to map real problems to
math problems.
The computer will only process numbers (binary digits). Every word,
every color, every kind of sound in the computer has a corresponding
number.
By the same token, text, color, pictures, images, and sounds that appear
on the screen of a computer can all be converted into
numbers. Everything is a number in the computer.
To solve real problems with a computer, there are usually two aspects to
consider: First, what devices should the computer be connected to? How
to control these devices with a computer? Second, how do real problems
correspond to mathematical problems? How to design an algorithm?
For example, we want to turn "people" on the screen into italics. The
process is roughly like this - first, take the figures of "people" (0,1),
(1,2), (2,3), ... out; then, the higher the coordinates, Just move a little
more to the right, so that it becomes italic. To move the coordinates to
the right, let the computer do the digital addition calculation and then
store the addition results.
For another example, use the mouse to select a folder and the color of
the folder will be reversed. The process is roughly like this - first, after
the computer detects the coordinates of the mouse click, convert the
coordinates into numbers; then, take the information on the screen and
see the coordinates of each thing on the screen. One matches the
coordinates of the mouse; 噢, it turns out to be a picture of a folder, and
the color of the folder is reversed.
The calculation speed of the computer can be said to be very fast, and it
can be performed tens of millions of times in one second. Even if there
are so many words, how big the picture is, the computer handles it, it is
easy and freehand, and it is very smooth.
Open any file on your computer, scroll the file with your mouse, and
your eyes are still empty. The correct picture will appear on the screen
immediately. In fact, when the volume is animated, the computer has
been calculated tens of millions of times, and only a very short time is
used, and all the data that should be presented on the screen is
calculated.
A l go r i thm
Inputs and outputs are a bunch of numbers. The practical thing is to put
these numbers in the data structure , such as array, list. The input
source, usually the file stored in the hard disk, or the number captured
by the hardware device, such as a digital camera, a microphone, and the
like. The output is usually located in a file stored on the hard disk, or is
converted by a hardware device and then displayed in other types, such
as a digital television, a digital audio, and the like.
The ancients defined the algorithm, which stipulated that the number of
calculation steps must be a finite step, not an infinite step. In the
terminology of programming languages: algorithms cannot have infinite
loops.
Most of the time, we can't fully understand algorithms from virtual code
and flow charts, just as we can't fully understand mathematical concepts
from mathematical formulas. If you want to understand the algorithm,
you usually have to use the auxiliary explanation of the text and the
picture.
To judge the quality of an algorithm, the most basic indicators are time
and space.
The most intuitive way is to measure the execution time of the program
and the memory usage of the program. However, because the execution
time of the same algorithm varies from computer to computer, and
because the programming language and programming skills used by
each person's algorithm are different, the execution time and memory
usage are not a stable criterion. .
Once you have the number of steps, you can further estimate the
execution time. Suppose a step requires 10 clocks, and the CPU of the
CPU is 2GHz: 2000000 clocks per second, then the program execution
time is about 12.2425 seconds.
But this is not the exact number of steps. Due to the actual relationship,
the coefficients are easy to change, so the coefficient is of little
significance. So the mathematician only takes the highest power of the
algebraic expression and specifies that n must be large enough (similar
to the infinite calculus approach). Although this is a very inaccurate way
of estimating, it is still possible to easily classify common algorithms and
roughly compare them.
| time* | space
---------------+-------------+--------
Bubble sort | O(n2) | O(n)
Insertion sort | O(n2) | O(n)
Merge sort | O(n log(n)) | O(n)
Quicksort | O(n2) | O(n)
Heapsort | O(n log(n)) | O(n)
Counting sort | O(n+r) | O(n+r)
*worst case
Problem solving
Math problems, usually can be clearly answered, for example, the bigger
the number, the better. Usually in this case, there are multiple
algorithms that can get a positive solution, so the performance of these
algorithms is just as good.
A l go r i thm
Learning algorithm
Learning algorithms have two levels: first, the operation process of the
algorithm itself; second, the idea is converted into an algorithm.
Algorithm book
Algorithms
Robert Sedgewick and Kevin Wayne
Introduction to Algorithms
Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein
Algorithm Design
Jon Kleinberg and Éva Tardos
Encyclopedia of Algorithms
Editors: Kao, Ming-Yang
Algorithm storybook
Out of their Minds: The Lives and Discoveries of 15 Great Computer Scientists
Fan: "The new future of brave information: the hero behind the creation of
information technology"
Jane: "Thinking: 15 computer geniuses and their major discoveries"
Nine Algorithms That Changed the Future: The Ingenious Ideas That Drive Today's
Computers
Fan: "The nine algorithms that change the world: the strongest concept that makes
today's computers omnipotent"
Jane: "Nine Algorithms for Changing the Future"
Algorithm course
Adam Blank
There are many course notes on the algorithm course website.
Jeff Erickson
There are many course notes on the algorithm course website.
Erik Demaine
There are many special topics on the algorithm course website.
Algorithm website
GeeksforGeeks
Programming language, math, algorithm puzzle problem.
Algorithms Notes
Algorithmic puzzle problem.
Rosetta Code
The implementation code for a wide variety of problems.
LeetCode
The interview question bank is mainly an algorithmic puzzle topic. You can practice
solving problems online.
Math website
AMS Open Math Notes
The mathematician's teaching notes.