0% found this document useful (0 votes)
3 views4 pages

Unit 1 2 3 Theory Ds

The document provides comprehensive notes on Data Structures and Algorithms, covering three units: Introduction to data types, recursion, and asymptotic notation; linked lists, stacks, queues, and hashing; and sorting and searching techniques along with heaps. Key concepts include types of data structures, operations on linked lists, various sorting algorithms, and searching methods. It also includes mnemonics and quick definitions for exam preparation.

Uploaded by

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

Unit 1 2 3 Theory Ds

The document provides comprehensive notes on Data Structures and Algorithms, covering three units: Introduction to data types, recursion, and asymptotic notation; linked lists, stacks, queues, and hashing; and sorting and searching techniques along with heaps. Key concepts include types of data structures, operations on linked lists, various sorting algorithms, and searching methods. It also includes mnemonics and quick definitions for exam preparation.

Uploaded by

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

📘 Data Structures & Algorithms (Units 1, 2, 3) – Complete Theory

Notes for Exam (40 Marks Theory Section)

✅ UNIT 1: Introduction, Recursion & Asymptotic Notation


🔹 Data Types
Data types define what kind of data a variable can hold. They are mainly 3
types: - Primitive Data Types: Inbuilt types like int, char, float. Jaise ki
int age = 18; - Derived Data Types: Jo dusre types se banaye jaate hain
jaise array, structure, pointer - Abstract Data Types (ADT): Jaise Stack,
Queue, Linked List jo logical view dete hain data ka
🔹 Classification of Data Structures
 Linear: Data ek ke baad ek arranged hota hai – Array, Linked List,
Stack, Queue
 Non-Linear: Data hierarchical hota hai – Tree, Graph
 Static: Memory pehle se fix hoti hai (e.g., Array)
 Dynamic: Runtime pe memory allocate hoti hai (e.g., Linked List)
🔹 Arrays & Storage
 1D Array: Ek simple list of elements – int a[5] = {1,2,3,4,5}
 2D Array: Matrix form mein – int b[3][3]
 Sparse Matrix: Aisi matrix jisme zyadatar elements zero hote hain.
Memory bachane ke liye compressed format mein store karte hain.
🔹 Notion of Algorithm
Algorithm ek step-by-step procedure hota hai problem solve karne ke liye.
Qualities: - Finite steps ho - Correct result de - Unambiguous instructions
ho
🔹 Asymptotic Notations
Yeh performance measure hai kisi algorithm ka jab input size badhta hai: -
Big O (O(n)): Worst case – kitna time lag sakta hai max - Omega (Ω(n)):
Best case – minimum time - Theta (Θ(n)): Average case
🔹 Recursion
Jab koi function khud ko call karta hai use recursion kehte hain.
➤ Types:
 Tail Recursion: Function call last line pe hota hai
 Head Recursion: Function call pehle hota hai
 Tree Recursion: Ek function multiple baar khud ko call karta hai
 Indirect Recursion: A -> B -> A call karte hain
➤ Applications:
 Factorial: n! = n * (n-1)!
 Fibonacci: f(n) = f(n-1) + f(n-2)
 Tower of Hanoi: Discs ko ek rod se dusri par shift karna recursively

✅ UNIT 2: Linked List, Stack, Queue, Hashing


🔹 Linked List
Linked List ek dynamic data structure hai jisme nodes hote hain: - Singly
Linked List: Har node mein data + next pointer - Doubly Linked List: Data
+ prev pointer + next pointer
➤ Operations:
 Insertion: Head, middle, end mein data daalna
 Deletion: Kisi specific node ya head/tail ko remove karna
 Traversal: Linked List ko start se end tak read karna
🔹 Stack
 Stack ek LIFO (Last In First Out) structure hai
 Push: Data daalna
 Pop: Data nikaalna
 Use array ya linked list se implement karte hain
🔹 Queue
 Queue ek FIFO (First In First Out) structure hai
 Enqueue: Data add karna
 Dequeue: Data remove karna
 Types: Normal Queue, Circular Queue, Deque
🔹 Polish Notation
 Infix: (A + B) – human readable
 Postfix: A B + – stack-friendly
 Prefix: + A B
🔹 Hashing
Hashing ek technique hai jisme data ko index ke form mein store karte hain -
Hash Table: Key → Index - Hash Function: Converts key into index
➤ Collision Handling:
 Chaining: Har index pe ek linked list
 Open Addressing: Agla index check karte hain (Linear, Quadratic
probing)
✅ UNIT 3: Sorting, Searching, Heap
🔹 Sorting Techniques
 Bubble Sort: Adjacent elements compare karte hain, agar galat order
hai toh swap karte hain
 Selection Sort: Minimum element dhundke usse front pe rakhte hain
 Insertion Sort: Ek element uthate hain aur correct position mein
insert karte hain
 Merge Sort: Array ko divide karte hain, fir sorted part merge karte
hain (Divide & Conquer)
 Quick Sort: Ek pivot choose karke left < pivot < right parts banate
hain
 Heap Sort: Array ko heap mein convert karte hain, fir root ko swap
karte hain
 Counting Sort: Elements ke frequency count karke position fix karte
hain
 Bucket Sort: Elements ko buckets mein daal kar sort karte hain
🔹 Searching Techniques
 Linear Search: One by one check karte hain – unsorted array ke liye
 Binary Search: Sorted array mein beech se divide karte hain aur
compare karte hain (O(log n))
🔹 Heap
 Binary Heap: Complete Binary Tree hota hai
 Max Heap: Har parent node ka value > child nodes
 Min Heap: Har parent node ka value < child nodes
➤ Heap Sort Steps:
1. Array ko max heap mein convert karo
2. Root ko last element se swap karo
3. Heapify remaining elements

🧠 Mnemonics:
 Bubble: Bubble up largest element
 Selection: Select smallest and fix
 Insertion: Insert in right position
 Merge: Merge sorted arrays
 Quick: Choose pivot and partition
 Heap: Parent node ka rule
 Binary Search: Divide array in half and search
🔑 Quick Definitions for Viva:
 Sparse Matrix: Jisme 90% ya zyada elements zero ho
 Head Recursion: Recursive call sabse pehle hota hai
 Hash Table: Keys ko index mein convert karke store karte hain
 LIFO/FIFO: Stack ke liye LIFO, Queue ke liye FIFO
 Heap Property: Parent node ka value child se bada (Max Heap)

Use this document for deep understanding, exam prep, and full marks
targeting. MCQs aur coding practicals bhi chahiye toh batao Priyam bhai 🔥

You might also like