answersLogoWhite

0

/* Bubble sort:

code snippet only

nos to be sorted are in the array named 'n' of size 'N'

for(int i=0;i<N-1;i++)

for(int j=i+1;j<N-1-i;j++)

if(n[j]>n[j+1])

swap(n[j],n[j+1]);

*/

/*

insertion sort

int v,j;

for(int i=1;i<N;i++)

{

v=n[j];

for(int j=i-1;j>0&&n[j]>v;j--)

n[j+1]=n[j];

n[j+1]=v;

}

*/

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

How do you write a C plus plus program that will display the first 10 positive prime numbers?

By learning how to program on C+.


A program c plus plus on automorphic numbers or not?

how to write a program that counts automorphic number from 1 to 999


C program to print numbers 1 to n?

how do we use loops in c plus plus programing and what are basic differences between do,for and while loop


How do you write a c plus plus program to sort a vector of strings using MSD radix sort?

The standard library sort algorithm automatically uses MSD radix to sort strings: std::vector&lt;std::string&gt; vs = {"a", "b", "c" "d", "ab"}; std::sort(vs.begin(), vs.end()); After sorting, the order will be: {"a", "ab", "b", "c", "d"}


Can you program games with c plus plus?

Yes, you can program games with C++.


What is the sort cut for running c plus plus program?

It depends on the particular IDE. Visual Studio uses &lt;Ctrl&gt;F5 to start a program in non-debug mode, and F5 to start a program in debug mode.


Write a c plus plus program to find the largest among three numbers using ternary operators?

R = (A &gt; B &amp;&amp; A &gt; C) ? A : (B &gt; C) ? B : C; // parentheses not necessary - for clarity only


C plus plus program calculate the power value of input base and exponent numbers?

cn = c0 *( 1 + i ) pow n


How to restart c plus plus program?

Exit the program and relaunch it.


Create a c plus plus program that displays odd numbers between 15 and 30?

for (int i = 15; i &lt; 30; i += 2) cout &lt;&lt; i &lt;&lt; endl;


Lint is a compiler b a interactive debugger c a cinterpreter d a tool for analysing c plus plus program?

d a tool for analysing c plus plus program


Types of sort in c plus plus?

There's only one type of sort in C++; std::sort. If you want other types you'll need to write your own.