DEV Community

Mukilan Palanichamy
Mukilan Palanichamy

Posted on

My journey in competitive programming

Today's Learn: Bubble Sort and Middle Node

Hey guys,

I focused on the two main concepts today-Bubble Sort, and how to find a middle node in a LinkedList.

Bubble Sort:

Bubble Sort is a very simple sorting algorithm in that we go through the list over and over again, comparing and swapping adjacent numbers until everything is in order. It's called "bubble" because the biggest numbers slowly "bubble up" to their correct positions. It's simple and a great way to understand how sorting works!

Image description

Middle Node:

Finding the middle node of a linked list was a really fun thing to learn. I used a smart trick with two pointers:

One pointer moves fast (two steps at a time), and the other moves slow (one step at a time).
When the fast pointer reaches the end of the list, the slow pointer is at the middle.

Image description

Thanks!

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay