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 Charge Sharing? Explain the Charge Sharing problem while sampling data from a Bus

0 Answers   Infosys,


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

0 Answers   Intel,


what is SCR (Silicon Controlled Rectifier)?

0 Answers  


Design an 8 is to 3 encoder using 4 is to encoder?

0 Answers   Intel,


Explain the difference between write through and write back cache.

2 Answers   Intel,






verify nmos passes good logic 0 and passes bad logic 1.also verify that pmos passes good logic 1 and passes bad logic 0.

2 Answers   Cosmic Circuits, HP,


How to find the read failiure probablity in SRAM?

2 Answers  


Explain what is the depletion region?

0 Answers  


What is the difference between fifo and the memory?

6 Answers   DewSoft, Intel, Pentagon Rugged Systems,


What is the mealy and moore machine's state diagram that can detect 3 consecutive heads of 3 coins ?

2 Answers  


What happens to delay if you increase load capacitance?

1 Answers   Google,


Id vs. Vds Characteristics of NMOS and PMOS transistors?

1 Answers   Brillient, Intel, ISRO,


Categories