0% found this document useful (0 votes)
16 views3 pages

DSA I Detailed Notes English Corrected

The document provides detailed notes on Data Structures and Algorithms, covering definitions, types, and operations of various data structures such as arrays, stacks, queues, and linked lists. It also discusses searching and sorting algorithms, recursion, and complexity analysis using Big-O notation. Key concepts include the advantages and disadvantages of each data structure and algorithm, as well as their applications.

Uploaded by

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

DSA I Detailed Notes English Corrected

The document provides detailed notes on Data Structures and Algorithms, covering definitions, types, and operations of various data structures such as arrays, stacks, queues, and linked lists. It also discusses searching and sorting algorithms, recursion, and complexity analysis using Big-O notation. Key concepts include the advantages and disadvantages of each data structure and algorithm, as well as their applications.

Uploaded by

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

Data Structures and Algorithms - I (Detailed Notes in English)

1. Introduction to Data Structures

Definition:
A Data Structure is a way of organizing and storing data so that it can be accessed and modified efficiently.

Types of Data Structures:


Linear Data Structures: Data is stored sequentially.
Examples: Array, Linked List, Stack, Queue
Non-Linear Data Structures: Data is stored hierarchically or as a network.
Examples: Tree, Graph

2. Arrays

Definition:
An array is a collection of elements of the same data type stored at contiguous memory locations.

Operations:
Insertion, Deletion, Traversal, Searching, Sorting

Advantages:
Fast access using index
Easy to implement

Disadvantages:
Fixed size
Insertion/Deletion is costly (requires shifting)

3. Stacks

Definition:
A Stack is a Linear Data Structure that follows the LIFO (Last In, First Out) principle.

Real-Life Example:
A stack of plates - the last plate placed is the first one removed.

Operations:
Push, Pop, Peek/Top, isEmpty

Applications:
Expression evaluation, Syntax parsing, Undo mechanisms

4. Queues

Definition:
A Queue is a Linear Data Structure that follows the FIFO (First In, First Out) principle.

Real-Life Example:
Data Structures and Algorithms - I (Detailed Notes in English)

A queue of people at a bus stop - the first person to arrive is the first to be served.

Types of Queues:
Simple Queue, Circular Queue, Priority Queue, Double-Ended Queue (Deque)

Operations:
Enqueue, Dequeue

Applications:
CPU Scheduling, Print Spooling, Handling requests to a shared resource

5. Linked Lists

Definition:
A Linked List is a Linear Data Structure consisting of nodes, where each node contains data and a pointer to the next
node.

Structure of a Node:
struct Node {
int data;
Node* next;
};

Types:
Singly Linked List, Doubly Linked List, Circular Linked List

Advantages:
Dynamic size, Easy insertion and deletion

Disadvantages:
Sequential access only (no direct access)

6. Searching Algorithms

Linear Search:
Checks each element sequentially.
Time Complexity: O(n)

Binary Search:
Works only on sorted arrays.
Divides the array based on the mid-point.
Time Complexity: O(log n)

Binary Search Steps:


1. Find mid = (low + high)/2
2. Compare key with mid element
Data Structures and Algorithms - I (Detailed Notes in English)

3. Move to left or right half based on comparison

7. Sorting Algorithms

Bubble Sort:
Compares adjacent elements and swaps them if needed until the list is sorted.

Algorithm:
1. Start from the 0th index.
2. Compare current element with the next.
3. Swap if required.
4. Repeat for all elements.

Time Complexity:
Best case: O(n) (already sorted)
Average/Worst case: O(n²)

Other Sorting Techniques:


Selection Sort, Insertion Sort, Merge Sort, Quick Sort

8. Recursion

Definition:
Recursion is when a function calls itself.

Example:
Factorial function:
factorial(n) = n * factorial(n-1)
Base Case: factorial(0) = 1

Important Points:
- Every recursion must have a base case to terminate.
- Recursion internally uses the stack data structure.

9. Complexity Analysis

Time Complexity:
Measures the execution time based on input size.

Big-O Notation (Worst Case):


O(1): Constant time
O(log n): Logarithmic time
O(n): Linear time
O(n log n): Log-linear time
O(n²): Quadratic time

You might also like