RSS

You are given two set X={ x1,x2,x3………xn} and Y={y1,y2,y3………ym}, You have to apply a Match( X parameter, Y parameter) function on each combination of set X and Y elements and then based on Match module result you have to assign a weight between the respective elements to form a Graph. Match(x1 , y1){if( x1==y1) assign weight between x1 and y1 = 1; else assign weight between x1 and y1= 0;

Fri, Mar 5, 2010

Algorithm

Method 1) Hash Map
 
Put all the elements of first array in a Hash Map
Visit second array to check whether the values are same (that is the value already has exist in the hashmap or not) or different
 
 

Method 2) Brute Force
 
Compare each combination of elements in the graph. If a match found then assign the weight accordingly
 
 

Method 3) Sort and Search
 
Sort one array
For each element in one array, do a binary search of the element on second element

Sharing ~ Helping Other:
  • Print
  • email
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • BlinkList
  • DZone
  • Slashdot
  • YahooMyWeb
  • StumbleUpon
  • Live
  • IndianPad
  • DotNetKicks
  • Technorati

Other Posts:

This post was written by:

eXclusiveMinds - who has written 500 posts on eXclusiveMinds.


Contact the author

Leave a Reply

You must be logged in to post a comment.