Tuesday, September 5, 2017

Today we start reviewing Bing Maps API
These APIs include map control and services that can be used to make maps part of your application. These APIs are an authoritative source for geospatial features. They offer static and interactive maps, geocoding, route and traffic data.Any spatial data such as store locations can be queried and stored with these APIs. Typically an account and a key is needed to use the APIs. The key is used as a license to utilize their services. They are classified as used for public website, private website and enterprise assets.
The Bing Maps dev center provides account management functionality. An account is needed to cut a key and to manage data sources.
The Bing Maps Services include REST services and spatial data services. The REST services provide geocoding, routing, elevation, imagery etc. and traffic incident information. The data services provide batch geocoding and spatial data source query and management.
The Web controls available by Bing Maps include support for both WPF and native libraries for Android and perhaps iOS. The geocoding API helps geocode a large batch of addresses. The FindBy APIs help with the querying.
The REST services automatically come  with transaction accounting that helps determine billable and non-billable transactions.
#codingexercise
Find the next smaller element which is smaller than twice itself for all in an integer array
Int[] GetNextSmaller2XElements(List<int> A)
{
var result = new int[A.length];
for (int i =0; i < A.Length; i++)
{
int next = -1;
for (int j = i+1; j < A.Length; j++)
      if (A[j] < 2 x A[i]){
          next  = A[j];
          break;
      }
result[i] = next;
}
return result;

}
We could also  do this with the help of a stack which we keep for all the elements that do not have a next 2X smaller element.
we push the first element in the stack. we pick the next item in the array if the next is smaller than the element in the stack, we print the tuple and pop the element otherwise we push it back on to the stack for retaining the elements we have not found an answer yet. we also push the next element on to the stack so it can participate for matches going forward. This is still O(N^2) but instead of looking ahead through all the elements we are looking back at the collection of unmatched so far. In the worst case, this stack will grow to be the length of the array. The order of the stack is the reverse order of the portion of the array we have covered.

No comments:

Post a Comment