[Show all top banners]

computerScience
Replies to this thread:

More by computerScience
What people are reading
Subscribers
:: Subscribe
Back to: Kurakani General Refresh page to view new replies
 Any Math CompScience guru ?? Need help..
[VIEWED 6836 TIMES]
SAVE! for ease of future access.
Posted on 09-19-10 12:25 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Malai kasari insertion or heap sort lai stable banaune kehe idea chahiyo. Algorithm bhanam. Koi chan hola yeha math computer guru haru...
 
Posted on 09-19-10 2:27 PM     [Snapshot: 44]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Insertion sort
http://www.roseindia.net/java/beginners/arrayexamples/InsertionSort.shtml

Heap sort
http://www.java-tips.org/java-se-tips/java.lang/heap-sort-implementation-in-java.html

 
Posted on 09-19-10 6:48 PM     [Snapshot: 111]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

I am actually looking for how to change hear sort into a stable algorithm. Not its implementation and hint would be great.
 
Posted on 09-19-10 11:30 PM     [Snapshot: 189]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

did you get a chance to look here?


http://en.wikipedia.org/wiki/Sorting_algorithm#Stability


Prolly this is helpful


Stability


Stable sorting algorithms maintain the relative order of records with equal keys. If all keys are different then this distinction is not necessary. But if there are equal keys, then a sorting algorithm is stable if whenever there are two records (let's say R and S) with the same key, and R appears before S in the original list, then R will always appear before S in the sorted list. When equal elements are indistinguishable, such as with integers, or more generally, any data where the entire element is the key, stability is not an issue. However, assume that the following pairs of numbers are to be sorted by their first component:

(4, 2) (3, 7) (3, 1) (5, 6)

In this case, two different results are possible, one which maintains the relative order of records with equal keys, and one which does not:

(3, 7) (3, 1) (4, 2) (5, 6) (order maintained)
(3, 1) (3, 7) (4, 2) (5, 6) (order changed)

Unstable sorting algorithms may change the relative order of records with equal keys, but stable sorting algorithms never do so. Unstable sorting algorithms can be specially implemented to be stable. One way of doing this is to artificially extend the key comparison, so that comparisons between two objects with otherwise equal keys are decided using the order of the entries in the original data order as a tie-breaker. Remembering this order, however, often involves an additional computational cost.


Sorting based on a primary, secondary, tertiary, etc. sort key can be done by any sorting method, taking all sort keys into account in comparisons (in other words, using a single composite sort key). If a sorting method is stable, it is also possible to sort multiple times, each time with one sort key. In that case the keys need to be applied in order of increasing priority.


Example: sorting pairs of numbers as above by first, then second component:

(4, 2) (3, 7) (3, 1) (5, 6) (original)
(3, 1) (4, 2) (5, 6) (3, 7) (after sorting by second component)
(3, 1) (3, 7) (4, 2) (5, 6) (after sorting by first component)

On the other hand:

(3, 7) (3, 1) (4, 2) (5, 6) (after sorting by first component)
(3, 1) (4, 2) (5, 6) (3, 7) (after sorting by second component,
order by first component is disrupted).


 
Posted on 09-20-10 4:02 PM     [Snapshot: 262]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

 SAS guru, what is the best book for the SAS beginner. I want to learn it as self-study.

 
Posted on 09-20-10 4:02 PM     [Snapshot: 262]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

 SAS guru, what is the best book for the SAS beginner. I want to learn it as self-study.

 
Posted on 09-20-10 5:50 PM     [Snapshot: 291]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Insertion Sort is stable.

Heap Sort is unstable. You cannot maintain the order of keys once sorted. If you really want to "pretend" you made heap sort stable, do one thing BUT strongly not recommended unless you want to be a smart-ass.

- Heap sort is a special case of selection sort, with building Heap every time it does the basic selection sorting. Now - skip building Heap :)
- So you are left with selection sort Only, which is not stable either. But there is a way you can make selection sort stable.

Follow this link to the way you could make a selection sort stable by "wildfrog"
http://www.codeguru.com/forum/showthread.php?t=362340





 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 90 days
Recommended Popular Threads Controvertial Threads
TPS Re-registration case still pending ..
Toilet paper or water?
and it begins - on Day 1 Trump will begin operations to deport millions of undocumented immigrants
Tourist Visa - Seeking Suggestions and Guidance
From Trump “I will revoke TPS, and deport them back to their country.”
I hope all the fake Nepali refugee get deported
advanced parole
Sajha Poll: Who is your favorite Nepali actress?
ढ्याउ गर्दा दसैँको खसी गनाउच
To Sajha admin
Problems of Nepalese students in US
Mamta kafle bhatt is still missing
अरुणिमाले दोस्रो पोई भेट्टाइछिन्
MAGA denaturalization proposal!!
Are Nepalese cheapstakes?
Nepali Psycho
How to Retrieve a Copy of Domestic Violence Complaint???
wanna be ruled by stupid or an Idiot ?
All the Qatar ailines from Nepal canceled to USA
MAGA मार्का कुरा पढेर दिमाग नखपाउनुस !
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters