0% found this document useful (0 votes)
4 views

DSA Assignment 2

The document defines a hash function as a method that converts an input into a fixed-size string of bytes, known as a hash value. It highlights the significance of hash functions in data retrieval, data integrity, and cryptography, emphasizing their role in enhancing efficiency and security in computer science. Additionally, it mentions the potential issue of collisions where different inputs may yield the same hash value.

Uploaded by

graphicsra41
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

DSA Assignment 2

The document defines a hash function as a method that converts an input into a fixed-size string of bytes, known as a hash value. It highlights the significance of hash functions in data retrieval, data integrity, and cryptography, emphasizing their role in enhancing efficiency and security in computer science. Additionally, it mentions the potential issue of collisions where different inputs may yield the same hash value.

Uploaded by

graphicsra41
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

ASSIGNMENT 02

COURSE NAME
Data Structures (CS-203)
SEMESTER
3rd Fall 2024
SUBMMITED BY

ROSHAN AKMAL
(23014119-103)
DEPARTMENT
COMPUTER SCIENCE

SECTION
B (EVE)

SUBMMITED TO
SIR TASADDAQ LATIF
Q1. What is a hash function? Define it and discuss its significance in the field of
computer science.

Answer:

A hash function is a function that takes an input (or "message") and returns a fixed-size
string of bytes. The output is known as the hash value or hash code. Hash functions are
widely used in computer science for data retrieval, data integrity, and cryptography.

Significance in Computer Science:

1. Data Retrieval: Hash functions are crucial in data structures like hash tables,
where they are used to quickly locate a data record given its key. The hash function
transforms the key into an index in an array, enabling constant time complexity
(O(1)) for search, insert, and delete operations.
2. Data Integrity: Hash functions help ensure data integrity by generating a unique
hash for a given piece of data. If the data changes, even slightly, the hash will
change significantly, making it easy to detect any alterations or errors in the data.
3. Cryptography: In cryptographic applications, hash functions are used in algorithms
like digital signatures, password storage, and blockchain technology. They provide
secure ways to verify data without revealing the original data.
4. Collisions: While hash functions are designed to produce unique outputs for
different inputs, collisions can occur when two different inputs produce the same
hash value. This is generally rare and is a key consideration in designing strong hash
functions.

You might also like