Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a program to implement bubble sort on a hardcoded array and print each step of the sorting process.

Medium

Problem Statement

Write a program to implement bubble sort on a hardcoded array and print each step of the sorting process.

Sample Input

Array: [5, 3, 8, 6, 2]

Sample Output

Step 1: 3, 5, 6, 2, 8
Step 2: 3, 5, 2, 6, 8
Step 3: 3, 2, 5, 6, 8
Step 4: 2, 3, 5, 6, 8

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
using System; class BubbleSortSteps { static void Main() { // Implement bubble sort and print each step } }
Log in or sign up to run or submit your code.Log inSign up
Input
Array: [5, 3, 8, 6, 2]
Expected Output
Step 1: 3, 5, 6, 2, 8
Step 2: 3, 5, 2, 6, 8
Step 3: 3, 2, 5, 6, 8
Step 4: 2, 3, 5, 6, 8