princeladdak
BAN USERThe record A specifies IP address (IPv4) for given host. A records are used for conversion of domain names to corresponding IP addresses.
- princeladdak March 05, 2014struct listNode
{
int data;
struct listNode *next;
};
typedef struct listNode ListNode;
typedef ListNode *ListNodePtr;
void renoveDuplicates(ListNodePtr sptr)
{
map<int,bool> M;
ListNodePtr previous=NULL;
while(sptr!=NULL)
{
if(M[sptr->data]==true)
{
cout<<"i m here"<<endl;
previous->next=sptr->next;
}
else
{
M[sptr->data]=true;
previous=sptr;
}
sptr=sptr->next;
}
}
Here is my implementation in c++
#include <cstdlib>
#include <stdio.h>
#include <cstring>
#include <complex>
#include <vector>
#include <cmath>
#include <ctime>
#include <iostream>
#include <numeric>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <iomanip>
#include <utility>
#include <locale>
#include <sstream>
#include <string> // this should be already included in <sstream>
#define FOR(i,n) for(i=0;i<n;i++)
#define FORI(i,a,n) for(i=a;i<n;i++)
#define FORC(it,C) for(it=C.begin();it!=C.end();it++)
#define scanI(x) scanf("%d",&x)
#define scanD(x) scanf("%lf",&x)
#define print(x) printf("%d\n",x)
#define ll long long
#define number32 4294967296ull
#define MAX 100001
///cout<<(double)(clock() - tStart)/CLOCKS_PER_SEC<<endl;
///clock_t tStart = clock();
using namespace std;
struct treeNode
{
struct treeNode *left;
int data;
struct treeNode *right;
};
typedef struct treeNode TreeNode;
typedef TreeNode *TreeNodePtr;
void insertNode(TreeNodePtr *treePtr,int value)
{
if(*treePtr== NULL)
{
*treePtr=(TreeNodePtr)malloc(sizeof(TreeNode));
if(*treePtr != NULL)
{
(*treePtr)->data=value;
(*treePtr)->left=NULL;
(*treePtr)->right=NULL;
}
else
{
// cout<<"Memory is not available "<<endl;
}
}
else
{
if(value<(*treePtr)->data)
{
insertNode(&((*treePtr)->left),value);
}
if(value>=(*treePtr)->data)
{
insertNode(&((*treePtr)->right),value);
}
}
}
void Inorder( TreeNodePtr treePtr)
{
if(treePtr != NULL)
{
Inorder(treePtr->left);
printf("%d\n",treePtr->data);
Inorder(treePtr->right);
}
}
void zigzagOrder(TreeNodePtr treePtr)
{
stack<TreeNodePtr> s1,s2;
TreeNodePtr cur1,cur2;
s1.push(treePtr);
do
{
while(!s1.empty())
{
cur1=s1.top();
s1.pop();
cout<<cur1->data<<" "<<endl;
if(cur1->left!=NULL)
s2.push(cur1->left);
if(cur1->right!=NULL)
s2.push(cur1->right);
}
while(!s2.empty())
{
cur2=s2.top();
s2.pop();
cout<<cur2->data<<" "<<endl;
if(cur2->left!=NULL)
s1.push(cur2->right);
if(cur2->right!=NULL)
s1.push(cur2->left);
}
}
while(!s1.empty()||!s2.empty());
}
int main()
{
int t,i;
int n;
TreeNodePtr rootPtr=NULL;
//int k=5;
//cout<<k<<" "<<(k<<1)<<" "<<(k>>1)<<endl;
srand(clock());
cin>>n;
FOR(i,n)
{
cin>>t;
insertNode(&rootPtr,t);
}
//Inorder(rootPtr);
zigzagOrder(rootPtr);
//cout<<"success"<<endl;
return 0;
}
The A record maps a name to one or more IP addresses, when the IP are known and stable.
- princeladdak March 05, 2014The CNAME record maps a name to another name. It should only be used when there are no other records on that name.