1 / 15

Department of Computer Engineering Faculty of Engineering Prince of Songkla University

Department of Computer Engineering Faculty of Engineering Prince of Songkla University. 240-222 Computer Programming Techniques Slide Presentation by Pichaya Tandayya Taught by Pichaya Tandayya. 240-204 Computer Programming Techniques Semester 1, 2004. 19. Misc. Objectives of these slides:

reuben
Télécharger la présentation

Department of Computer Engineering Faculty of Engineering Prince of Songkla University

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Department of Computer EngineeringFaculty of EngineeringPrince of Songkla University 240-222 Computer Programming Techniques Slide Presentation by Pichaya Tandayya Taught by Pichaya Tandayya

  2. 240-204 Computer Programming TechniquesSemester 1, 2004 19. Misc Objectives of these slides: to introduce Hashing, Merge Sort, and Backtracking

  3. Overview 1. Hashing 2. Merging 3. Backtracking

  4. 1. Hashing • Hashing is the transformation of data into a usually shorter fixed-length value or key that represents the original data. • Hashing is used to index and retrieve items in a database because it is faster to find the item using the shorter hashed key than to find it using the original value. • It is also used in many encryption algorithms.

  5. As a simple example of the using of hashing in databases, a group of people could be arranged in a database like this: Abernathy, Sara Epperdingle, Roscoe Moore, Wilfred Smith, David (and many more sorted into alphabetical order)

  6. But if each of the names were hashed, it might be possible to generate a unique four-digit key for each name. For example: 7864 Abernathy, Sara 9802 Epperdingle, Roscoe 1990 Moore, Wilfred 8822 Smith, David (and so forth)

  7. The hashing algorithm is called the hash function. • hashing is also used to encrypt and decrypt digital signatures. • The digital signature is transformed with the hash function and then both the hashed value (known as a message-digest) and the signature are sent in separate transmissions to the receiver.

  8. The hash function is used to index the original value or key and then used later each time the data associated with the value or key is to be retrieved. • Thus, hashing is always a one-way operation. • There's no need to "reverse engineer" the hash function by analyzing the hashed values.

  9. Collision • In fact, the ideal hash function can't be derived by such analysis. • A good hash function also should not produce the same hash value from two different inputs. • If it does, this is known as a collision. • A hash function that offers an extremely low risk of collision may be considered acceptable.

  10. Simple Hash Functions • The division-remainder method: The remainder is the hashed value. (liable to produce a number of collisions) • Folding: This method divides the original value (digits in this case) into several parts, adds the parts together, and then uses the last four digits as the hashed value or key.

  11. Radix transformation: Where the value or key is digital, the number base (or radix) can be changed resulting in a different sequence of digits. (For example, a decimal numbered key could be transformed into a hexadecimal numbered key.) High-order digits could be discarded to fit a hash value of uniform length. • Digit rearrangement: This is simply taking part of the original value or key such as digits in positions 3 through 6, reversing their order, and then using that sequence of digits as the hash value or key.

  12. 2. Merging • External sorting • Algorithm for large data • Divide data into 2 or more groups • Sort each group and merge them together

  13. 3. Backtracking • An algorithmic technique to find solutions by trying one of several choices. • If the choice proves incorrect, computation backtracks or restarts at the point of choice and tries another choice. • It is often convenient to maintain choice points and alternate choices using recursion.

  14. Non-Deterministic Programming • Chronological Backtracking • Dependency-Directed backtracking • Acrotic Example

  15. Queen Problems http://students.ceid.upatras.gr/~papagel/project/kef5_8.htm

More Related