○ Finiteness – Should terminate after a finite
DATA STRUCTURES AND ALGORITHMS number of steps.
○ Feasibility – Can be implemented with
● Data Structures: A way of organizing and storing available resources.
data efficiently. ○ Independence – Can be implemented in
● Algorithms: A set of instructions that define how different languages.
data is processed. 2. Algorithm Analysis:
● Importance: Helps improve efficiency, manage ○ A Priori Analysis – Theoretical efficiency
large datasets, and optimize system performance. (before execution).
○ A Posteriori Analysis – Practical efficiency
DATA STRUCTURE CONCEPTS (after execution).
3. Algorithm Complexity:
1. Foundation Terms: ○ Time Complexity – Measures how execution
○ Interface – Defines available operations in a time scales with input size.
data structure. ○ Space Complexity – Measures memory
○ Implementation – Provides the actual requirements of an algorithm.
structure and algorithms used.
○ Characteristics – Includes correctness, time FUNCTIONS IN PROGRAMMING
complexity, and space complexity.
2. Need for Data Structures: 1. Defining a Function
○ Efficient searching – Faster lookups in large ○ A function is a block of reusable code that
datasets. performs a specific task.
○ Processor speed limitations – Managing 2. Function Declaration
billion-record data efficiently. ○ Specifies function name, return type, and
○ Handling multiple requests – Optimizing parameter list.
performance under high user load. 3. Function Call
○ Invokes the function to execute its code.
EXECUTION TIME COMPLEXITY 4. Function Parameters
○ Parameters – Variables listed in function
● Best Case: The fastest possible execution declaration.
scenario. ○ Arguments – Actual values passed when
● Average Case: The expected execution time for calling the function.
most inputs. ○ Pass by Reference – Allows modifying the
● Worst Case: The slowest possible execution original variable.
scenario. 5. Return Values
○ A function can return a value using the
ALGORITHM BASICS return keyword.
1. Algorithm Characteristics:
○ Unambiguous – Clear and precise steps.
○ Input & Output – Should accept inputs and
produce outputs.
ARRAY
○ Two-Dimensional Arrays – Grid-like
1. What is an Array?
structure.
○ A fixed-size collection of elements of
○ Multi-Dimensional Arrays – Extends
the same type stored in contiguous
beyond 2D (e.g., 3D arrays).
memory.
2. Why Use Arrays?
STRINGS
○ Helps manage large collections of
data efficiently.
1. String Representation in C++
3. Array Operations:
○ Can be represented as character
○ Traverse – Access each element one
arrays or objects.
by one.
2. Basic String Operations
○ Insertion – Add an element at a
○ String Length – Determines the
specific index.
number of characters in a string.
○ Deletion – Remove an element from a
○ Concatenation – Combines multiple
specific index.
strings.
○ Search – Locate an element by value
○ Comparison – Checks if strings are
or index.
equal.
○ Update – Modify an element at a
specific index.
4. Array Dimensionality:
○ One-Dimensional Arrays – Linear
storage structure.