Jiskha Homework Help
SATURDAY
November 21, 2009
SCHOOL SUBJECTS
- Art
- Business
- Computers
- English
- Foreign Languages
- Health
- Home Economics
- Math
- Music
- Physical Education
- Science
- Social Studies
GRADE LEVELS
- Preschool
- Kindergarten
- Elementary School
- 1st Grade
- 2nd Grade
- 3rd Grade
- 4th Grade
- 5th Grade
- 6th Grade
- 7th Grade
- 8th Grade
- High School
- 9th Grade
- 10th Grade
- 11th Grade
- 12th Grade
- College
- Adult Education
Post a New Question | Current Questions | Chat With Live Tutors

Homework Help Forum: computers

Posted by su on Sunday, October 4, 2009 at 6:17pm.

How can you write a sorting algorithm for three intergers in simple english terms before it is translated into C?

  • computers - MathMate, Sunday, October 4, 2009 at 6:35pm

    Do the three integers come in an array or in three distinct variables?

    Can you clarify if the sorting algorithm should work for 3 (and no more) or is it a general algorithm that you are supposed to do?

    A general one is not much more complicated, but requires the use of for-loops.


  • computers - MathMate, Sunday, October 4, 2009 at 6:46pm

    For a general sorting using bubble sort (the simplest and the slowest):

    N=number of items
    A(i)=item i from array A

    loop i from 1 to N-1
    loop j from i+1 to N
    if(A(i)>A(j)) exchange A(i) and A(j)
    end loop j
    end loop i

Answer this Question

First Name:
School Subject:
Answer:

SEARCH

COMMUNITY
FEATURES
- Live Tutors
- Net Riddle
- Reference
- Search