TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ahmed salah
NA
530
148.7k
what outer loop and inner loop represent in bubble sort
Dec 22 2016 6:13 PM
Hi i work in visual studio 2015 c# console applications .
I try to make bubble sort to array unsorted but i cannot do that
i search for internet about that i understand idea .
it is make comparison between small and largest then swap items to make in order array
but i cannot understand this code .
so that what outer loop represent and inner loop represent ?
red lines for outer loop and inner loop
/*
* C# Program to Perform Bubble Sort
*/
using
System;
class
bubblesort
{
static
void
Main(
string
[] args)
{
int
[] a = { 30, 20, 50, 40, 10 };
int
t;
Console.WriteLine(
"The Array is : "
);
for
(
int
i = 0; i < a.Length; i++)
{
Console.WriteLine(a[i]);
}
for
(
int
j = 0; j <= a.Length - 2; j++)
outer loop
{
for
(
int
i = 0; i <= a.Length - 2; i++)
inner loop
{
if
(a[i] > a[i + 1])
{
t = a[i + 1];
a[i + 1] = a[i];
a[i] = t;
}
}
}
Console.WriteLine(
"The Sorted Array :"
);
foreach
(
int
aray
in
a)
Console.Write(aray +
" "
);
Console.ReadLine();
}
}
Reply
Answers (
1
)
error - add list items to the static class variable C#
How can I Decryption This HashSha256 algorithm?