Continue to Site

### Welcome to EDAboard.com

#### Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Status
Not open for further replies.

#### mail4idle2

##### Full Member level 4
I have a block which compares and gives the smaller and Larger number of 2 numbers.
Using above block, when 4 numbers are given as inputs, produce the outputs in ascending order. How ?

Thanks

:-)

### :-)

Points: 2
Is my question not clear ?

Given:
a block which compares and gives the smaller and Larger number of 2 numbers....

Goal:
when 4 numbers are given as inputs, produce the outputs in ascending order....
Solution:
Assuming the numbers to be sorted are 7,1,3,6

Step 1: Take the first two numbers 7 and 1. Using your so called "block" gives smaller number as 1 and big number as 7. So swap the two numbers we get sequence as 1, 7, 3, 6.

step 2: Now move to numbers 7 and 3, give this as input to your block. big number is 7 and small is 3. So replace the positon of two numbers we get sequence as 1, 3, 7, 6.

step 3: Give the input to the block next two numbers 7 and 6. find which is greater and smaller. swap it to give the output 1,3,6,7.

Output:
Using your block we have sorted the given sequence in ascending order 1, 3, 6,7.

:-)

### :-)

Points: 2

Given:

Goal:

Solution:
Assuming the numbers to be sorted are 7,1,3,6

Step 1: Take the first two numbers 7 and 1. Using your so called "block" gives smaller number as 1 and big number as 7. So swap the two numbers we get sequence as 1, 7, 3, 6.

step 2: Now move to numbers 7 and 3, give this as input to your block. big number is 7 and small is 3. So replace the positon of two numbers we get sequence as 1, 3, 7, 6.

step 3: Give the input to the block next two numbers 7 and 6. find which is greater and smaller. swap it to give the output 1,3,6,7.

Output:
Using your block we have sorted the given sequence in ascending order 1, 3, 6,7.

Thanks for step by step bubble sort example... made it clear.

Status
Not open for further replies.