program help: i want a java program to implement heap sort algorithm and merge - Help.com

mai
offline Verified (10 months, 1 week) Visit mai's shoutbox
AU

i want a java program to implement heap sort algorithm

and merge sort algorithm

This open post was written 10 months, 1 week ago | V/U/S: 419, 3, 4 | Edit Post | Leave a reply | Report Post


Reciprocity (0) Reciprocation Failure -- The poster has NOT helped anyone else yet!

Since writing this post mai may have helped people, but has not within the last 4 days. mai is a verified member, has been around for 10 months, 1 week and has 8 posts and 4 replies to their name.

Post Tags (8)

Replies (3)

Where were you?

Click and drag to move the map around. FAQ: How we place people on this map »
You can also watch events on Help.com as they happen
Mouse over the map for 2 seconds to see an expanded, interactive view

The Clue offline Verified User (3 years, 1 month) Long Term User Shouts: 41 #
Minot, ND, US | 10 months, 1 week ago (1 hour, 16 minutes after post)

Get a complier and design it to do what you want. Hope this helps :-)

Quote this reply Report this reply to moderators
ashrith_kua offline Unverified User #
An Unknown Location | 9 months, 1 week ago (1 month after post)

public static void heapsort( Comparable [ ] a )
{
for( int i = a.length / 2; i >= 0; i– ) /* buildHeap */
percDown( a, i, a.length );
for( int i = a.length - 1; i > 0; i– )
{
swapReferences( a, 0, i ); /* deleteMax */
percDown( a, 0, i );
}
}

private static int leftChild( int i )
{
return 2 * i + 1;
}

private static void percDown( Comparable [ ] a, int i, int n )
{
int child;
Comparable tmp;

for( tmp = a[ i ]; leftChild( i ) < n; i = child )
{
child = leftChild( i );
if( child != n - 1 && a[ child ].compareTo( a[ child + 1 ] ) < 0 )
child++;
if( tmp.compareTo( a[ child ] ) < 0 )
a[ i ] = a[ child ];
else
break;
}
a[ i ] = tmp;
}

public static final void swapReferences( Object [ ] a, int index1, int index2 )
{
Object tmp = a[ index1 ];
a[ index1 ] = a[ index2 ];
a[ index2 ] = tmp;
}

Quote this reply Report this reply to moderators
This account has been deactivated.
rashie123r offline Unverified User #
An Unknown Location | 4 months ago (6 months, 1 week after post)

I need a merge sort algorithm and Java implementatin

Quote this reply Report this reply to moderators
This account has been deactivated.

Invite Others to Help

A logged in and verified Help.com member has the ability to setup a Friends List and invite others to help with posts.