DSA Unit-1 (1st)
DSA Unit-1 (1st)
UNIT - I
Introduction to Data Structures
CO5 : Differentiate between various types of data structures
UNIT I: CONTENT
Introduction to Data Structures:
• Algorithms and Flowcharts, Basics Analysis on Algorithm, Complexity of Algorithm, Introduction and
Definition of Data Structure, Classification of Data, Arrays, Various types of Data Structure, Static and
Dynamic Memory Allocation, Function, Recursion. [CO5]
• Introduction to Arrays, Definition, One Dimensional Array and MultiDimensional Arrays, Pointer,
Pointer to Structure, various Programs for Array and Pointer. Strings. Introduction to Strings,
Definition, Library Functions of Strings. [CO1]
Introduction to Data Structures: Algorithms and Flowcharts
• Algorithm: A step-by-step procedure or formula for solving a problem.
• Importance: Fundamental to programming and problem-solving in computer
science.
• Way to arrange data in main memory (RAM) for efficient usage
• Arrays, linked list, queues, stacks etc
• Example: Algorithm for finding the largest number in a list.
• Examples:
• O(1): Constant time
• O(n): Linear time
• O(n2): Quadratic time
Complexity
Introduction to Data Structures: Introduction and Definition of Data Structure
• A data structure is a storage that is used to store and organize data. It is a way of
arranging data on a computer so that it can be accessed and updated efficiently.
• Types:
Examples:
• malloc(): Allocates memory.
• calloc(): Allocates and initializes memory.
• realloc(): Reallocates memory.
• free(): Deallocates memory.
Introduction to Data Structures: Function
• A block of code that performs a specific task.
• Helps in modular programming.
Types:
• Built-in Functions: Predefined in libraries.
• User-Defined Functions: Defined by the programmer.
Properties
• Ability to solve a problem by breaking it down into smaller sub-problems
• Must have a base case or stopping criteria
• Calling the same function within itself, which leads to a call stack.
• Less efficient than iterative solutions in terms of memory and performance.