0% found this document useful (0 votes)
8 views17 pages

DSA Unit-1 (1st)

The document provides an overview of data structures, including their definitions, classifications, and types such as arrays, linked lists, stacks, queues, trees, and graphs. It discusses algorithm analysis, complexity, memory allocation, functions, and recursion, highlighting their importance in programming and problem-solving. Key concepts like static vs dynamic memory allocation and the differences between primitive and non-primitive data types are also covered.

Uploaded by

niktannu12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views17 pages

DSA Unit-1 (1st)

The document provides an overview of data structures, including their definitions, classifications, and types such as arrays, linked lists, stacks, queues, trees, and graphs. It discusses algorithm analysis, complexity, memory allocation, functions, and recursion, highlighting their importance in programming and problem-solving. Key concepts like static vs dynamic memory allocation and the differences between primitive and non-primitive data types are also covered.

Uploaded by

niktannu12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

DATA STRUCTURES

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]

Arrays, Pointers and Strings:

• 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.

• Flowchart: A visual representation of an algorithm using symbols.


• Importance: Helps in understanding the flow of the process.
• Basic Symbols:
• Oval: Start/End
• Rectangle: Process
• Diamond: Decision
• Parallelogram: Input/Output
• Example: Flowchart for the same algorithm (finding the largest number in a list).
Introduction to Data Structures: Basics Analysis on Algorithm
• What is Algorithm Analysis?

• The process of determining the computational


complexity of algorithms.

• Importance: Helps in choosing the most efficient


algorithm for a task.
• Types of Analysis:

 Worst-case: The maximum time taken. (O) Big O


 Best-case: The minimum time taken. ((Ω) Omega
 Average-case: The expected time take (Θ) Big
Theta
Introduction to Data Structures: Complexity of Algorithm
• Complexity: Measure of the amount of time and/or space required by an algorithm.
• Types of Complexity:

• Time Complexity: The time taken by an algorithm to run.


• Space Complexity: The memory space required by an algorithm.

• Big O Notation: A mathematical notation to describe the upper bound of an algorithm's


complexity.

• 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.

• A data structure is not only used for organizing the data.


• It is also used for processing, retrieving, and storing data.

• Types:

• Primitive: Basic data types like int, char, float, etc.


• Non-Primitive: More complex data types like arrays, lists, trees, etc.
Type of DS
Introduction to Data Structures: Various types of Data Structure
Linear Data Structures:
• Arrays: Explained above.
• Linked Lists: Elements linked using pointers.
• Stacks: Operates on LIFO principle.
• Queues: Operates on FIFO principle.

Non-Linear Data Structures:


• Trees: Hierarchical structure with root, branches, and leaves.
• Graphs: Set of nodes connected by edges.

• Comparison: Differences in structure, usage, and application scenarios.


Introduction to Data Structures: Classification of Data
• Primitive Data Types: structure.
• Integer: Whole numbers • Queues: FIFO (First In First Out) data
structure.
• Float: Numbers with decimals
• Trees: Hierarchical data structure.
• Character: Single characters
• Graphs: Set of nodes connected by
• Boolean: True/False values edges.

• Non-Primitive Data Types: Examples and Use Cases: Applications



of each data type in real-world
• Arrays: A collection of elements of the scenarios.
same type.
• Lists: Ordered collection of elements.
• Stacks: LIFO (Last In First Out) data
Primitive and non-primitive
Introduction to Data Structures: Arrays
• A collection of homogeneous elements identified by index or key.
• Elements are of the same type.
Types of Arrays:
• One-Dimensional: A single row of elements.
• Multi-Dimensional: Arrays of arrays (e.g., matrices).
Operations on Arrays:
• Insertion: Adding elements.
• Deletion: Removing elements.
• Traversal: Accessing each element sequentially.
• Examples and Applications: Sorting, searching, and matrix operations.
Introduction to Data Structures: Static and Dynamic Memory Allocation
Static Memory Allocation: Memory size is fixed at compile time.
• Advantages: Fast access.
• Disadvantages: Inefficient use of memory.

Dynamic Memory Allocation: Memory size can be changed at runtime.


• Advantages: Efficient use of memory.
• Disadvantages: Slower access.

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.

• Function Declaration and Definition: Syntax and examples.


• Examples and Applications: Reusability and ease of debugging.
Introduction to Data Structures: Recursion
• Recursion is defined as a process which calls itself directly or indirectly and the corresponding
function is called a recursive function.

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.

• Base Case and Recursive Case: Necessary conditions for recursion.


• Advantages: Simplifies code for complex problems.
• Disadvantages: Higher memory usage.
• Examples:
• Factorial Calculation: n!=n×(n−1)!
• Fibonacci Series: F(n)=F(n−1)+F(n−2)

You might also like