📚🌃 Continuing my dive into data structures and algorithms. 🙂 🫧 🔁 🫧 Tonight’s focus: Chapter 22: Bubble Sort ❌ Bubble Sort is one of the simplest sorting algorithms, but also one of the most inefficient. It’s often taught not because it’s fast, but to help you recognize and avoid sluggish 🐌 sorting patterns in your own code. ⚙️ How Bubble Sort Works -Start at the beginning of the list. -Compare each pair of adjacent elements. -If the first is greater than the second, swap them. -Move one step forward and repeat the comparison. -Once you reach the end, go back to the beginning and repeat the process. -Continue this cycle until all items are sorted. -When it runs a full pass with no swaps, the list is officially sorted. ✅ Key Notes -Its best-case scenario is a sorted list, ironically, the one time you don’t need a sort. -It’s slowest when the list is in reverse order because every element needs to be moved. ⚡🐢🐌 Performance -Time complexity: Worst and average case is O(n²). -Even small lists can take many steps, sorting 4 numbers might involve 8+ steps. -Requires multiple passes through the list. It will still pass through elements that have already been sorted, so it’s inefficient for large datasets. If you're learning too, or just love a good emoji-powered breakdown, follow along for more chapters in this series! 🚀 #JavaScript #Algorithms #Coding #DevNotes
Learning Bubble Sort: Simple but Inefficient Sorting Algorithm
More Relevant Posts
-
📚🌃 Continuing my dive into data structures and algorithms. 🙂 🔍 Tonight’s focus: Chapter 24: Selection Sort ⚙️ How Selection Sort Works -Assume the first item is the smallest. -Scan the entire list to find the actual smallest item. 🔎 -Swap it with the first item and add it to the sorted region. -Move to the next unsorted item and repeat: ----Assume it's the smallest. ----Compare it with the rest of the unsorted region. ----Swap the new smallest into place in the sorted region. -Continue until all items are sorted! ✅ Key Notes -Splits the list into a sorted region (usually at the front) and an unsorted region. -Swaps each new smallest item into place, expanding the sorted region one item at a time. -Simple to understand and implement, but not very efficient. ⚡ Performance -Time: O(n²) -Space: The items sort in their place, so memory usage is minimal. -Not ideal for large datasets. -Slightly less practical than Insertion Sort, but still a good learning tool. 💻 Implementation Tips -Outer loop (i): tracks the boundary between sorted and unsorted. -Inner loop (j): finds the smallest item in the unsorted region. -Swap smallest item with the first unsorted item. If you're learning too, or just love a good emoji-powered breakdown, follow along for more chapters in this series! 🚀 #JavaScript #Algorithms #Coding #DevNotes
To view or add a comment, sign in
-
📚🌃 Continuing my dive into data structures and algorithms. 🙂 🃏↪️🃏Tonight’s focus: Chapter 23: Insertion Sort Insertion Sort is like organizing cards 🃏 in your hand one at a time, you compare and place each card in its correct spot. ⚙️ How Insertion Sort Works -Start with the second item in the list (the first item is considered sorted). -Mark it as the active item. 📌 -Compare the active item to the items on its left (aka the sorted region). -Keep shifting left until you find a value smaller than the active item, then insert it to the right. -Repeat for each item in the unsorted region, reassigning the active item 📌 each time. ✅ Key Notes -Follows a “look left” approach: each new active item 📌 is compared to those before it, one by one, moving toward the first index, until it finds a value that is less than itself. ⚡ Performance -Time: O(n²) in the average and worst case. Best case (already sorted): O(n). -Space: Uses constant memory, no extra space needed. -Not ideal for large datasets, but useful when memory is limited, the list is mostly sorted. -Ok for small data sets. If you're learning too, or just love a good emoji-powered breakdown, follow along for more chapters in this series! 🚀 #JavaScript #Algorithms #Coding #DevNotes
To view or add a comment, sign in
-
📚🌃 Continuing my dive into data structures and algorithms. 🙂 🌳 Tonight’s Focus: Chapter 19 – Binary Tree Traversal In linear structures like arrays or linked lists, we move step-by-step: 0️⃣ ➡️ 1️⃣ ➡️ 2️⃣ ➡️ 3️⃣ But trees are hierarchical 🌳, so we use a different approach: Breadth-First 🔺 and Depth-First 🐋 Traversal ✅ FYI -Tree depth helps us understand how far a node is from the root -The goal is to visit every node and represent the full structure ⚙️ Traversal Basics Each node goes through two phases: Discovered Collection – We identify a node (starting from the root) and add it to this list as soon as it's found. Explored Collection – After a node is discovered, we examine its children. Once all its children have been discovered, we move the node to this list. 🔺 Breadth-First Traversal -Uses a queue (First In, First Out) -Visits nodes level by level, left to right, moving nodes from the discovered to explored collection as they are processed -Example order: A → B → C → D → E… 🐋 Depth-First Traversal -Uses a stack (Last In, First Out) -Nodes are discovered by traversing deep down the left-most path, then backtracked to the nearest unexplored node. During processing, nodes are moved from the discovered collection to the explored collection. ⚡ Performance Time: O(n) Space: O(n) Same across best, average, and worst cases 📚 Might just do half a chapter for the more involved chapters next. If you’re learning too (or just love emoji-powered breakdowns), follow along for more chapters in this series! 🚀 #JavaScript #Algorithms #Coding #DevNotes
To view or add a comment, sign in
-
📚🌃 Continuing my dive into data structures and algorithms. 🙂 🕸️ Tonight’s Focus: Chapter 20 – Graph Traversal (DFS & BFS) Unlike trees, graphs aren’t always hierarchical. They can be messy, interconnected, and unpredictable. So how do we explore them? With two trusty tools: Depth First 🐋 and Breadth First 🧭 Search ✅ FYI Graphs can represent anything from social networks to maps to recommendation systems We explore them to uncover all reachable nodes and understand their connections At the start, we only see one node. The rest are hidden until discovered ⚙️ Traversal Basics Each node goes through two phases Discovered Collection – Nodes are added here as soon as they’re found Explored Collection – Once all discovered neighbors of a node have been checked, the node moves here 🐋 Depth First Search (DFS) Uses a stack (Last In, First Out) Goes deep into one path before backtracking Newly discovered nodes are added to the beginning of the list Example path: A → B → C → E → F → G… 🧭 Breadth First Search (BFS) Uses a queue (First In, First Out) Explores level by level, checking all immediate neighbors before moving outward Newly discovered nodes are added to the end of the list Example path: A → B → C → D → E… ⚙️ Discovery Order DFS: Order depends on how neighbors are listed and pushed BFS: Order follows the queue. First discovered, first explored ⚡ Performance Time: O(n) Space: O(n) Same across best, average, and worst cases. Depends on graph size and structure 📚 These chapters are getting deeper. Might split them up going forward If you’re learning too (or just love emoji-powered breakdowns), follow along for more chapters in this series 🚀 #JavaScript #Algorithms #Coding #DevNotes
To view or add a comment, sign in
-
📚🌃 Continuing my dive into data structures and algorithms. 🙂 📌➗ Tonight’s focus: Chapter 21 – Quicksort Quick Recap: Quicksort is one of the fastest sorting algorithms. It’s popular because it handles large datasets efficiently using a divide-and-conquer strategy. ⚙️ How Quicksort Works -Pick a 📌 pivot element from the array -Partition the array so that: -Elements less than the pivot go to the left -Elements greater than the pivot go to the right -Recursively apply the same logic to the left and right subarrays -Repeat until all regions are sorted ✅ Key Notes -The 📌 pivot element acts as a center point, elements are thrown left or right based on comparison -Once all values around a pivot are placed, that pivot is considered sorted -Choosing a good pivot is crucial since poor choices can lead to performance issues -Not stable meaning it doesn’t guarantee that equal elements will stay in their original order after sorting ⚡ Performance -Best/Average Case: O(n log n) - when partitions are balanced -Worst Case: O(n²) - when partitions are highly unbalanced (for example already sorted data) -To avoid worst-case scenarios, it's recommended to shuffle the array before sorting -Space Complexity: O(log n) 🌍 Real-World Use -Most programming languages have their own built-in and optimized version of Quicksort -You likely won’t need to implement it from scratch unless you're working with custom data structures If you're learning too, or just love a good emoji-powered breakdown, follow along for more chapters in this series! 🚀 #JavaScript #Algorithms #Coding #DevNotes
To view or add a comment, sign in
-
I'm thrilled to launch my new end-to-end Data Science project: a live, interactive Customer Churn Prediction App! 🚀 Instead of just building a model in a Jupyter Notebook, I wanted to build a complete, usable product. I'm proud to say I handled the entire stack, from data analysis to a deployed front-end. The Application: The app allows a user to input customer details into a futuristic, animated dashboard and get a real-time churn probability, visualized on a "risk-o-meter" gauge. The Tech Stack: * Model: Logistic Regression (built with Statsmodels and Scikit-learn) to ensure model interpretability. * Back-End API: A high-performance API built with FastAPI & Pydantic to serve the model. * Front-End: A responsive, animated dashboard built from scratch with HTML, TailwindCSS, and JavaScript. * Deployment: The API is container-ready (using Docker) and handles all serialization (.pkl), scaling, and complex CORS errors. The Challenge: The most challenging (and rewarding) part was deploying the API. Debugging the connection between the web app and the server was a fantastic learning experience. I solved CORS (Cross-Origin) errors, port conflicts, and 422 Unprocessable Content issues by implementing FastAPI middleware and using Pydantic aliases to map the JSON payload to the model's exact feature names! This project was a deep dive into MLOps, API development, and front-end design. The full, documented code is available on my GitHub (see the link in the first comment!). Check out the 52-second demo in the video below. #DataScience #MachineLearning #MLOps #FastAPI #Python #Statsmodels #Pydantic #PortfolioProject #FullStack #WebDevelopment #DataAnalyst
To view or add a comment, sign in
-
🚀 DSA Challenge – Day 93 Problem: Find Median from Data Stream 📊⚙️ This was an exciting deep dive into data structures and real-time computation — maintaining the median efficiently while continuously adding numbers from a stream. 🧠 Problem Summary: You need to design a class MedianFinder that can: ✅ Add numbers dynamically from a data stream. ✅ Return the median at any point in time. If the total number of elements is even → median = mean of the two middle values. If odd → median = middle value. ⚙️ My Approach: 1️⃣ Use two heaps to maintain balance: A max heap (maxHeap) for the smaller half of numbers. A min heap (minHeap) for the larger half. 2️⃣ Whenever a new number arrives: Push it into the maxHeap (inverted to simulate max behavior). Balance both heaps so that their size difference is never more than 1. 3️⃣ Ensure heap order: the maximum in maxHeap ≤ minimum in minHeap. 4️⃣ The median is: The top of the larger heap (if odd count). The average of both tops (if even count). 📈 Complexity: Time: O(log n) → For insertion and heap balancing. Space: O(n) → To store all elements in heaps. ✨ Key Takeaway: This problem highlights how heaps can turn complex real-time median calculations into a smooth, efficient process — a great example of data structure synergy in action. ⚡ 🔖 #DSA #100DaysOfCode #LeetCode #ProblemSolving #Heaps #PriorityQueue #DataStructures #Algorithms #Median #Python #CodingChallenge #InterviewPrep #EfficientCode #DynamicProgramming #TechCommunity #LearningByBuilding #CodeEveryday
To view or add a comment, sign in
-
-
Announcing dshelper-ayushlokre v0.1.0 🚀 Over time, I noticed that in almost every data science project, I repeat the same small setup steps — checking for missing values, scaling the data, splitting the data into train/test sets, and running the same evaluation metrics. None of these is difficult, but they add friction and clutter notebooks with boilerplate. So I built dshelper — a lightweight helper library that focuses on the boring but necessary parts of the workflow, so analysis stays fast, clear, and consistent. It’s not trying to replace pandas, sklearn, or any big framework. It’s simply a productivity layer on top of them. What dshelper does: • Shows missing value statistics with an optional visual summary • Generates correlation insights and clean heatmaps quickly • Allows train/test split + scaling in one simple call • Auto-detects classification vs regression and evaluates accordingly • Works directly with pandas DataFrames and sklearn models you already use No new syntax to learn. No heavy abstractions. Just small helpers that save minutes repeatedly — which adds up. Why I built it: • To reduce repetitive code in notebooks • To make early analysis cleaner and less error-prone • To help myself (and hopefully others) stay focused on insights and modeling • To build something small, open-source, and genuinely useful This is just v0.1.0 — a starting point. I want to grow it based on real needs. Install: pip install dshelper-ayushlokre Quick usage: from dshelper_ayushlokre import missing, preprocessing # Missing value report report = missing.analyze(df, show_plot=True) # Train/test split + scaling X_train, X_test, y_train, y_test = preprocessing.split_and_scale(X, y, test_size=0.2, scaler='standard') Links: -PyPI → https://lnkd.in/dr7a5kMU -GitHub → https://lnkd.in/dG7juciX If you try it, I’d genuinely appreciate: • A ⭐ on GitHub • Feedback/suggestions • Feature requests • Or PR contributions #Python #DataScience #MachineLearning #OpenSource #Pandas #ScikitLearn #PyPI
To view or add a comment, sign in
-
-
🚀 It All Starts with Arrays A few days ago, I was solving a LeetCode problem, one of those “remove duplicates from a sorted list” kind of questions. It looked easy. My brain instantly screamed: “Use a Set!” Well… the test cases failed miserably 😅 That’s when I noticed the question mentioned an in-place algorithm, meaning you had to modify the data directly without extra space. That was my lightbulb moment. I realised that almost every data structure I’ve ever used traces back to the same thing: arrays. Think about it 👇 HashMaps? Arrays with hashed indices. Linked lists? Chained memory blocks. Trees and graphs? Fancy linked lists. Tries? Linked lists hiding behind hash maps. It’s funny how the “basic stuff” quietly powers everything we call advanced. So, next time you’re debugging a complex structure or optimizing performance, give arrays and linked lists a little nod. They’re the real OGs. 🧠 Read the full post here: https://lnkd.in/dxZr9qG7 #SoftwareEngineering #DataStructures #BackendDevelopment #LearningInPublic #LeetCode
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development