21. Sorting algorithms on arrays

21. Sorting algorithms on arrays - Philadelphia University...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Philadelphia University Faculty of Information Technology Department of Applied Computer Science A Course for all Scientific Colleges Module: Computer Skills 2 for Scientific Colleges (710104) Section: 2 Lecturer: Dr. Nadia Y. Yousif Examples on Arrays Sorting an Array There are several sorting algorithms that are used to sort arrays of elements in ascending or descending order. The algorithm presented here is the Insertion sort. Definition: Let a 0 , . .., a n -1 be the sequence to be sorted. At the beginning and after each iteration of the algorithm the sequence consists of two parts: the first part a 0 , . .., a i -1 is already sorted, the second part a i , . .., a n -1 is still unsorted ( i 0, . .., n ). In order to insert element a i into the sorted part, it is compared with a i -1 , a i -2 etc. When an element a j with a j a i is found, a i is inserted behind it. If no such element is found, then a i is inserted at the beginning of the sequence. After inserting element
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/23/2011 for the course CHEMICAL E 2 taught by Professor Hibasaadeh during the Spring '11 term at University of Jordan.

Page1 / 2

21. Sorting algorithms on arrays - Philadelphia University...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online