Some algorithm ideas of big data processing in. net

Source: Internet
Author: User
In. NET development, encryption and decryption are sometimes used to process the knowledge content of some edge disciplines, such as statistics, finance, and astronomy.Algorithm
It involves the calculation of large numbers, that is, the maximum number of overflow values stored in. net. One of my ideas is to use the numeric type During computation.
If the storage (temporary) and output are strings, then the storage requires box [N] n arrays to temporarily store the results of a small step in calculation,
'Example:
=================================== Algorithm understanding diagram ==================== ==========
'97*97*97*97*97 = 8587340257 box (1) = 587340257 box (2) = 8
'97*97*97*97*97*97 = 832972004929 box (1) = 972004929 box (2) = 832
'97*97*97*97*97*97*97 = 80798284478113 box (1) = 284478113 box (2) = 80798
'97*97*97*97*97*97*97*97 = 7837433594376961 box (1) = 594376961 box (2) = 7837433
'97 ^ 9 = 760231058654565217 box (1) = 654565217 box (2) = 760231058
'97 ^ 10 = 73742412689492826049 box (1) = 492826049 box (2) = 742412689 box (3) = 73
...... ...... ...... ......
Note that the higher the box subscript, the higher the corresponding number. Remember to use the above Algorithm
1. Define the number of bits in a box first, for example, 9 bits (based on requirements and actual conditions ),
② Due to computing habits, many people calculate the number of {box (0-> n)} bits from the base bits) the number of incoming bits (for example, the first calculated box (1) generates an incoming bits to box (2) = 0, and 8 boxes (2) + the number of incoming bits = 8) for processing.
③ It is best to calculate from the high level, you will save a lot of trouble, the number of boxes is unknown, it does not matter, with dynamic array, when full (maximum subscript box generated into the number of digits) then add
In addition, if the modulus is not large during the modulo operation, you can also use the above idea to perform the modulo in segments, and then link the box to get the temporary result and re-allocate the box (the box must be removed from the high position) for example, if the module 123456789123456789 is used to set eight bits and one box (1) = 89 box (2) = 91234567 box (3) = 12345678, each box is modulo and then combined. (Traditional is 123456789123456789 running 333 = 370741108478849 mode is 72) So the re-allocated box should be box (1) = 478849 box (2) = 370741180 instead of box (1) = 370741180 box (2) = 478849 why? The modulo operation starts from the high position. If the modulo operation of box (n) remains unchanged after the modulo operation, the result of the modulo operation is not changed to box (n) = Box (n) Program Will enter the endless loop
Another case involving the big number operation is to take the modulo after the N power of a (a ^ n mod v) if the MOD number is not big (it ends after n) (a mod v) * A mod V ...... This algorithm does not have to be implemented using recursion. It can be a simple loop, with a maximum of two layers of nested loops.
Last piece of advice: When performing addition, subtraction, multiplication, and Division on a large number, do not easily perform (addition, subtraction, multiplication, and Division) Factorization of the number. This algorithm is very efficient.
( Article Writing is in a hurry and there may be mistakes. Please forgive me)
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.