Write a pseudo code for sorting the numbers in an array?

Answer Posted / prabhath

SelectionSort(A)
for i <- length[A]-1 downto 0
for j <- 0 to i
if (A[j]>MAX) // for descending, change this to MIN
MAX=A[j]
MAX_ID=j

temp=A[i]
A[i]=A[MAX_ID]
A[MAX_ID]=temp

Slow motion run of Selection Sort (Bold == sorted region):

5 1 3 2 4
4 1 3 2 5
1 3 2 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5 >> done

Is This Answer Correct ?    22 Yes 14 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the function of tie-high and tie-low cells?

625


For f = AB+CD if B is S-a-1, what are the test vectors needed to detect the fault?

737


For an AND-OR implementation of a two input Mux, how do you test for Stuck-At-0 and Stuck-At-1 faults at the internal nodes? (You can expect a circuit with some redundant logic)

712


How does a Bandgap Voltage reference work?

3242


What types of high speed CMOS circuits have you designed?

2061






What happens if we use an Inverter instead of the Differential Sense Amplifier?

2476


What are the steps involved in preventing the metastability?

651


Explain the operation of a 6T-SRAM cell?

4067


What are the different gates where boolean logic are applicable?

591


Draw the Layout of an Inverter?

2044


How does the size of PMOS Pull Up transistors (for bit & bit- lines) affect SRAM's performance?

738


Draw the Cross Section of an Inverter? Clearly show all the connections between M1 and poly, M1 and diffusion layers etc?

2854


What are the Advantages and disadvantages of Mealy and Moore?

703


Implement a function with both ratioes and domino logic and merits and demerits of each logic?

717


How to improve these parameters? (Cascode topology, use long channel transistors)

1705