HTTP://WWW.COMPUTER-WORLD1.COM

Computer World
Computer World
Computer World
Computer World
Computer World
Computer World
Computer World
Computer World
Computer World
Computer World
Computer World
Computer World
Computer World
Computer World
Computer World
Computer World
Computer World
Computer World
Computer World
Computer World
Computer World
Computer World
Computer World
Computer World
Computer World
Computer World
Computer World
Computer World
Computer World
Computer World


The Web Ask
 


 
Computer Information
MENU  
  COMPUTER HELP
  Computing Notes
  => 1 Introduction To Computing
  => 1.1 Computer Hardware
  => 1.2 Computer Software
  => 1.3 The Human-Computer Interface
  => 1.4 Business Information Systems
  => 1.5 Batch Processing
  => 2 Word Processing
  => 2.1 Introduction
  => 2.2 Editing Facilities
  => 2.3 Bullets And Numbering
  => 2.4 Layout Facilities
  => 2.5 Headers And Footers
  => 2.6 Style Controls
  => 2.7 Spelling And Grammar Checking
  => 2.8 Inserting Columns
  => 2.9 Borders And Shading
  => 2.10 Tables
  => 2.11 Inserting Graphics
  => 2.12 Mail Merging
  => 2.13 Macros
  => 3 Programming In QuickBASIC
  => 3.1 Introduction
  => 3.2 Variables, Input And Output
  => 3.3 Arithmetic Operators
  => 3.4 Iteration
  => 3.5 Selection
  => 3.6 Functions
  => 3.7 Subprograms
  => 3.8 Recursion
  => 3.9 Arrays
  => 3.10 Program Structure
  => 3.11 Jackson Structure Diagrams
  => 3.12 String Processing
  => 4 Data Representation
  => 4.1 Different Computer Codes
  => 4.2 Binary Integers
  => 4.3 Higher Number Bases
  => 4.4 Graphics, Sounds And Other Interpretations
  => 4.5 Fixed Point Binary Numbers
  => 4.6 Floating Point Binary Numbers
  => 4.7 Range And Accuracy
  => 5 Spreadsheets
  => 5.1 Introduction
  => 5.2 General Features
  => 5.3 "What If" Calculations
  => 5.4 Changing The Workbook's Appearance
  => 5.5 Relative And Absolute Reference
  => 5.6 Sorting And Filters
  => 5.7 Charts
  => 5.8 Lookup
  => 5.9 The IF Function
  => 5.10 Goal Seeker
  => 5.11 Solver
  => 5.12 Macros
  => 6 Files
  => 6.1 File Concepts
  => 6.2 Serial & Sequential Files
  => 6.3 Indexed Sequential Files
  => 6.4 Random Access Files
  => 6.5 Overview of File Processing
  => 7 Standard Algorithms
  => 7.1 Linear Searches
  => 7.2 Binary Search
  => 7.3 Internal Sorting
  => 7.4 External Sorting
  => 8 Legal Issues And Data Security
  => 8.1 The Computer Missuse Act 1990
  => 8.2 The Data Protection Act 1984
  => 8.3 Computer Fraud
  => 8.4 Software Copyright
  => 8.5 Viruses And Trojans
  => 8.6 Security Of Data
  => 8.7 Data Integrity
  => 9 Databases
  => 9.1 Flat-file Databases
  => 9.2 Introduction To Relational Databases
  => 9.3 The Aims Of Database Normalisation
  => 9.4 Security And Integrity Issues
  => 9.5 Database Management
  => 10 Data Structures
  => 10.1 Introduction
  => 10.2 Linear Lists
  => 10.3 Linked Lists
  => 10.4 Queues
  => 10.5 Stacks
  => 10.6 Binary Trees
  => 11 Systems Development
  => 11.1 Introduction
  => 11.2 Analysis
  => 11.3 Design
  => 11.4 Graphical System Representation
  => 11.5 Development
  => 11.6 Testing
  => 11.7 Implementation
  => 11.8 Maintenance
  => 11.9 System Documentation
  => 12 Peripherals
  => 12.1 Input Devices
  => 12.2 Output Devices
  => 12.3 Storage Devices
  => 13 Computer Architecture
  => 13.1 The Processor And Memory
  => 13.2 The Fetch-Execute Cycle
  => 13.3 Data Buses
  => 13.4 Processing Architectures
  => 13.5 Assembly Language
  => 14 Translation
  => 14.1 Interpreters
  => 14.2 Compilers
  => 14.3 Compilation Phases
  => 14.4 Assemblers
  => 15 Operating Systems
  => 15.1 Operating System Functions
  => 15.2 Different OS Modes
  => 15.3 Job Control Language
  => 15.4 The Scheduler And Dispatcher
  => 15.5 Memory Management
  => 15.6 Peripheral Control
  => 15.7 Backing Store Management
  => 16 High Level Programming
  => 16.1 High And Low Level Languages
  => 16.2 Language Classification
  => 16.3 Language Generations
  => 16.4 Logic Programming
  => 16.5 Choosing A Programming Language
  => 17 Computers & Communication
  => 17.1 Data Transmission
  => 17.2 Local Area Networks
  => 17.3 Wide Area Networks
  => 17.4 The Internet
  बातमी वाचु शकता
  जनरल नॉलेज
  HELPLINE
  GALLERY
  Calculators and Converters
  Zoo Animal Photos
  Short form list
  LOGIN
  HOME
  CONTACT
  CHAT ME !!!
  INTRODUCTION
  SUBMIT URLs
  ADD OWN LINK
  Banner Exchange
  IPL T20 Live Scores
  NATIONAL ANTHEM OF INDIA
  Birthday Reminder
  FUNNY PAGE
  TOP LIST
  MAP AND SATELLITE IMAGE
  Your IP Address
  MOBILE WAP SETTINGS
  INDEX



Bookmark and Share



Online Reference
Dictionary, Encyclopedia & more
Word:
Look in: Dictionary & thesaurus
Medical Dictionary
Legal Dictionary
Financial Dictionary
Acronyms
Idioms
Encyclopedia
Wikipedia
Periodicals
Literature
Other languages:
by:


INDIA
7.3 Internal Sorting
Section 7.3

7 Standard Algorithms

7.3 Internal Sorting

When a file is small enough to be held in the computer's memory an internal sort can be used.

7.3.1 Insertion Sort

In order to convert an unsorted list to a sequential list we can take an item out of the list, shuffle the other items along until a gap appears at the appropriate place and insert our item. This is repeated for all items.

Example

Position: 0 1 2 3 4 5
Value: 5 3 8 6 2

Start with the item in position 2. Take it out of the list to position 0.

Position: 0 1 2 3 4 5
Value: 3 5 8 6 2

Now start just to the left of the gap. Compare each item with the item in position 0 and move it right if it is greater.

Position: 0 1 2 3 4 5
Value: 3 5 8 6 2

Finally insert the item in position 0 in the gap.

Position: 0 1 2 3 4 5
Value: 3 5 8 6 2

The third item is greater than the item in position 2 so nothing has to be done and the number stays in the same position.

Next we move the fourth item into position 0.

Position: 0 1 2 3 4 5
Value: 6 3 5 8 2

We now move the appropriate items right...

Position: 0 1 2 3 4 5
Value: 6 3 5 8 2

and move the item in position zero into the gap.

Position: 0 1 2 3 4 5
Value: 3 5 6 8 2

Now we move the item in position 5 to position 0.

Position: 0 1 2 3 4 5
Value: 2 3 5 6 8

We now move the appropriate items right...

Position: 0 1 2 3 4 5
Value: 2 3 5 6 8

and move the item in position zero into the gap.

Position: 0 1 2 3 4 5
Value: 2 3 5 6 8

Pseudocode

DIM card% (0 TO 5)

READ in the data

FOR position% = 2 TO 5
    card%(0) = card%(position%)
    DO UNTIL card%(movpos%) <= card%(0)
       card%(movpos% + 1) = card%(movpos%)
       movpos% = movpos% - 1
    LOOP
    card%(movpos% + 1) = card%(0)
NEXT position%

7.3.2 Bubble Sort

In this internal sort, adjacent values in a list are compared and swapped if necessary.

Several passes are usually required to sort a list.

1st Pass 6 5 3 2 8
5 6 3 2 8
5 3 6 2 8
5 3 2 6 8
2nd Pass 5 3 2 6 8
3 5 2 6 8
3 2 5 6 8
3rd Pass 3 2 5 6 8
2 3 5 6 8
4th Pass 2 3 5 6 8

On the fourth pass no swaps are made so the sort is complete.

This sort is called a bubble sort because small (or light) numbers 'bubble' to the top.

Pseudocode

DIMension card(1 to n)

READ in data

DO
    swapped = 0
    FOR position = 1
       IF card(position) > card(position + 1) THEN
          swap the cards
          swapped = 1
       END IF
    NEXT position
LOOP UNTIL swapped = 0

7.3.3 Quick Sort

This algorithm is a fast sorting algorithm because it swaps items that are a very large distance apart.

It works by picking a pivot item in the list and then moves every item that is greater to one side and every item that is less is passed to the other side.

The two sub-divisions are then recursively passed one after another to the Quick Sort algorithm.

The loop unravels when the sub-divisions are sorted.

7.3.4 Extraction Sort

When lengthy records or variable length records need to be sorted it is often faster to sort only the key field.

In order to retrieve the full record details a pointer is added to each key field value.


< Previous Back To Topic Next >

COMPUTER-WORLD1  
 
Username:
Password:
 
SHOUTBOX  
 








 
SMS 160by2  
 
Forgot Password / Username

 
VISITS  
 
 
Time  
  free guide to setting up a website
 
Today, there have been 83 visitorson this page!
Matrimony Search Widgets
Matrimony Search


Home
SILICONINDIA FACEBOOK YOUTUBE MYSPACE

HOME :: :: INDEX :: :: COMPUTING NOTES :: ::COMPUTER HELP

This website was created for free with Own-Free-Website.com. Would you also like to have your own website?
Sign up for free