Doubly Linked List Implementation in Java Today I implemented a Doubly Linked List from scratch to strengthen my understanding of how data structures work internally. What I built: • Converted an array into a Doubly Linked List • Traversed and printed the list • Calculated length of the list • Implemented deletion operations: • Delete head • Delete tail Key Operations Implemented: 1. Convert Array → DLL • Created nodes dynamically • Linked each node using next and back 2. Delete Head • Move head to next node • Remove backward reference 3. Delete Tail • Traverse to last node • Disconnect last node from previous 4. Length Calculation • Traverse the list and count nodes #Java #DataStructures #DSA #BackendJourney #SoftwareDevelopment
Java Doubly Linked List Implementation
More Relevant Posts
-
Day 67 — LeetCode Progress (Java) Problem: Insert Delete GetRandom O(1) Goal: Design a data structure that supports: Insert Delete Get Random All in O(1) time Idea: You can’t rely on just a set or list — you need both speed + index access. Approach: Use: ArrayList → for O(1) random access HashMap → value → index mapping Insert:If value exists → return false Else: Add to list Store index in map Remove:If value not present → return false Else: Swap it with last element in list Update map for swapped element Remove last element Delete from map GetRandom:Generate random index Return element from list Time Complexity: O(1) for all operations Space Complexity: O(n) #LeetCode #DSA #Java #HashMap #ArrayList #SystemDesign #CodingJourney
To view or add a comment, sign in
-
-
Still writing instanceof + casts + nested conditionals? That’s legacy Java. With Java25, pattern matching simplifies type checks, switch logic, and data extraction. Learn how with Mihaela Gheorghe-Roman: https://lnkd.in/d6PuSZdH #CleanCode #PatternMatching #JDK25 OpenJDK #Java #Java25
To view or add a comment, sign in
-
-
Most Java performance issues don’t show up in code reviews They show up in object lifetimes. Two pieces of code can look identical: same logic same complexity same output But behave completely differently in production. Why? Because of how long objects live. Example patterns: creating objects inside tight loops → short-lived → frequent GC holding references longer than needed → objects move to old gen caching “just in case” → memory pressure builds silently Nothing looks wrong in the code. But at runtime: GC frequency increases pause times grow latency becomes unpredictable And the worst part? 👉 It doesn’t fail immediately. 👉 It degrades slowly. This is why some systems: pass load tests work fine initially then become unstable weeks later Takeaway: In Java, performance isn’t just about what you do. It’s about how long your data stays alive while doing it. #Java #JVM #Performance #Backend #SoftwareEngineering
To view or add a comment, sign in
-
A small mistake in SQL can slow down your entire application. I learned this the hard way. A query that looked perfectly fine was taking 6–7 seconds in production. Reason? • Missing indexes • Unnecessary joins • Fetching more data than required After optimization, response dropped to under 2 seconds. Lesson: Backend performance often depends more on DB than Java code. #SQL #BackendDeveloper #Java #PerformanceOptimization #Microservices
To view or add a comment, sign in
-
🌱 A Small Step in My DSA Journey (Java) As part of my ongoing Data Structures practice, I recently worked on a problem: 👉 Converting a Binary Tree into a Linked List (in-place) using Java This helped me strengthen my understanding of: • Preorder traversal and its practical use • Managing pointers carefully without losing node references • Modifying data structures efficiently without extra space 💡 One key realization: Writing code is one part—but understanding how data flows through the structure makes the real difference. Practiced implementing this using Java and gained better clarity on pointer manipulation. Taking it one step at a time and building stronger fundamentals 🚀 #Java #DataStructures #DSA #BinaryTree #ProblemSolving #LearningInPublic
To view or add a comment, sign in
-
-
Day 6/75 – Data Structures & Algorithms Practice Solved the “Best Time to Buy and Sell Stock” problem on LeetCode using Java. • 212 / 212 test cases passed • Runtime: 1 ms (Beats 99.92%) • Time Complexity: O(n) • Space Complexity: O(1) Approach: Used a single-pass greedy strategy by tracking the minimum price so far and continuously updating the maximum profit. This avoids checking all pairs and keeps the solution efficient. Key Takeaways: Importance of optimizing brute-force logic Writing clean and efficient code Strengthening understanding of greedy techniques Consistent daily problem-solving is helping me improve both logic building and performance optimization. #75DaysOfDSA #DSA #Java #LeetCode #ProblemSolving #SoftwareEngineering
To view or add a comment, sign in
-
-
Stack vs Heap Memory in Java – Where Does Your Data Live? 🧠 Stack Memory: ▸ Method calls + local variables ▸ LIFO (Last In, First Out) ▸ Very fast, auto-cleared after method ends ▸ Each thread has its own stack Heap Memory: ▸ Stores objects & instance variables ▸ Shared across threads ▸ Managed by Garbage Collector ▸ Slower than Stack, can throw OutOfMemoryError Example: void demo() { int x = 10; String s = new String("Java"); } ▸ x → Stack ▸ s (reference) → Stack ▸ "Java" object → Heap Rule: → Primitives → Stack → References → Stack → Objects → Heap #Java #SpringBoot #BackendDevelopment #Memory #JavaDeveloper
To view or add a comment, sign in
-
-
Stack vs Heap Memory in Java – Where Does Your Data Live? 🧠 Stack Memory: ▸ Method calls + local variables ▸ LIFO (Last In, First Out) ▸ Very fast, auto-cleared after method ends ▸ Each thread has its own stack Heap Memory: ▸ Stores objects & instance variables ▸ Shared across threads ▸ Managed by Garbage Collector ▸ Slower than Stack, can throw OutOfMemoryError Example: void demo() { int x = 10; String s = new String("Java"); } ▸ x → Stack ▸ s (reference) → Stack ▸ "Java" object → Heap Rule: → Primitives → Stack → References → Stack → Objects → Heap #Java #SpringBoot #BackendDevelopment #Memory #JavaDeveloper
To view or add a comment, sign in
-
-
Stack vs Heap Memory in Java – Where Does Your Data Live? 🧠 Stack Memory: ▸ Method calls + local variables ▸ LIFO (Last In, First Out) ▸ Very fast, auto-cleared after method ends ▸ Each thread has its own stack Heap Memory: ▸ Stores objects & instance variables ▸ Shared across threads ▸ Managed by Garbage Collector ▸ Slower than Stack, can throw OutOfMemoryError Example: void demo() { int x = 10; String s = new String("Java"); } ▸ x → Stack ▸ s (reference) → Stack ▸ "Java" object → Heap Rule: → Primitives → Stack → References → Stack → Objects → Heap #Java #SpringBoot #BackendDevelopment #Memory #JavaDeveloper
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