Sunday, January 25, 2015

Intersection Of Unsorted Arrays

There are two arrays, find the elements which for which there is an intersection.

Input:
  arr1 = { 12, 4, 17 }
  arr2 = { 1, 12, 7, 17 }

Output:
 Intersection Using Simple Comparison
 12 17
 Intersection Using Sort and Binary Search
 12 17
There are two approaches for solving the problem:

  • A simple approach or 
  • Approach based on sorting and searching. ( Sorting which we have learned in some of the previous posts).


No comments:

Post a Comment