abc.xyz
BAN USER 0of 0 votes
AnswersWhat would be the sample class design of notification system?
 abc.xyz in India Report Duplicate  Flag  PURGE
Amazon SDE2  0of 0 votes
AnswersWhat would be the sample class design of tic tac toe game?
 abc.xyz in India Report Duplicate  Flag  PURGE
Amazon SDE2  0of 0 votes
AnswersWhat would be the sample class design of Outlook like meeting scheduler?
 abc.xyz in India Report Duplicate  Flag  PURGE
Amazon SDE2  1of 1 vote
AnswersHow is design review done?
 abc.xyz in India Report Duplicate  Flag  PURGE
Amazon SDE2 Software Design
To do all the operation in O(1)
It requires 2 HashMap and one Doubly Linked List, and one counter that can store the least Frequency count currently.
1st HashMap will keep the key and DoublyLinkedList Node as Value (including frequency)
2nd HashMap will store frequency as Key and DLL as LInkedList (with head and tail)
so once the new key,pair comes to set we will push it on 1st Map and Add into second Map tail side at Zeroth frequency.
once get operation performed we will take the node from 1st Map, remove that node from 2nd Map, and add it into tail side of 2nd Map by increasing its frequency by 1.
A more simple code than above .... doing preorder traversal and keeping the lowest leaf position
void NLN(Tree *Root,Tree **temp,int level)
{
static int s=1000;
if(!Root)
return ;
if(Root>left==NULL&&Root>right==NULL&&s>=level)
{
*temp=Root;
s=level;
return;
}
NLN(Root>left,temp,level+1);
NLN(Root>right,temp,level+1);
}
//Icalling like this
Tree *temp;
NLN(Root,&temp,0);
if(temp)
cout<<endl<<temp>data;

abc.xyz
September 08, 2013 I have simple approach for the above problem...which are as
1. Find the height of the tree...(considering leaf node can be on any height for more than one node)
2.Now Traverse at each level from i=0 to each height of the tree...
if i==height &&Root>left==NULL&&Root>right==NULL
you are done
My code goes like this... in c++
typedef struct Tree_Structure
{
int data;
struct Tree_Structure *left;
struct Tree_Structure *right;
}Tree;
int HeightOfTree(Tree *Root)
{
int n=0,m=0;
if(!Root)return 0;
n=HeightOfTree(Root>left);
m=HeightOfTree(Root>right);
if(n>m)
return n+1;
else
return m+1;
}
Tree *Level(Tree *Root,int i,int height)
{ Tree *temp=NULL;
if(!Root)return NULL;
if(i==height&&(Root>left==NULL&&Root>right==NULL))
return Root;
temp=Level(Root>left,i+1,height);
if(temp)
return temp;
temp=Level(Root>right,i+1,height);
if(temp)
return temp;
}
Tree *NearestLeafNode(Tree *Root)
{ Tree *temp=NULL;
if(!Root)
return NULL;
int height=HeightOfTree(Root);
for(int i=0;i<height;i++)
{
temp=Level(Root,0,i);
if(temp)
return temp;
}
}

abc.xyz
September 08, 2013 A c program for finding Sqrt upto 3 decimal point........Paper and Pencil way.
#include<stdio.h>
#include<stdlib.h>
void Sqrt(int n)
{
double R=0,d=0;
int i=0,p,temp=0,count=0;
if(n<=0){printf("Not possible ");return ;}
}
for(i=0;i<=n/2+2;i++)
{ if(d==0)
p=i*i;
else
p=(d*10+i)*i;
if(p>n)
{
R=(double)R*10+temp;
n=n(d*10+temp)*temp;
d=(d*10+temp)+temp;
if(n<=d&&count<3)
{
n=n*100;
count++;
}
else
break;
i=0;
}
temp=i;
}
printf("final result=%g",(float)R/1000);
}
int main(void)
{int i=0,data;
printf("Enter the data for Sqrt=");
scanf("%d",&data);
Sqrt(data);
return 0;
}
Happy coding.....
 abc.xyz June 27, 2013Open Chat in New Window
Here is my Algorithm,
1. Pick a customer
2. Iterate its drinks
3. check if any customer has this drinks if it has update cust with that drinks.
4. check which drinks have the most customer, and delete them from the set.
5. now for the rest customer go to point 1.
 abc.xyz July 20, 2017