Moving Nodes and Building Order - Day 213 Today Today I learned how to actually build a Min Heap from scratch using JavaScript. Yesterday was about the structure but today was about the movement of data. When I insert a new value I always put it at the very end of the array. Then I compare it with its parent. If the new value is smaller I swap them. I keep doing this until the value finds its right place. This is called heapify up or bubbling up. Deleting the smallest value is different. The smallest value is always at the top root. I take it out and move the last value of the array to the root. Since this value is probably too large I move it down by comparing it with its children. I always swap with the smaller child to keep the min heap property. This is called heapify down. I used a JavaScript class to manage this. I used simple math formulas to find the connections between parents and children in the array. This way I do not need complex pointers. Today was about logic and writing clean helper functions to make the heap work. LeetCode logic and structures solved today: Manual implementation of Min Heap class Logic for Heapify Up insertion Logic for Heapify Down deletion Array index mapping for binary trees #DSAinJavaScript #365daysOfCoding #JavaScriptLogic #LeetCode #DataStructures #MinHeap #AlgorithmBuilding #LogicDevelopment #ProgrammingDaily #SoftwareEngineer #CodingLogic #JavaScriptDeveloper #Heapify #ArrayLogic #ProblemSolving #CodePractice #TechLearning #StructureAndLogic #BuildingBlocks #WebDevLearning
Implementing Min Heap in JavaScript
More Relevant Posts
-
🚀 Week 1 Project: Advanced Scientific Calculator code link below mentioned 👇 https://lnkd.in/gqVJSPwM Github link https://lnkd.in/gRq4qUJs 🚀 Week 1 Project: Advanced Scientific Calculator I built a fully functional Scientific Calculator using HTML, CSS, and JavaScript. 🔧 Key Features: • Basic arithmetic operations (+, −, ×, ÷) • Trigonometric functions (sin, cos, tan) • Degree & Radian mode support • Logarithmic functions (log, ln) • Factorial calculations (!) • Power operations (x², x³, xʸ) • Constants (π, e) • Expression-based evaluation • History tracking & keyboard support 💡 What I learned: • DOM manipulation in JavaScript • Handling complex expressions • Building real-world UI components • Improving problem-solving and logic 📈 This is part of my journey to becoming a Full Stack Developer. More projects coming every week! #FullStack #JavaScript #WebDevelopment #100DaysOfCode #LearningInPublic #Projects
To view or add a comment, sign in
-
Priority Order in JavaScript Day 216 Today Today I learned about the Priority Queue. It is a very important concept in data structures. In a normal queue the rule is first in first out. But in a priority queue the element with the highest priority is processed first. Think of a hospital emergency room. A patient with a serious injury gets treated before someone with a cold even if the person with the cold arrived earlier. This is exactly how a priority queue works. I learned that there are two ways to implement this. You can use an array and sort it every time but that is slow. The best way is using a Heap. Using a Heap makes adding and removing elements very fast because the time complexity is log n. JavaScript does not have a built in priority queue like some other languages. This means we have to build it ourselves using classes. This is a great way to practice logic building and understand how things work under the hood. A very helpful tip for interviews is that if a question asks for the Kth smallest or Kth largest element you should think of using a priority queue or a heap. It makes the solution much more efficient. Today I solved these LeetCode questions: 215 Kth Largest Element in an Array 703 Kth Largest Element in a Stream #DSAinJavaScript #365daysOfCoding #JavaScriptLogic #LeetCode #DataStructures #PriorityQueue #CodingInterview #ProgrammingDaily #SoftwareEngineering #TechLearning #WebDevelopment #LogicBuilding #ProblemSolving #JavaScriptDev #JSCode #ArrayLogic #HeapDataStructure #AlgorithmDesign #CodingChallenge #BinaryHeap
To view or add a comment, sign in
-
🚀 𝗗𝗮𝘆 𝟮𝟳/𝟯𝟬 – 𝟯𝟬 𝗗𝗮𝘆𝘀 𝗼𝗳 𝗣𝘆𝘁𝗵𝗼𝗻 𝗣𝗿𝗼𝗷𝗲𝗰𝘁 𝗖𝗵𝗮𝗹𝗹𝗲𝗻𝗴𝗲 Consistency builds skill. Skill builds confidence. 🚀 As part of my 30-day challenge, I’m focused on solving real-world problems while strengthening core development concepts. 🧠 𝗧𝗼𝗱𝗮𝘆’𝘀 𝗣𝗿𝗼𝗷𝗲𝗰𝘁: 𝗪𝗲𝗮𝘁𝗵𝗲𝗿 𝗔𝗽𝗽 (GUI) I built a Python-based Weather Application using Tkinter that fetches real-time weather data and displays it in an interactive graphical interface. ✨ 𝗪𝗵𝘆 𝘁𝗵𝗶𝘀 𝗽𝗿𝗼𝗷𝗲𝗰𝘁 𝗺𝗮𝘁𝘁𝗲𝗿𝘀: This project goes beyond CLI and introduces GUI development — making applications more user-friendly and visually interactive while still leveraging real-time API data. ⚙️ 𝗞𝗲𝘆 𝗙𝗲𝗮𝘁𝘂𝗿𝗲𝘀: • Real-time weather data by city 🌍 • Displays temperature, humidity, and condition 🌡️ • Dynamic weather icons (sun, cloud, rain) 🖼️ • Clean and responsive Tkinter UI 💻 • Error handling for invalid inputs ⚠️ 💡 𝗖𝗼𝗻𝗰𝗲𝗽𝘁𝘀 𝗔𝗽𝗽𝗹𝗶𝗲𝗱: • API integration using `requests` • GUI development with Tkinter • Handling JSON data • Image processing using Pillow • Writing modular and clean Python code 🔗 𝗚𝗶𝘁𝗛𝘂𝗯: https://lnkd.in/dSqTtREe 📌 𝗧𝗮𝗸𝗲𝗮𝘄𝗮𝘆: Moving from CLI to GUI is a big step — it changes how users interact with your application. Building such projects helps understand not just logic, but also user experience. On to Day 28. 🔥 #Python #BuildInPublic #DeveloperJourney #30DaysOfCode #APIs #Tkinter #SoftwareDevelopment #Coding #Learning #OpenSource #Projects
To view or add a comment, sign in
-
📣 𝗡𝗲𝘅𝘁 𝗕𝗹𝗼𝗴 𝗶𝘀 𝗛𝗲𝗿𝗲! ⤵️ Array Methods You Must Know — Writing Less Loops, More Logic ⚡🧠 Working with arrays using only loops feels repetitive. Modern JavaScript gives cleaner tools — and this blog explains them step by step. 🔗 𝗥𝗲𝗮𝗱 𝗵𝗲𝗿𝗲: https://lnkd.in/gqQKdsAc 𝗧𝗼𝗽𝗶𝗰𝘀 𝗰𝗼𝘃𝗲𝗿𝗲𝗱 ✍🏻: ⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺ ⇢ Adding and removing elements using push, pop, shift, unshift ⇢ Looping arrays cleanly with forEach() ⇢ Transforming data using map() ⇢ Filtering values using filter() ⇢ Combining array values using reduce() ⇢ Traditional loops vs modern method chaining ⇢ Real beginner examples and practice assignments ⇢ Common mistakes like forgetting return in map/filter ⇢ Mental model to choose the right method 💬 If arrays still feel like “write loop → do work → repeat”, this article helps you understand how modern array methods make code cleaner, shorter, and easier to reason about. #ChaiAurCode #JavaScript #ArrayMethods #WebDevelopment #ProgrammingBasics #Beginners #LearningInPublic #100DaysOfCoding
To view or add a comment, sign in
-
-
🚀 Day 10 of DSA Practice – Flattening the Chaos! At first glance, flattening an array seems simple… but what happens when it’s nested infinitely? 🤯 🔍 Problem: Flatten a nested array into a single level 👉 Example: [1, [2, 3], [4, [5, 6]]] → [1, 2, 3, 4, 5, 6] 💭 My Approach: 1️⃣ Understand how nested structures behave 2️⃣ Handle elements at any depth 3️⃣ Make the solution work for all edge cases 🧠 Key Takeaway: When dealing with nested data: Break the problem into smaller parts Think recursively or iteratively ⚡ Realization: It’s not just about flattening one array… It’s about handling infinite levels of complexity 🔥 💻 Check out my implementation: 🔗 GitHub – Day 10: Flatten Array 💬 Question for you: What’s your favorite trick for handling deeply nested data structures? #DSA #JavaScript #CodingJourney #Recursion #100DaysOfCode #FrontendDeveloper #ProblemSolving #TechTips
To view or add a comment, sign in
-
-
𝗧𝗵𝗲 𝗣𝗼𝘄𝗲𝗿 𝗼𝗳 𝗬𝗶𝗲𝗹𝗱 𝗞𝗲𝘆𝘄𝗼𝗿𝗱 𝗶𝗻 𝗝𝗮𝗵𝗮𝘀𝗰𝗿𝗶𝗽𝘁 The yield keyword in JavaScript is used with generators. Generators are special functions that can be paused and resumed. They are useful for working with sequences of data and asynchronous programming. Here are some real-life use cases: - Generators allow for lazy evaluation, meaning they produce values on-demand. - Generators can be used with asynchronous code to simplify complex flows. - Generators can be used to create custom iterators. - Generators can be used to implement recursive algorithms with an iterative style. You can use the yield keyword to pause the execution of a generator function and pass values in and out of the generator. This enables more readable and manageable asynchronous and iterative code. Source: https://lnkd.in/giTGm4PU
To view or add a comment, sign in
-
Solved one of the most famous Linked List problems today on LeetCode: Add Two Numbers This problem looks simple at first, but it really tests your understanding of traversal, carry handling, and clean pointer manipulation. 💡 Big Takeaway: Using a Dummy (Sentinel) Node makes the solution much cleaner and avoids edge cases while building the result list. let dummy = new ListNode(0); let current = dummy; Now instead of worrying about initializing the head separately, you can directly keep attaching nodes: current.next = new ListNode(digit); current = current.next; Core Logic: Traverse both lists simultaneously Add digits along with carry Store sum % 10 as the node value Carry forward Math.floor(sum / 10) while (l1 || l2 || carry) { let sum = (l1 ? l1.val : 0) + (l2 ? l2.val : 0) + carry; carry = Math.floor(sum / 10); } ⚡ Why this matters: Handling carry + unequal lengths + null nodes in a clean way is a pattern used in many real-world problems. Small problem, but powerful pattern #LeetCode #DSA #LinkedList #JavaScript #ProblemSolving
To view or add a comment, sign in
-
-
Built something today because nothing out there worked the way I needed. I came up with a new sorting approach — “Zipper Sort” — and wanted to visualize it step by step. Existing tools didn’t cut it (too abstract, not real execution), so I built my own 👇 🚀 ALGO_TYPEWRITER — a browser-based visualizer that runs real C/C++ sorting code and animates it live. 💡 What it does • Paste C/C++ → hit RUN • Watch comparisons (green) & swaps (bars slide, not resize) • Pause/resume, control speed, adjust array size • Get stats: time, comparisons, swaps + inferred complexity ⚙️ How it works • Regex-based transpiler → C/C++ → JS • Proxy layer logs comparisons/swaps (no code modification) • Action log replayed as smooth animations 📊 Complexity is measured empirically, not hardcoded. 🔥 Built this to test one idea… ended up building a full system. Would love to hear your thoughts on Zipper Sort and whether tools like this would help you understand algorithms better. #buildinpublic #algorithms #cpp #javascript #webdev #learningbydoing Link to the GitHub Repo housing this Project https://lnkd.in/dmdHfWQf
To view or add a comment, sign in
-
Speed Up Your Code with Hashing Day 218 Today Today I learned about Hashing in JavaScript. Hashing is like a shortcut for your data. Instead of looking through a long list one by one which takes O(n) time, hashing lets you find things almost instantly in O(1) time. Think of it like a library where every book has a special code to find its shelf directly. In JavaScript, we use Objects, Maps, and Sets to do this. [Image comparing time complexity of Array search vs Hash Map search] Hashing helps with counting how many times a word appears, finding duplicates, and solving sum problems. It takes extra memory but saves a lot of time. If you see a problem with words like frequency, unique, or duplicate, hashing is usually the best answer. #DSAinJavaScript #365daysOfCoding #JavaScriptLogic #LeetCode #Hashing #DataStructures #CodingChallenge #WebDevelopment #Algorithm #ProblemSolving #MapAndSet #SoftwareEngineering #JSPerformance #InterviewPrep #TechLearning #LogicBuilding #CodeDaily #ProgrammingLife #Optimization #CodingJourney
To view or add a comment, sign in
-
𝗗𝗮𝘆 𝟭𝟲/𝟯𝟬 – 𝟯𝟬 𝗗𝗮𝘆𝘀 𝗼𝗳 𝗣𝘆𝘁𝗵𝗼𝗻 𝗣𝗿𝗼𝗷𝗲𝗰𝘁 𝗖𝗵𝗮𝗹𝗹𝗲𝗻𝗴𝗲 Continuing my journey of building one Python project every day to sharpen my development skills. Today’s focus was on bridging the gap between GUI design and Real-time Data Fetching. 🧠 𝗣𝗿𝗼𝗷𝗲𝗰𝘁: 𝗦𝗺𝗮𝗿𝘁 𝗖𝘂𝗿𝗿𝗲𝗻𝗰𝘆 𝗖𝗼𝗻𝘃𝗲𝗿𝘁𝗲𝗿 A sleek desktop application built using Python and Tkinter that fetches live exchange rates to provide instant, accurate global currency conversions. ✨ 𝗙𝗲𝗮𝘁𝘂𝗿𝗲𝘀: • Live Exchange Rates: Real-time data via External API integration. • Modern UI/UX: Enhanced readability with custom fonts and high-contrast styling. • Responsive Design: Dynamic layout with structured padding for a professional feel. • Error Handling: Robust validation for "Invalid Input" or network issues. 💡 𝗖𝗼𝗻𝗰𝗲𝗽𝘁𝘀 𝗨𝘀𝗲𝗱: • Tkinter & TTK: Advanced GUI layout and widget styling. • API Integration: Using the requests library to handle JSON data. • Object-Oriented Logic: Clean separation of UI elements and backend calculation. • Formatting: Implementing internal padding and geometry management for better UX. 🔗 𝗚𝗶𝘁𝗛𝘂𝗯 𝗟𝗶𝗻𝗸: https://lnkd.in/dpMC3ykM Building projects daily to improve consistency, problem-solving, and real-world development skills. Follow along as I complete 30 Python projects in 30 days 🚀 #Python #BuildInPublic #DeveloperJourney #30DaysOfCode #Programming #PythonProjects #Coding #GUI #Tkinter #API #WebServices #currency #post
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