ACM (UVa) : 11462


Data type:
long Integer

Algorithm:
hmm …
which sorting algorithm is going round in ur head ?? Quick sort !! or sth more efficient !!
while writing this post, till now I can efficiently use only bubble sort and rarely I did use insertion sort. Then, what abt our current problem !!

I have used Frequency sort !! sounds interesting, right ?
Suppose, we have an array of 10 elements, initially inserted 0

Index

0

1

2

3

4

5

6

7

8

9

Value

0

0

0

0

0

0

0

0

0

0

We have to sort these values: 5 6 3 2 0 1 4 7 5 0 6 3 2 1 5 6 8 4 5 2 3 2 1 4 6 2 1
Total 27 values
now, frequency wise increase values in array’s respective fields

Index

0

1

2

3

4

5

6

7

8

9

Value

2

4

5

3

3

4

4

1

1

0

Number of 0’s : 2
Number of 1’s : 4
Number of 2’s : 5

Number of 8’s : 1
Number of 9’s : 0
Just print the array index orderly, frequency wise.

Hmm …
UVa@Presentation_Error !!
bcoz, u print an extra space after last value.

Firstly, Flag = 0
loop () {
if ( Flag is equals to 1 ) then, print (space)
printf (Value)
Flag = 1
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s