• About
  • Advertise
  • Privacy & Policy
  • Contact
iOSlift logo
  • Home
  • About
  • JailBreakMe
  • Services
  • Paid Services
  • Downloads
    • IOS 14 BEta IPSW
    • IOS 13 iPSW
    • TVPROfileOS
    • MacOS Profile Download
    • WatchOS Profile Configuration
No Result
View All Result
  • Home
  • About
  • JailBreakMe
  • Services
  • Paid Services
  • Downloads
    • IOS 14 BEta IPSW
    • IOS 13 iPSW
    • TVPROfileOS
    • MacOS Profile Download
    • WatchOS Profile Configuration
No Result
View All Result
iOSLift Logo White Mob
No Result
View All Result

Implant linear and bubble sort in java discuss in class (Don’t bulletin array).

Faheem Ali by Faheem Ali
March 21, 2017
Home Uncategorized
Share on FacebookShare on Twitter

LAB # 6

Linear and bubble sort in java

 

OBJECTIVE # 1:

Implant  linear and bubble sort in java discuss in class (Don’t bulletin array).

SOURCE CODE:

public class NewClass6_1 {

public static void main(String ar[]){

System.out.println(“linear sort”);

int Data[]={2,4,7,45,44};

int k=1;

for(k=0;k<Data.length;k++){

int ptr=k+1;

while(ptr<Data.length){

if(Data[k]>Data[ptr]){

int a=Data[k];

Data[k]=Data[ptr];

Data[ptr]=a;

}

ptr=ptr+1;

 

}

}

for(int i=0;i<Data.length;i++){

System.out.print(Data[i]+”,”);

}

System.out.println(“\rbubble sort”);

int Data1[]={22,23,80,10,32};

int k1;

for(k1=1;k1<Data1.length;k1++){

int ptr=0;

while(ptr<Data1.length-k1){

if(Data1[ptr]>=Data1[ptr+1]){

 

int temp=Data1[ptr];

Data1[ptr]=Data1[ptr+1];

Data1[ptr+1]=temp;

 

}

ptr=ptr+1;

}

}

for(int i=0;i<Data1.length;i++){

System.out.print(Data1[i]+”,”);

}

}

 

}

 

 

Output:

linear sort

2,4,7,44,45,

bubble sort

10,22,23,32,80,

OBJECTIVE # 2:

Implant array sort for sorting in integer char double. Also sort for specific range.

SOURCE CODE:

import java.util.*;

public class lab6_2 {

 

 

public static void main(String ar[]){

int[] i={12,14,15,16,3};

double[] j={0.2,0.3,0.4,0.5,0.6};

char[] r={‘o’,’p’,’r’,’e’,’v’};

Arrays.sort(i);

Arrays.sort(j);

Arrays.sort(r);

 

System.out.println(“INTGER”);

for(int k=0;k<i.length;k++){

System.out.println(i[k]);

 

}

System.out.println(“Double”);

for(int k=0;k<j.length;k++){

System.out.println(j[k]);

}

System.out.println(“Double”);

for(int k=0;k<r.length;k++){

System.out.println(r[k]);

}

Arrays.sort(i,0,2);

Arrays.sort(j,2,3);

Arrays.sort(r,1,3);

System.out.println(“Spacific “);

System.out.println(“INTGER”);

for(int k=0;k<2;k++){

System.out.println(i[k]);

}

System.out.println(“Double”);

for(int k=0;k<3;k++){

System.out.println(j[k]);

}

System.out.println(“Double”);

for(int k=0;k<3;k++){

System.out.println(r[k]);

}

 

}

}

Output:

INTGER

3

12

14

15

16

Double

0.2

0.3

0.4

0.5

0.6

Double

e

o

p

r

v

Spacific

INTGER

3

12

Double

0.2

0.3

0.4

Double

e

o

p

 

OBJECTIVE # 3:

Readel the algotithm of linear and bubble sort form maximum to minimum string (Don’t use array .sort)

SOURCE CODE:

 

public class lab6_3 {

 

 

public static void main(String ar[]){

System.out.println(“Maxi to Mini”);

int Data[]={22,23,80,10,32};

int k;

for(k=1;k<Data.length;k++){

int ptr=0;

while(ptr<Data.length-k){

if(Data[ptr]<Data[ptr+1]){

 

int temp=Data[ptr];

Data[ptr]=Data[ptr+1];

Data[ptr+1]=temp;

 

}

ptr=ptr+1;

}

}

for(int i=0;i<Data.length;i++){

System.out.print(Data[i]+”,”);

}

}

}

Output:

Maxi to Mini

80,32,23,22,10,

OBJECTIVE # 3

Implement lab task 1 and 3 for string(alphabet) .

SOURCE CODE

 

 

 

public class lab6_h {

 

public static void main(String[] args) {

String[] list = {“umair”, “hamza”, “ahsan”, “junaid”, “suhfa”};

System.out.print(“STRING ARRAY : “);

for(int w = 0; w < list.length; w++){

System.out.print(list[w]+”, “);

}// end for loop

 

System.out.println(“\n\n——————–“);

System.out.println(“ASCENDING ORDER”);

System.out.println(“——————–“);

linear_Sort_Ascending(list);

System.out.print(“\nLINEAR SORT : “);

for(int b = 0; b < list.length; b++){

System.out.print(list[b]+”, “);

}// end for loop

 

bubble_Sort_Ascending(list);

System.out.print(“\nBUBBLE SORT : “);

for(int s = 0; s < list.length; s++){

System.out.print(list[s]+”, “);

}// end for loop

 

System.out.println(“\n\n——————–“);

System.out.println(“DESCENDING ORDER”);

System.out.println(“——————–“);

linear_Sort_Descending(list);

System.out.print(“\nLINEAR SORT : “);

for(int b = 0; b < list.length; b++){

System.out.print(list[b]+”, “);

}// end for loop

 

bubble_Sort_Descending(list);

System.out.print(“\nBUBBLE SORT : “);

for(int s = 0; s < list.length; s++){

System.out.print(list[s]+”, “);

}// end for loop

 

}// end main method

 

public static void linear_Sort_Ascending(String[] l){

for(int k = 0; k < l.length; k++){

int ptr = k + 1;

while(ptr < l.length){

if(l[k].compareToIgnoreCase(l[ptr]) > 0){

String temp = l[k];

l[k] = l[ptr];

l[ptr] = temp;

}// end if

ptr = ptr + 1;

}//end while

}// end for

}// end method

 

public static void bubble_Sort_Ascending(String[] l){

for(int k = 1; k < l.length; k++){

int ptr = 0;

while(ptr < l.length – k){

if(l[ptr].compareToIgnoreCase(l[ptr + 1]) > 0){

String temp = l[ptr];

l[ptr] = l[ptr + 1];

l[ptr + 1] = temp;

}// end if

ptr = ptr + 1;

}//end while

}// end for

}// end method

 

public static void linear_Sort_Descending(String[] l){

for(int k = 0; k < l.length; k++){

int ptr = k + 1;

while(ptr < l.length){

if(l[k].compareToIgnoreCase(l[ptr]) < 0){

String temp = l[k];

l[k] = l[ptr];

l[ptr] = temp;

}// end if

ptr = ptr + 1;

}//end while

}// end for

}// end method

 

public static void bubble_Sort_Descending(String[] l){

for(int k = 1; k < l.length; k++){

int ptr = 0;

while(ptr < l.length – k){

if(l[ptr].compareToIgnoreCase(l[ptr + 1]) < 0){

String temp = l[ptr];

l[ptr] = l[ptr + 1];

l[ptr + 1] = temp;

}// end if

ptr = ptr + 1;

}//end while

}// end for

}// end method

 

 

}

Output:

STRING ARRAY : umair, hamza, ahsan, junaid, suhfa,

——————–

ASCENDING ORDER

——————–

LINEAR SORT : ahsan, hamza, junaid, suhfa, umair,

BUBBLE SORT : ahsan, hamza, junaid, suhfa, umair,

——————–

DESCENDING ORDER

——————–

LINEAR SORT : umair, suhfa, junaid, hamza, ahsan,

BUBBLE SORT : umair, suhfa, junaid, hamza, ahsan,

Previous Post

Implement linear search and binary search algorithm (Discuss in class).

Next Post

Implement Insertion sort algorithm in java.

Faheem Ali

Faheem Ali

I'm A Student of Sir Syed University Here to Provide you News and Updates on iPhone , iPad , iPhone and Also The iMac & Apple iWatch

Next Post

Implement Insertion sort algorithm in java.

Please login to join discussion
  • How To Fill Google AdSense MANAGE Tax Info in Pakistan

    HOW TO BYPASS IPHONE PTA TAX IN PAKISTAN

    555 shares
    Share 222 Tweet 139
  • All in One Automatic Roti Maker in Pakistan

    531 shares
    Share 212 Tweet 133
  • GymKit and Apple Watch: A Perfect Pair for Effective Workouts

    508 shares
    Share 203 Tweet 127
  • How To Do CPLC Mobile Check Step-By-Step Guide

    497 shares
    Share 199 Tweet 124
  • What is Chat CPT How it Works ?

    497 shares
    Share 199 Tweet 124
iOSlift logo

iOS lift provides Software Updates for Apple Products like iPhone, iPod , iPad & iMac

Follow Us

Categories

  • Apple
  • iPhone’s
  • iOS
  • Cydia Jaibreak
  • Computers
  • Business
  • Community
  • Education
  • Electric Car
  • Entertainment
  • Trending
  • Comments
  • Latest
How To Fill Google AdSense MANAGE Tax Info in Pakistan

HOW TO BYPASS IPHONE PTA TAX IN PAKISTAN

November 29, 2022
All in One Automatic Roti Maker in Pakistan

All in One Automatic Roti Maker in Pakistan

July 20, 2020
GymKit and Apple Watch

GymKit and Apple Watch: A Perfect Pair for Effective Workouts

December 8, 2023
CPLC Mobile Check

How To Do CPLC Mobile Check Step-By-Step Guide

December 2, 2023
Get Free: Game Show Aisay Chalay Ga Passes & Timings ,Registration

Get Free: Game Show Aisay Chalay Ga Passes & Timings ,Registration

78
Apple Releases Their New IOS 10.3 Beta 1 Public Preview

Apple Releases Their New IOS 10.3 Beta 1 Public Preview

9
How To Get PAKISTAN V WORLD XI T20 Cricket Match Tickets

Pakistan Super League 2018 Schedule

6

MacOS Beta Profile Error “you must enroll your Mac to download the beta” when trying to download the update?

5
italian food san antonio

Italian Food in San Antonio: Discover the Best Spots for Authentic Italian Cuisine

November 2, 2024
GymKit and Apple Watch

GymKit and Apple Watch: A Perfect Pair for Effective Workouts

December 8, 2023
Apple iOS 17.1.2 Unleashed: Discover the Latest Update’s Exciting New Features!

Apple iOS 17.1.2 Unleashed: Discover the Latest Update’s Exciting New Features!

December 2, 2023
CPLC Mobile Check

How To Do CPLC Mobile Check Step-By-Step Guide

December 2, 2023
  • About
  • Advertise
  • Privacy & Policy
  • Contact

© 2023 iOS Lift All Rights Reserved Umair Ahmed.

No Result
View All Result
  • JailBreakMe
  • Services
  • Paid Services
  • MacOS Profile Download
    • TvOS Profile Confiuration
    • TVPROfileOS
    • WatchOS Profile Configuration
  • Privacy Policy
  • Contact Us
  • About

© 2023 iOS Lift All Rights Reserved Umair Ahmed.

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms below to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In
x

Deprecated: Directive 'allow_url_include' is deprecated in Unknown on line 0