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

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

1710


If the current through the poly is 20nA and the contact can take a max current of 10nA how would u overcome the problem?

700


What is Charge Sharing? Explain the Charge Sharing problem while sampling data from a Bus

800


In Verilog code what does “timescale 1 ns/ 1 ps” signifies?

697


What is the difference between cmos and bipolar technologies?

576






Draw the Differential Sense Amplifier and explain its working. Any idea how to size this circuit? (Consider Channel Length Modulation)

904


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

724


Write a program to explain the comparator?

686


what is SCR (Silicon Controlled Rectifier)?

640


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

2484


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

746


How can you model a SRAM at RTL Level?

5265


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

625


Describe the various effects of scaling?

4324


Draw the SRAM Write Circuitry

666