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

What is threshold voltage?

1 Answers  


What are the total number of lines written by you in C/C++? What compiler was used?

1 Answers   Intel, Zensar,


Differences between Signals and Variables in VHDL? If the same code is written using Signals and Variables what does it synthesize to?

1 Answers   IIT, Intel,


For CMOS logic, give the various techniques you know to minimize power consumption

1 Answers   Infosys,


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

1 Answers  


Explain the working of Insights of a pass gate ?

1 Answers   Intel,


Explain how binary number can give a signal or convert into a digital signal?

1 Answers  


Explain how logical gates are controlled by Boolean logic?

1 Answers  


How do you size NMOS and PMOS transistors to increase the threshold voltage?

4 Answers  


Why is Extraction performed?

1 Answers   Intel,


Explain why is the number of gate inputs to cmos gates usually limited to four?

1 Answers  


What are the Factors affecting Power Consumption on a chip?

1 Answers   Intel,


Categories