Showing posts with label Web Services. Show all posts
Showing posts with label Web Services. Show all posts

Saturday 1 June 2013

Binary Search Tree

Binary Search Tree
In computer science, a Binary Search Tree (also known as ordered or sorted binary tree) is a node-based binary data structure which has the following properties.









  • The left subtree of a node contains only nodes with keys less than the node's key.
  • The right subtree of a node contains only nodes with keys greater than the node's key.
  • The left and right subtree must each also be a binary tree.
  • There must be no duplicate nodes.


In Following case, We use Binary Search Tree
They can be used as a quick way to sort data. Insert data into a binary search tree at O(log(n)). Then traverse the tree in order to sort them.

Binary Search Tree Example in PHP
/** Create Node Class **/
class Node
{
 public $parent = null;
 public $left = null;
 public $right = null;
 public $data = null;
 
 public function __construct($data)
 {
  $this->data = $data;
 }
 
 public function __toString()
 {
  return $this->data;
 }
}

/** Create BinarySearchTree Class **/ 
class BinarySearchTree
{
 protected $_root = null;
 
 protected function _insert(&$new, &$node)
 {
  if ($node == null) {
   $node = $new;
   return;
  }
 
  if ($new->data <= $node->data) {
   if ($node->left == null) {
    $node->left = $new;
    $new->parent = $node;
   } else {
    $this->_insert($new, $node->left);
   }
  } else {
   if ($node->right == null) {
    $node->right = $new;
    $new->parent = $node;
   } else {
    $this->_insert($new, $node->right);
   }
  }  
 }
 
 protected function _search(&$target, &$node)
 {
  if ($target == $node) {
   return 1;
  } else if ($target->data > $node->data && isset($node->right)) {
   return $this->_search($target, $node->right);
  } else if ($target->data <= $node->data && isset($node->left)) {
   return $this->_search($target, $node->left);
  }
 
  return 0;
 }
 
 public function insert($node)
 {
  $this->_insert($node, $this->_root);
 }
 
 public function search($item) 
 {
  return $this->_search($item, $this->_root);
 }
}
 
/* Add Data in Nodes **/
$node1 = new Node(43);
$node2 = new Node(52);
$node3 = new Node(44);
$node4 = new Node(47);
$node5 = new Node(65);
 
/* Create Object **/
$obj = new BinarySearchTree();
 
$obj->insert($node1);
$obj->insert($node2);
$obj->insert($node3);
$obj->insert($node4);
$obj->insert($node5);

Friday 2 November 2012

Soap Interview Questions and Answers for Experienced

What is SOAP ?
It is communication protocol based on XML.


What is Full Form of SOAP?
Simple Object Access Protocol.


Why we use it?
It is used to communicate between two applications that is on different operating system and on different language.
SOAP is platform independent.
SOAP is Language Independent.
SOAP is simple and Extensive.


How to use SOAP?
SOAP is communication protocol, that use xml to communicate.
To use SOAP write your xml in some specific format and xml must contain some specific elements.


What are the elements use is SOAP message.?
It has 4 imp elements that are following..
  •  Envelope element: It contain information about this document and message.
  •  Header element: It contain information about  header.
  •  Body element: It contain Message
  •  Fault element: containing errors and status information

What are syntax for SOAP?
Following are the syntax for SOAP..
  •  Encoded using XML
  •  Use the SOAP Envelope namespace
  •  SOAP Encoding namespace
  • A SOAP message must NOT contain a DTD reference
  • A SOAP message must NOT contain XML Processing instructions


What is structure for SOAP?
    <soap:envelope soap:encodingstyle="http://www.w3.org/2001/12/soap-encoding" xmlns:soap="http://www.w3.org/2001/12/soap-envelope">
      <soap:header></soap:header>
      <soap:body>
        <soap:fault></soap:fault>
      </soap:body>
  </soap:envelope>


What is SOAP Envelope Element?
It is root element of a soap and it define about xml document. It have following attributes
encodingStyle : It may appear on any soap element.
<soap-env:envelope soap-env:encodingstyle="http://www.www.org/soap/encoding/" xmlns:soap-env="http://www.www.org/soap/envelope/">
<!-- SOAP body goes here -->
</soap-env:envelope>



What is SOAP Header Element?
SOAP Header: It contain application information (for example payment, authentication).It is optional. It have following attributes:
encodingStyle : It may appear on any soap element.
<soap:encodingStyle="http://php-tutorial-php.blogspot.in/2012/11/soap.html">
mustUnderstand: The SOAP mustUnderstand attribute can be used to indicate whether a header entry is mandatory or optional for the recipient to process. If you add mustUnderstand='1' to a child element of the Header element it indicates that the receiver processing the Header must recognize the element. If the receiver does not recognize the element it will fail when processing the Header.
<soap:mustUnderstand="0|1">
actor: It is used to address the header element to a specific endpoint.
<soap:actor="http://php-tutorial-php.blogspot.in/2012/11/soap.html"> 



What is SOAP Body Element?
SOAP Body: It contain the actual SOAP message intended for the ultimate endpoint of the message
<soap:body>
  <m:getblogresponse http:="http:" php-tutorial-php.blogspot.in="php-tutorial-php.blogspot.in" soap.html="soap.html" xmlns:m="">
    <m:blogname>php-tutorial-php.blogspot.com</m:blogname>
  </m:getblogresponse>
</soap:body>





What is SOAP Fault Element?
If a Fault element is present, it must appear as a child element of the Body element. A Fault element can only appear once in a SOAP message.  

Saturday 14 July 2012

What is OpenInviter

OpenInviter is free & let you import contacts from yahoo, gmail, rediff, MSN, AOL etc by entering the username & password. It take 5-10 min to integrate in your websites.

get contact list form


When we click on after filling detail, it show all the contacts store in your mail box. It will just return data in form of array of object( field's return Email, Name), depend of you how you display.


It provide the code to import contacts from followings website
  1. YouTube,
  2.  Evite,
  3.  Xing,
  4.  Mynet.com, 
  5. Virgilio, 
  6. Wp.pt,
  7.  IndiaTimes,
  8.  Bigstring, 
  9. Netaddress, 
  10. Inbox.com, 
  11. Web.de, 
  12. Aussiemail, 
  13. Interia, 
  14. 5Fm, 
  15. GMX.net, 
  16. Canoe, 
  17. Yandex, 
  18. Mail2World, 
  19. Freemail,
  20.  Doramail,
  21.  Plaxo, 
  22. GMail, 
  23. KataMail, 
  24. Bordermail, 
  25. Walla, 
  26. O2, 
  27. Nz11,
  28.  Inet, 
  29. India, 
  30. Apropo, 
  31. Mail.in, 
  32. Care2, 
  33. Mail.ru, 
  34. MSN, 
  35. Clevergo, 
  36. Gawab, 
  37. Lycos, 
  38. Kids, 
  39. Uk2, 
  40. Abv, 
  41. Mail.com, 
  42. Azet, 
  43. AOL, 
  44. OperaMail, 
  45. Yahoo!, 
  46. Sapo.pt, 
  47. Meta, 
  48. Pochta,
  49.  Hushmail,
  50. Terra, 
  51. Rediff,
  52.  Popstarmail,
  53.  Libero, 
  54. Rambler,
  55.  LinkedIn,
  56.  FastMail,
  57.  Zapakmail,
  58.  Live/Hotmail, 
  59. Atlas, Grafitti, 
  60. Techemail or social portals like Skyrock,
  61.  Orkut, 
  62. Xanga, 
  63. Mydogspace,
  64. Konnects,
  65.  Hyves,
  66. Fdcareer, 
  67. Mycatspace,
  68.  Last.fm, 
  69. Plazes, 
  70. Meinvz, 
  71. Eons, 
  72. Vimeo, 
  73. Friendfeed,
  74.  Flickr, 
  75. Brazencareerist, 
  76. Cyworld, 
  77. Kincafe, 
  78. Flixster, 
  79. Ning, 
  80. Livejournal, 
  81. Bookcrossing, 
  82. Facebook, 
  83. Perfspot, 
  84. Hi5, 
  85. Tagged, 
  86. Lovento, 
  87. Xuqa, 
  88. Badoo, 
  89. Koolro, 
  90. NetLog, 
  91. Mevio, 
  92. Flingr, 
  93. Famiva, 
  94. Vkontakte,
  95.  Faces, 
  96. Friendster, 
  97. Twitter, 
  98. Motortopia, 
  99. MySpace,
  100.  Plurk, 
  101. Multiply, 
  102. Bebo

Tuesday 6 December 2011

Facebook Social Plugins Integration in Website


Facebook Social Plugins Integration in Website

Facebook Platform enables you to make your website more social. You can use our Social Plugins, such as the Like Button to drive user engagement with a single line of HTML.  Login Button and Registration Plugin let you simplify or eliminate your own user registration and sign-in. Lastly, the Graph API lets you access the full social graph of a given user, allowing you to create a truly deep personal experience.

Social Plugins are the easiest way to get started with Facebook Platform. The plugins are embeddable social features that can be integrated in your site with a line of HTML. Because they are hosted by Facebook, the plugins are personalized for all users who are currently logged into Facebook, even if they are visiting your site for the first time.


Following are the different  Facebook Social Plugins.


Facebook Like Button



Send Button


Facebook Comments

Share Button



Like Box








Facebok Social Plugin from where you can get the code and just past into your website.
Each link Socail plugin will give you  two codes and are following
  • JavaScript SDK  (include once only)<div id="fb-root"> </div> <xmp> (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&amp;appId=508427595967225&amp;version=v2.0"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));

  • HTML Code (Must include for each Social plugin)
  • <div class="fb-like-box" data-colorscheme="light" data-header="true" data-href="https://www.facebook.com/pages/Web-Technology-Experts-Notes/1486091758321940" data-show-border="true" data-show-faces="true" data-stream="false"> </div>

    Following are the links from where you can get the HTML tag


    Tuesday 6 September 2011

    Share your Website

    If you are running a blog or any kind of website, and you’re always trying to encourage more people to talk about and share your pages on social sites like facebook, LinkedIn, twitter etc and posts through a variety of channels, including social media and e-mail.


    Share your website



    Following are popular sites which provide you "embed code", After integration embed code, user can share your website on social sites.
    1) https://www.addthis.com/
    2) https://www.addtoany.com/
    3) http://sharethis.com/