Data Structure using in C++ 4th unit
DS USING IN C ++ 📘 UNIT – IV: Searching, Sorting & Heaps -🇩🇦🇹🇦 -- https://sites.super.myninja.ai/ff8bd05b-902a-4f34-a35f-b1a676681394/425664e6/unit1/fundamental-concepts.html 🔍 1. Searching a. Linear Search Check each element one by one. Time complexity: O(n) int linearSearch(int arr[], int n, int key) { for(int i = 0; i < n; i++) { if(arr[i] == key) return i; } return -1; } b. Binary Search Requires sorted array. Divide and conquer approach. Time complexity: O(log n) int binarySearch(int arr[], int left, int right, int key) { while(left <= right) { int mid = (left + right)/2; if(arr[mid] == key) return mid; else if(arr[mid] < key) left = mid + 1; else right = mid - 1; } return -1; } 🖼️ Binary Search Visual --- 🔃 2. Sorting Algorithms a...