Home Answers Viewqa Java-Beginners Need help in constructing bubble sort

 
 


francis mag
Need help in constructing bubble sort
2 Answer(s)      10 months ago
Posted in : Java Beginners

using a bubble sort, for each entry in the array, display the original index of the first dimension, the second dimension's value, and the first dimension's value on a single line separated by : (colon) sorted by the second dimension.

I already got the two dimensional array figured out just couldnt dont know how to plug in the bubble sort. Thanks in advace

View Answers

July 14, 2012 at 10:52 PM


1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
public class BubbleSort {

 /**
  * @Author : Chandrasekhara Kota
  * @Date   : 17-December-2011
  */
 public static void main(String[] args) {
         // TODO Auto-generated method stub
         int num[]={4,1,9,5,2,8,10};
         for(int i=0;i<num.length;i++)
        {
              for(int y=0;y<num.length-1;y++)
             {
                   if(num[y]>num[y+1])
                  {
                        int temp=num[y+1];
                        num[y+1]=num[y];
                        num[y]=temp;
                  }
             }
         }
        System.out.println("Sorted Data is :");
        for(int i=0;i<num.length;i++)
       {
            System.out.print(" "+num[i]);
        }
 }

}









Related Pages:
Need help in constructing bubble sort
Need help in constructing bubble sort  using a bubble sort, for each entry in the array, display the original index of the first dimension... array figured out just couldnt dont know how to plug in the bubble sort
bubble sort
bubble sort  write a program in java using bubble sort
bubble sort
bubble sort  how to calculate the number of passes in bubble sort
Need help in constructing a 2 dimensionla array?
Need help in constructing a 2 dimensionla array?  Construct a 2 dimensional array that for each entry in the array, display the index of the first dimension data entered, the second dimension's value of the data entered
need help with two dimensional array that takes input from user and bubble sorts and selections sorts
need help with two dimensional array that takes input from user and bubble sorts and selections sorts  I can get both of the sorts figured out but i... that performs Bubble Sort using 2 d array. public class BubbleSortWith2D
bubble sort - Java Beginners
bubble sort  how to write program The bubble-sort algorithm in double...  Hi friend, Bubble Sort program : public class...[] = {10,5,3,89,110,120,1,8,2,12}; System.out.println("Values Before the sort:\n
Bidirectional Bubble Sort in Java
Bidirectional Bubble Sort in Java       Introduction : Bidirectional Bubble Sort... of an array using bi-directional bubble sort. Definition: A alternative of bubble
Bubble Sort in Java
Bubble Sort aka exchange sort in Java is used to sort integer values... are needed. Bubble Sort is a slow and lengthy way to sort elements. Example of Bubble Sort in Java: public class BubbleSort { public static void main(String
Need in desperate help in writing a console program
Need in desperate help in writing a console program  Write a console...: Bubble Sorted using a bubble sort, for each entry in the array, display... dimension. display: Selection Sorted using a selection sort, for each entry
Need in desperate help in writing a console program
Need in desperate help in writing a console program  Write a console...: Bubble Sorted using a bubble sort, for each entry in the array, display... dimension. display: Selection Sorted using a selection sort, for each entry
Need in desperate help in writing a console program
Need in desperate help in writing a console program  Write a console...: Bubble Sorted using a bubble sort, for each entry in the array, display... dimension. display: Selection Sorted using a selection sort, for each entry
Constructing Application of Java
Constructing Application of Java   Hi,I am doing project on java as front end and database as back end.I completed it almost on my computer but now I... code into jar file.How to do it?Please help me.I am using Net Beans
write a progam for bubble sort using file read nd write?
write a progam for bubble sort using file read nd write?  hi, please give the code
Bubble Sorting in Java
are going to sort integer values of an array using bubble sort. Bubble sort is also known as exchange sort. Bubble sort is a simplest sorting algorithm. In bubble sort algorithm array is traversed from 0 to the length-1
Sort
Sort  Hi i would really be thankful if someone could help me with this A program is required to ask users to rate the Java programming language using a number in the range 0 - 10. The data input is ended by entering -1. After
Bubble Sorts
that all students are expected to understand to some extent. Bubble Sort -- fixed number of passes This version of bubble sort makes a fixed number of passes...; } } } } Bubble Sort -- stop when no exchanges This version of bubble sort
Java insertion sort question
Java insertion sort question  I've got another program that I need help with. I am trying to write a Java method that accepts an array of strings, and sorts the strings using the insertion sort algorithm. Then I need to write
buble sort
buble sort  ascending order by using Bubble sort programm   Java BubbleSort Example
Java Dictionary-Sort,Extract
Java Dictionary-Sort,Extract  *I need to make an English(other...;then using that text file I need to sort the words collected in alphabetical order... that when a word is look up time of lookup will be fast is a hard. Please help
search and sort techniques in java
search and sort techniques in java  Hi i attened an interview... any utility methods .....i could answer few but not all..i need datalied code of all these searchings and sortings in java...please help... Regards, Anugnya
Help With Costructing Selection sort?
Help With Costructing Selection sort?  Using a selection sort, for each entry in the array, display the original index of the first dimension... in advance!   Please visit the following link: Java Selection Sort
Sort the element find mean
Sort the element find mean  Hi Friend, I want to find meaning..., 65, 63, 33, In this example we need mean of 65,52,50,68,65,63. I am developing this program in java..Please help me to solve this problem ASAP
sort table by dropbox entry
sort table by dropbox entry  Hi All, I current have the following.... The dropdown pulls its data from another dedicated table(works) but I need an OnCHANGE..... can this be done dynamically or with a page reload??? Any help gratefully
Need help
Need help  Hello... I need some help I have a method which contains 1 string value and i wnat when this method get called den that string value should b assigned as array name.. for example.. i have a method name() which
Need help
Need help  Hello... I need some help I have a method which contains 1 string value and i wnat when this method get called den that string value should b assigned as array name.. for example.. i have a method name() which
Need help
Need help  Dear sir, I have a problem. How to write JSP coding, if a user select a value from drop down list for example department, the another drop.... This name list should get from the database. Please help me. By the way, I'm
Need help with this!
Need help with this!  Can anyone please help me... to a file at all at this time. Any help would be greatly appreciated, thank you... to effectivly end the loop with out the need to break it. for(i=(0); i <
Heap Sort in Java
Heap Sort in Java is used to sort integer values of an array. Like quicksort, insertion sort, bubble sort and other sorting methods, heap sort is used to sort an unsorted list. When compared to other sorting methods heap sort
need
need  i need a jsp coding based project plz help me
Merge Sort Java
Merge Sort in Java is used to sort integer values of an array. There are many methods to sort Java like bubble sort, insertion sort, selection sort, etc. In Merge sort unsorted values are divided into two equal parts
Quick Sort in Java
Quick sort in Java is used to sort integer values of an array. It is a comparison sort. Quick sort is one of the fastest and simplest sorting algorithm in comparison to other sorting algorithms like bubble sort, insertion sort, heap
Please help with this code
Please help with this code  I need some help getting the Search method below to work with the menu, and I also cannot figure out how to get my bubble...; } } return false; } // !Bubble sort goes here
Need Help on JMS - JMS
Need Help on JMS   Hi, In my application i need to create my own ques and my own QueueConnectionFactory..... Plz tell me how to create the same... Any help is appriciated,.. Thanks in advance
Need help with nested queries
Need help with nested queries  Hello, Table1 has "id", "votes" columns. Table2 has "id", "Name" column. I need to retrieve Name and its corresponging Votes. I tried with nested queries but its confusing. Can anyone please help
need help please
need help please  Dear sir, my name is logeswaran. I have a big problem that I can't find the solution for a program. How can I block a user from enter a page second time. Please help me. By the way I'm using Access database
Need Help in Java programming
Need Help in Java programming  Hello. Can someone please help me with writing the following program Java program that gives assignment details such as:assignment number,assignment name,due date,submission date,percentage marks
need help to create applet
need help to create applet  Can u help me..?? I get a task ...and i dont know how to make it... So I hope that u can help me... Here is the task... If u can help me, then please send it to my email lcfahmi90@yahoo.com http
Insertion Sort Applet
Insertion Sort Applet  Please All , I need Insertion sort applet program
Insertion Sort Applet
Insertion Sort Applet  I need Insertion Sort Applet code was design by Dr. Daniel Liang Please
insertion sort applet code
insertion sort applet code  i need Insertion Sort Applet Program
Need help on JAVA JSP
Need help on JAVA JSP  Hi, I have never worked on java and I have been given an assignment where I have to fix existing issues in the tool(created...(need to know how I can adjust it based on the cureen system's screen resolution
Need some help urgently
Need some help urgently  Can someone please help me with this below question. I need to write a class for this. If you roll Y standard six-sided dice... need to write a class for this where X and Y are passed as parameter. If someone
hello there i need help
hello there i need help  : i need to do a program like... i am a beginner, and aside from that i am really eager to learn java please help me with the codes and please explain to me how it works. i only need to use
Need help with console program?
Need help with console program?  Write a console program that repeatedly prompts the user to enter data until they type done (any case, Upper, Lower, or Mixed). thanks in advance.   Here is an example that repeatedly
Need Help With This Scenario
Need Help With This Scenario  The bonnet of a car is opened to determine if there is anything wrong with the engine. Firstly, the radiator water is checked. If the radiator water is below the minimum indicator level
Need Help With This Scenario
Need Help With This Scenario  The bonnet of a car is opened to determine if there is anything wrong with the engine. Firstly, the radiator water is checked. If the radiator water is below the minimum indicator level
Need Help - Java Beginners
Need Help  Hello Sir, Am a beginner of Java. Also i did course on J2EE... but dont have any ideas about real time projects. But i want to do some projects in Java as well as J2EE... Can u help me and guide to do a project
i need a help in this please
i need a help in this please  The factorial of a nonnegative integer n is written n! (pronounced â?? n factorialâ??) and is defined as follows: n!=n . (n-1) . (n-2) . .... . 1 (for values of n greater than or equal to 1) and n!=1
Need Help on the script
Need Help on the script  hello there, My name is Femi and am a web developer using php. am working on a project. and am having some difficulties. i dont know if you can help me out with it. The platform am building will receive
need help - Java Beginners
need help  Need help in programming in Java  Simple java program that will show the output within quotes using system.out.println();DISPLAYING OUPUT " * " ," *** " ........I used System.out.print

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.