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

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / vicneswary

5 1 3 2 4
1 3 5 2 4
1 2 3 5 4
1 2 3 4 5

Is This Answer Correct ?    3 Yes 8 No

Post New Answer

More VLSI Interview Questions

Insights of a pass gate. Explain the working?

0 Answers   Intel,


what is verilog?

0 Answers  


what is Latch up?How to avoid Latch up?

3 Answers  


What is validation?

2 Answers   Intel,


Describe the various effects of scaling?

0 Answers   Infosys,






What types of high speed CMOS circuits have you designed?

0 Answers   Intel,


Give various factors on which threshold voltage depends.

0 Answers  


What does the above code synthesize to?

0 Answers   Intel,


Explain Clock Skew?

6 Answers   Intel, nvidia,


Implement a 2 I/P and gate using Tran gates?

0 Answers   Intel,


Differences between DRAM and SRAM?

14 Answers   Infosys, Intel, University, Wipro,


What is Fermi level?

5 Answers  


Categories