Data Structures Fundamentals
1. Representation of Information
Meaning: How computers store, process, and communicate different types of data.
- Bit Level: Smallest unit (0 or 1).
- Byte/Word Level: Group of bits, usually 8 bits = 1 byte.
- Numbers: Integers and real numbers. Example: Decimal 25 → Binary 11001.
- Floating-point: Stored as mantissa and exponent.
- Characters: Encoded with ASCII/Unicode. Example: ‘A’ → ASCII 65 → Binary 01000001.
- Multimedia: Images = pixels; Audio/Video = sampling + compression.
Key Point: All forms of data (text, numbers, images, sound) are ultimately represented in binary (0s and 1s).
2. Characteristics of an Algorithm
Definition: A sequence of clear steps to solve a problem.
- Finiteness: Must terminate after finite steps.
- Clarity: Instructions must be precise.
- Input: Zero or more inputs allowed.
- Output: At least one result produced.
- Effectiveness: Steps must be practical.
- Generality: Should solve a broad set of problems.
Example: To add two numbers: 1) Input two numbers. 2) Add them. 3) Display the result.
3. Program
Definition: A program is the coded form of an algorithm written in a programming language.
Difference: Algorithm = logical plan (language independent). Program = actual implementation (C, Java, Python, etc.).
#include <stdio.h>
int main() {
int a, b, sum;
printf("Enter two numbers: ");
scanf("%d %d", &a, &b);
sum = a + b;
printf("Sum = %d", sum);
return 0;
}
4. Analyzing Programs
Definition: Examining a program for efficiency and correctness.
- Correctness: Always gives accurate results.
- Time Complexity: How fast it runs (Big-O notation).
- Space Complexity: Memory required.
- Readability: Is the code easy to maintain?
- Scalability: Handles large inputs efficiently.
Example: Linear Search → Time Complexity: O(n) | Space Complexity: O(1).
Summary
- Representation of Information → Data storage in binary.
- Algorithm → Logical steps to solve a problem.
- Program → Algorithm implemented in code.
- Program Analysis → Measures correctness and efficiency.
Data Structures Fundamentals
1. Representation of Information
Meaning: How computers store, process, and communicate different types of data.
- Bit Level: Smallest unit (0 or 1).
- Byte/Word Level: Group of bits, usually 8 bits = 1 byte.
- Numbers: Integers and real numbers. Example: Decimal 25 → Binary 11001.
- Floating-point: Stored as mantissa and exponent.
- Characters: Encoded with ASCII/Unicode. Example: ‘A’ → ASCII 65 → Binary 01000001.
- Multimedia: Images = pixels; Audio/Video = sampling + compression.
Key Point: All forms of data (text, numbers, images, sound) are ultimately represented in binary (0s and 1s).
2. Characteristics of an Algorithm
Definition: A sequence of clear steps to solve a problem.
- Finiteness: Must terminate after finite steps.
- Clarity: Instructions must be precise.
- Input: Zero or more inputs allowed.
- Output: At least one result produced.
- Effectiveness: Steps must be practical.
- Generality: Should solve a broad set of problems.
Example: To add two numbers: 1) Input two numbers. 2) Add them. 3) Display the result.
3. Program
Definition: A program is the coded form of an algorithm written in a programming language.
Difference: Algorithm = logical plan (language independent). Program = actual implementation (C, Java, Python, etc.).
#include <stdio.h>
int main() {
int a, b, sum;
printf("Enter two numbers: ");
scanf("%d %d", &a, &b);
sum = a + b;
printf("Sum = %d", sum);
return 0;
}
4. Analyzing Programs
Definition: Examining a program for efficiency and correctness.
- Correctness: Always gives accurate results.
- Time Complexity: How fast it runs (Big-O notation).
- Space Complexity: Memory required.
- Readability: Is the code easy to maintain?
- Scalability: Handles large inputs efficiently.
Example: Linear Search → Time Complexity: O(n) | Space Complexity: O(1).
Summary
- Representation of Information → Data storage in binary.
- Algorithm → Logical steps to solve a problem.
- Program → Algorithm implemented in code.
- Program Analysis → Measures correctness and efficiency.