SlideShare ist ein Scribd-Unternehmen logo
1 von 11
University Institute of Information Technology, PMAS-AAUR
Lecture 10: Programming Fundamentals:2012Lecture 01: Programming Fundamentals
Lecture 10
Sorting
1
University Institute of Information Technology, PMAS-AAUR
Lecture 10: Programming Fundamentals:2012
Sorting Arrays
• The process of arranging the values of an array
in particular order is called sorting.
• Two Types of sorting:
• Ascending Order: The smallest value is stored in the
first location of an array. The largest value is stored at
the last position of an array.
15 25 33 47 51
• Descending Order: The largest value is stored in the first
location of an array. The smallest value is stored at the
last position of an array.
51 47 33 25 15
2
University Institute of Information Technology, PMAS-AAUR
Lecture 10: Programming Fundamentals:2012
3
Given an array of length n,
– Search elements 0 through n-1 and select the smallest
• Swap it with the element in location 0
– Search elements 1 through n-1 and select the smallest
• Swap it with the element in location 1
– Search elements 2 through n-1 and select the smallest
• Swap it with the element in location 2
– Search elements 3 through n-1 and select the smallest
• Swap it with the element in location 3
– Continue in this fashion until there’s nothing left to
search
University Institute of Information Technology, PMAS-AAUR
Lecture 10: Programming Fundamentals:2012
4
Example and analysis of selection sort
• The selection sort might swap an
array element with itself--this is
harmless, and not worth checking
for
• Analysis:
– The outer loop executes n-1 times
– The inner loop executes about n/2
times on average (from n to 2
times)
– Work done in the inner loop is
constant (swap two array
elements)
– Time required is roughly (n-
1)*(n/2)
– You should recognize this as O(n2)
7 2 8 5 4
2 7 8 5 4
2 4 8 5 7
2 4 5 8 7
2 4 5 7 8
University Institute of Information Technology, PMAS-AAUR
Lecture 10: Programming Fundamentals:2012
Selection Sort
Program that take 5 random values from user
in an array and sort it in ascending order.
5
University Institute of Information Technology, PMAS-AAUR
Lecture 10: Programming Fundamentals:2012
int array[5], i, j, temp;
cout<< "Enter five integers" << endl;
for(i=0; i<5; i++)
{
cin>>array[i];
}
cout<<"The array in Actual Order n"<<endl;
for(i=0; i<5; i++)
{
cout<<array[i]<<" ";
}
for(i=0; i<5; i++)
for(j=i+1; j<5; j++)
if(array[i]>array[j])
{
temp = array[i];
array[i] = array[j];
array[j] = temp;
}
cout<<endl;
cout<<"The array in Sorted Ordern ";
for(i=0; i<5; i++)
{
cout<<array[i]<<" ";
}
getch();
}
6
University Institute of Information Technology, PMAS-AAUR
Lecture 10: Programming Fundamentals:2012
Bubble Sort
• In the bubble sort, as elements are sorted they
gradually "bubble" (or rise) to their proper
location in the array, like bubbles rising in a glass
of soda.
• The bubble sort repeatedly compares adjacent
elements of an array.
– The first and second elements are compared and swapped if out
of order.
– Then the second and third elements are compared and swapped
if out of order.
– This sorting process continues until the last two elements of the
array are compared and swapped if out of order.
7
University Institute of Information Technology, PMAS-AAUR
Lecture 10: Programming Fundamentals:2012
• When this first pass through the array is complete,
the bubble sort returns to elements one and two
and starts the process all over again.
• So, when does it stop?
• The bubble sort knows that it is finished when it examines
the entire array and no "swaps" are needed (thus the list is
in proper order).
• The bubble sort keeps track of occurring swaps by the use
of a flag.
8
University Institute of Information Technology, PMAS-AAUR
Lecture 10: Programming Fundamentals:2012
• The table below follows an array of numbers before,
during, and after a bubble sort for descending order.
• A "pass" is defined as one full trip through the array
comparing and if necessary, swapping, adjacent
elements.
• Several passes have to be made through the array
before it is finally sorted.
9
Array at beginning: 84 69 76 86 94 91
After Pass #1: 84 76 86 94 91 69
After Pass #2: 84 86 94 91 76 69
After Pass #3: 86 94 91 84 76 69
After Pass #4: 94 91 86 84 76 69
After Pass #5 (done): 94 91 86 84 76 69
University Institute of Information Technology, PMAS-AAUR
Lecture 10: Programming Fundamentals:2012
Program that take 5 random values from user
in an array and sort it in ascending order,
using bubble sort.
10
University Institute of Information Technology, PMAS-AAUR
Lecture 10: Programming Fundamentals:2012
main()
{
int array[5], i, j, temp;
cout<< "Enter five integers" << endl;
for(i=0; i<5; i++)
{
cin>>array[i];
}
cout<<"The array in Actual Order n"<<endl;
for(i=0; i<5; i++)
{
cout<<array[i]<<" ";
}
for(i=0; i<5; i++)
for(j=0; j<4; j++)
if(array[j]>array[j+1])
{
temp = array[j];
array[j] = array[j+1];
array[j+1] = temp;
}
cout<<endl;
cout<<"The array in Sorted Ordern ";
for(i=0; i<5; i++)
{
cout<<array[i]<<" ";
}
getch();
} 11

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Array
ArrayArray
Array
 
Linked List
Linked ListLinked List
Linked List
 
Array in c++
Array in c++Array in c++
Array in c++
 
Arrays In C++
Arrays In C++Arrays In C++
Arrays In C++
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array ppt
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
 
Conversion of Infix to Prefix and Postfix with Stack
Conversion of Infix to Prefix and Postfix with StackConversion of Infix to Prefix and Postfix with Stack
Conversion of Infix to Prefix and Postfix with Stack
 
Arrays
ArraysArrays
Arrays
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
 
Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursion
 
Data Structures- Part7 linked lists
Data Structures- Part7 linked listsData Structures- Part7 linked lists
Data Structures- Part7 linked lists
 
Array
ArrayArray
Array
 
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 Data Structures - Lecture 9 [Stack & Queue using Linked List] Data Structures - Lecture 9 [Stack & Queue using Linked List]
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 
Data Structures - Lecture 7 [Linked List]
Data Structures - Lecture 7 [Linked List]Data Structures - Lecture 7 [Linked List]
Data Structures - Lecture 7 [Linked List]
 
concept of Array, 1D & 2D array
concept of Array, 1D & 2D arrayconcept of Array, 1D & 2D array
concept of Array, 1D & 2D array
 
Doubly & Circular Linked Lists
Doubly & Circular Linked ListsDoubly & Circular Linked Lists
Doubly & Circular Linked Lists
 
Queue in Data Structure
Queue in Data Structure Queue in Data Structure
Queue in Data Structure
 
Arrays in java
Arrays in javaArrays in java
Arrays in java
 
2D Array
2D Array 2D Array
2D Array
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
 

Ähnlich wie Array sorting

QUEUE in data-structure (classification, working procedure, Applications)
QUEUE in data-structure (classification, working procedure, Applications)QUEUE in data-structure (classification, working procedure, Applications)
QUEUE in data-structure (classification, working procedure, Applications)
Mehedi Hasan
 
Data Structures in C
Data Structures in CData Structures in C
Data Structures in C
Jabs6
 
jn;lm;lkm';m';;lmppt of data structure.pdf
jn;lm;lkm';m';;lmppt of data structure.pdfjn;lm;lkm';m';;lmppt of data structure.pdf
jn;lm;lkm';m';;lmppt of data structure.pdf
VinayNassa3
 

Ähnlich wie Array sorting (20)

Data Structures 6
Data Structures 6Data Structures 6
Data Structures 6
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
QUEUE in data-structure (classification, working procedure, Applications)
QUEUE in data-structure (classification, working procedure, Applications)QUEUE in data-structure (classification, working procedure, Applications)
QUEUE in data-structure (classification, working procedure, Applications)
 
lecture-k-sorting.ppt
lecture-k-sorting.pptlecture-k-sorting.ppt
lecture-k-sorting.ppt
 
3.ppt
3.ppt3.ppt
3.ppt
 
Lecture k-sorting
Lecture k-sortingLecture k-sorting
Lecture k-sorting
 
Data Structures in C
Data Structures in CData Structures in C
Data Structures in C
 
Data Structure (MC501)
Data Structure (MC501)Data Structure (MC501)
Data Structure (MC501)
 
Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)
 
Data Structures 2
Data Structures 2Data Structures 2
Data Structures 2
 
Bubble Sort algorithm in Assembly Language
Bubble Sort algorithm in Assembly LanguageBubble Sort algorithm in Assembly Language
Bubble Sort algorithm in Assembly Language
 
Queues
QueuesQueues
Queues
 
Data Structures and Algorithm - Week 11 - Algorithm Analysis
Data Structures and Algorithm - Week 11 - Algorithm AnalysisData Structures and Algorithm - Week 11 - Algorithm Analysis
Data Structures and Algorithm - Week 11 - Algorithm Analysis
 
Basic Sorting algorithms csharp
Basic Sorting algorithms csharpBasic Sorting algorithms csharp
Basic Sorting algorithms csharp
 
Iare ds ppt_3
Iare ds ppt_3Iare ds ppt_3
Iare ds ppt_3
 
jn;lm;lkm';m';;lmppt of data structure.pdf
jn;lm;lkm';m';;lmppt of data structure.pdfjn;lm;lkm';m';;lmppt of data structure.pdf
jn;lm;lkm';m';;lmppt of data structure.pdf
 
Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures
 
Lecture 11.2 : sorting
Lecture 11.2 :  sortingLecture 11.2 :  sorting
Lecture 11.2 : sorting
 
Searching and sorting Techniques in Data structures
Searching and sorting Techniques in Data structuresSearching and sorting Techniques in Data structures
Searching and sorting Techniques in Data structures
 
DSJ_Unit I & II.pdf
DSJ_Unit I & II.pdfDSJ_Unit I & II.pdf
DSJ_Unit I & II.pdf
 

Mehr von ALI RAZA

Programming Fundamentals using C++
Programming Fundamentals using C++Programming Fundamentals using C++
Programming Fundamentals using C++
ALI RAZA
 
Introduction to Programming
Introduction to ProgrammingIntroduction to Programming
Introduction to Programming
ALI RAZA
 
Introduction to Programming
Introduction to ProgrammingIntroduction to Programming
Introduction to Programming
ALI RAZA
 
Dil hua kirchi kirchi by mohammad iqbal shams
Dil hua kirchi kirchi by mohammad iqbal shamsDil hua kirchi kirchi by mohammad iqbal shams
Dil hua kirchi kirchi by mohammad iqbal shams
ALI RAZA
 
Pathar kar-do-ankh-mein-ansu-complete
Pathar kar-do-ankh-mein-ansu-completePathar kar-do-ankh-mein-ansu-complete
Pathar kar-do-ankh-mein-ansu-complete
ALI RAZA
 

Mehr von ALI RAZA (20)

Structure
StructureStructure
Structure
 
Recursion
RecursionRecursion
Recursion
 
pseudocode and Flowchart
pseudocode and Flowchartpseudocode and Flowchart
pseudocode and Flowchart
 
Algorithm Development
Algorithm DevelopmentAlgorithm Development
Algorithm Development
 
Programming Fundamentals using C++
Programming Fundamentals using C++Programming Fundamentals using C++
Programming Fundamentals using C++
 
Introduction to Programming
Introduction to ProgrammingIntroduction to Programming
Introduction to Programming
 
Introduction to Programming
Introduction to ProgrammingIntroduction to Programming
Introduction to Programming
 
Array programs
Array programsArray programs
Array programs
 
2D-Array
2D-Array 2D-Array
2D-Array
 
Quiz game documentary
Quiz game documentaryQuiz game documentary
Quiz game documentary
 
Function pass by value,function pass by reference
Function pass by value,function pass by reference Function pass by value,function pass by reference
Function pass by value,function pass by reference
 
Drug Addiction 39 Slides
Drug Addiction 39 SlidesDrug Addiction 39 Slides
Drug Addiction 39 Slides
 
Drug Addiction Original 51 Slides
Drug Addiction Original 51 SlidesDrug Addiction Original 51 Slides
Drug Addiction Original 51 Slides
 
Passing stuctures to function
Passing stuctures to functionPassing stuctures to function
Passing stuctures to function
 
Basic general knowledge
Basic general knowledgeBasic general knowledge
Basic general knowledge
 
Dil hua kirchi kirchi by mohammad iqbal shams
Dil hua kirchi kirchi by mohammad iqbal shamsDil hua kirchi kirchi by mohammad iqbal shams
Dil hua kirchi kirchi by mohammad iqbal shams
 
Pathar kar-do-ankh-mein-ansu-complete
Pathar kar-do-ankh-mein-ansu-completePathar kar-do-ankh-mein-ansu-complete
Pathar kar-do-ankh-mein-ansu-complete
 
Husne akhlaq
Husne akhlaqHusne akhlaq
Husne akhlaq
 
Parts of speech sticky note definitions and examples
Parts of speech sticky note definitions and examplesParts of speech sticky note definitions and examples
Parts of speech sticky note definitions and examples
 
Quik tips
Quik tipsQuik tips
Quik tips
 

Kürzlich hochgeladen

Kürzlich hochgeladen (20)

How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 

Array sorting

  • 1. University Institute of Information Technology, PMAS-AAUR Lecture 10: Programming Fundamentals:2012Lecture 01: Programming Fundamentals Lecture 10 Sorting 1
  • 2. University Institute of Information Technology, PMAS-AAUR Lecture 10: Programming Fundamentals:2012 Sorting Arrays • The process of arranging the values of an array in particular order is called sorting. • Two Types of sorting: • Ascending Order: The smallest value is stored in the first location of an array. The largest value is stored at the last position of an array. 15 25 33 47 51 • Descending Order: The largest value is stored in the first location of an array. The smallest value is stored at the last position of an array. 51 47 33 25 15 2
  • 3. University Institute of Information Technology, PMAS-AAUR Lecture 10: Programming Fundamentals:2012 3 Given an array of length n, – Search elements 0 through n-1 and select the smallest • Swap it with the element in location 0 – Search elements 1 through n-1 and select the smallest • Swap it with the element in location 1 – Search elements 2 through n-1 and select the smallest • Swap it with the element in location 2 – Search elements 3 through n-1 and select the smallest • Swap it with the element in location 3 – Continue in this fashion until there’s nothing left to search
  • 4. University Institute of Information Technology, PMAS-AAUR Lecture 10: Programming Fundamentals:2012 4 Example and analysis of selection sort • The selection sort might swap an array element with itself--this is harmless, and not worth checking for • Analysis: – The outer loop executes n-1 times – The inner loop executes about n/2 times on average (from n to 2 times) – Work done in the inner loop is constant (swap two array elements) – Time required is roughly (n- 1)*(n/2) – You should recognize this as O(n2) 7 2 8 5 4 2 7 8 5 4 2 4 8 5 7 2 4 5 8 7 2 4 5 7 8
  • 5. University Institute of Information Technology, PMAS-AAUR Lecture 10: Programming Fundamentals:2012 Selection Sort Program that take 5 random values from user in an array and sort it in ascending order. 5
  • 6. University Institute of Information Technology, PMAS-AAUR Lecture 10: Programming Fundamentals:2012 int array[5], i, j, temp; cout<< "Enter five integers" << endl; for(i=0; i<5; i++) { cin>>array[i]; } cout<<"The array in Actual Order n"<<endl; for(i=0; i<5; i++) { cout<<array[i]<<" "; } for(i=0; i<5; i++) for(j=i+1; j<5; j++) if(array[i]>array[j]) { temp = array[i]; array[i] = array[j]; array[j] = temp; } cout<<endl; cout<<"The array in Sorted Ordern "; for(i=0; i<5; i++) { cout<<array[i]<<" "; } getch(); } 6
  • 7. University Institute of Information Technology, PMAS-AAUR Lecture 10: Programming Fundamentals:2012 Bubble Sort • In the bubble sort, as elements are sorted they gradually "bubble" (or rise) to their proper location in the array, like bubbles rising in a glass of soda. • The bubble sort repeatedly compares adjacent elements of an array. – The first and second elements are compared and swapped if out of order. – Then the second and third elements are compared and swapped if out of order. – This sorting process continues until the last two elements of the array are compared and swapped if out of order. 7
  • 8. University Institute of Information Technology, PMAS-AAUR Lecture 10: Programming Fundamentals:2012 • When this first pass through the array is complete, the bubble sort returns to elements one and two and starts the process all over again. • So, when does it stop? • The bubble sort knows that it is finished when it examines the entire array and no "swaps" are needed (thus the list is in proper order). • The bubble sort keeps track of occurring swaps by the use of a flag. 8
  • 9. University Institute of Information Technology, PMAS-AAUR Lecture 10: Programming Fundamentals:2012 • The table below follows an array of numbers before, during, and after a bubble sort for descending order. • A "pass" is defined as one full trip through the array comparing and if necessary, swapping, adjacent elements. • Several passes have to be made through the array before it is finally sorted. 9 Array at beginning: 84 69 76 86 94 91 After Pass #1: 84 76 86 94 91 69 After Pass #2: 84 86 94 91 76 69 After Pass #3: 86 94 91 84 76 69 After Pass #4: 94 91 86 84 76 69 After Pass #5 (done): 94 91 86 84 76 69
  • 10. University Institute of Information Technology, PMAS-AAUR Lecture 10: Programming Fundamentals:2012 Program that take 5 random values from user in an array and sort it in ascending order, using bubble sort. 10
  • 11. University Institute of Information Technology, PMAS-AAUR Lecture 10: Programming Fundamentals:2012 main() { int array[5], i, j, temp; cout<< "Enter five integers" << endl; for(i=0; i<5; i++) { cin>>array[i]; } cout<<"The array in Actual Order n"<<endl; for(i=0; i<5; i++) { cout<<array[i]<<" "; } for(i=0; i<5; i++) for(j=0; j<4; j++) if(array[j]>array[j+1]) { temp = array[j]; array[j] = array[j+1]; array[j+1] = temp; } cout<<endl; cout<<"The array in Sorted Ordern "; for(i=0; i<5; i++) { cout<<array[i]<<" "; } getch(); } 11