Skip to main content

Sorting Algorithms


Java Implementation for Sortings:

Bubble Sort:

import java.util.Scanner;
public class BubbleSort {
      public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("input size");
int n = scan.nextInt();
int[] ar = new int[n];
System.out.println("input elements");
for (int i = 0; i < ar.length; i++) {
ar[i] = scan.nextInt();
}
bubbleSort(ar);
for (int i = 0; i < ar.length; i++) {
System.out.print(ar[i]+"\t");
}
System.out.println();
scan.close();
}
private static void bubbleSort(int[] ar) {
// TODO Auto-generated method stub
int temp = 0;
for (int i = 0; i < ar.length; i++) {
for (int j = 1; j < (ar.length-i); j++) {
if(ar[j-1]>ar[j]){
temp = ar[j-1];
ar[j-1] = ar[j];
ar[j] = temp;
}
}
        }
}
}


Insertion Sort:

import java.util.Scanner;
public class InsertionSort {
    public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("input size");
int n = scan.nextInt();
int[] ar = new int[n];
System.out.println("input elements");
for (int i = 0; i < ar.length; i++) {
ar[i] = scan.nextInt();
}
insertionSort(ar);
for (int i = 0; i < ar.length; i++) {
System.out.print(ar[i]+"\t");
}
System.out.println();
scan.close();
}
private static void insertionSort(int[] ar) {
int key,j;
for (int i = 1; i < ar.length; i++) {
key = ar[i];
j=i-1;
while(j>=0 && ar[j]>key){
ar[j+1] = ar[j];
j--;
}
ar[j+1] = key;
}
}
}

Comments

Popular posts from this blog

Unshackling the 65mm Format: Inside the ARRI ALEXA 265

  Introduction If you’ve ever tried to shoot dynamic, kinetic movement with a 65mm digital cinema camera, you know the physical toll it takes. Hauling a 10.5-kilogram brain around requires specialized remote heads, heavy-duty stabilization, and an operator with iron shoulders. The sheer physics of large-format glass and massive sensor blocks historically meant sacrificing agility for image quality. Directors had to choose: do we want the immersive, medium-format aesthetic, or do we want to move fast in tight locations? The ARRI ALEXA 265 eliminates that compromise entirely. By stripping the 65mm form factor down to a staggering 3.3 kilograms and injecting the absolute cutting-edge of REVEAL Color Science, ARRI hasn’t just updated a camera—they have fundamentally altered how and where we can shoot large format. Let's break down why this is a seismic shift for visual creators. The Physics of Shrinking 65mm The most immediate shock when looking at the ALEXA 265 is the footprint. It i...

The Sideways Film and the Chicken-Head Robot: Why Modern Movies Look So "Real"

If you’ve walked out of a theater recently feeling like you were inside the movie rather than just watching it, you aren’t imagining things. We are currently living through a weird, wonderful "tech-renaissance" in cinematography. On one hand, we have cameras that can practically see in the dark; on the other, top-tier directors are resurrecting 70-year-old film formats that are literally held together by gears and grease. As a cinematographer, I can tell you: it’s not about having the "best" camera anymore—it’s about having the camera with the most soul. Let’s look at two movies that just changed the game: One Battle After Another and Civil War . 1. The "Kobe Beef" Hamburger (VistaVision) In One Battle After Another , Director Paul Thomas Anderson and DP Michael Bauman did something radical: they went backward to go forward. They used VistaVision , a format from the 1950s where the 35mm film travels through the camera horizontally instead of vertically....

Size Matters (But Not How You Think): Why 17K is the New Indie Darling

Remember when shooting "Large Format" meant renting a camera the size of a mini-fridge, hiring a team of bodybuilders to move it, and selling your soul to a studio to pay for the film stock? Think Lawrence of Arabia or 2001: A Space Odyssey. Well, grab your popcorn, because the gatekeepers just lost the keys. The cinema world is buzzing about a new power couple that’s turning the industry on its head: the Blackmagic URSA Cine 17K 65 and the Cooke Panchro 65/i lenses. Together, they are proving that "Grand Format" isn't just for exploding planets anymore—it’s for intimate, human stories. Here’s the breakdown of why this tech is a game-changer, in plain English. ========================================================================== The Beast: Blackmagic URSA Cine 17K 65 Let’s talk numbers for a second. Most of us watch movies in 4K. This camera shoots in 17K . To be precise, that’s a resolution of 17,520 x 8,040 pixels. That is a staggering 140 megapixels ...