@CITRIX ..............
4 posters
Page 1 of 1
@CITRIX ..............
The following questions were asked in CITRIX
1)Find the maximum size Binary search tree in a binary tree..
2)Merge two given linked list
3) remove repeated letters from a word
BANANA ->> BAN
1)Find the maximum size Binary search tree in a binary tree..
2)Merge two given linked list
3) remove repeated letters from a word
BANANA ->> BAN
ballu- Posts : 58
Join date : 2009-02-01
Re: @CITRIX ..............
to remove repeated we can use hashing..as only 26 alphabets r there....
we will keep an array of 26 alphabets and start puttin 1 at their indexes as soon as we start gettin them >= 2 times..
i.e.
while traversing the string we will first check the index of particular alphabet in the array in O(1) ..if its 0 it means the alphabet is comin for the first time ..
n we will outpuut dat alphabet else we ll skip dat
complexity O(1),...
plzz do tell me if m wrong...m not sure
we will keep an array of 26 alphabets and start puttin 1 at their indexes as soon as we start gettin them >= 2 times..
i.e.
while traversing the string we will first check the index of particular alphabet in the array in O(1) ..if its 0 it means the alphabet is comin for the first time ..
n we will outpuut dat alphabet else we ll skip dat
complexity O(1),...
plzz do tell me if m wrong...m not sure
Re: @CITRIX ..............
#include<iostream>
#include<map>
using namespace std;
typedef map<char,int> mymap;
main()
{
mymap maparray;
string s="BANANA";
for(int i=0;i<s.size();i++){
if(maparray[s[i]]==0){
cout<<s[i];
maparray[s[i]]++;
}
}//O(n)
getchar();
}//main
given heads of two linked list..
node *head1,*head2;
traverse till end of first linked list
while(head1->next!=NULL)
head1=head1->next;
den point the null tail to head2;
head1->next=head2;
#include<map>
using namespace std;
typedef map<char,int> mymap;
main()
{
mymap maparray;
string s="BANANA";
for(int i=0;i<s.size();i++){
if(maparray[s[i]]==0){
cout<<s[i];
maparray[s[i]]++;
}
}//O(n)
getchar();
}//main
given heads of two linked list..
node *head1,*head2;
traverse till end of first linked list
while(head1->next!=NULL)
head1=head1->next;
den point the null tail to head2;
head1->next=head2;
$corpion- Posts : 25
Join date : 2009-01-30
Age : 37
Re: @CITRIX ..............
Bhai logon Largest Binary Tree vaala karne ka try karo....its an awesome ques......
shivang- Posts : 42
Join date : 2009-01-30
Age : 35
@all
I have come up with a solution for the largest BST in a binary tree....
okay, all know that for a bst the inorder traversal is sorted...right
now start the inorder traversal for the given binary tree....
jab tak sorted list ban rahi hai tab tak it is forming a binary search tree......so sabse bada vaala jo sorted list hoga tats the largest BST in the binary tree given
iske aur bhi solns hain .....try akro varna i'll post...
okay, all know that for a bst the inorder traversal is sorted...right
now start the inorder traversal for the given binary tree....
jab tak sorted list ban rahi hai tab tak it is forming a binary search tree......so sabse bada vaala jo sorted list hoga tats the largest BST in the binary tree given
iske aur bhi solns hain .....try akro varna i'll post...
shivang- Posts : 42
Join date : 2009-01-30
Age : 35
Re: @CITRIX ..............
sorry bhai logon./...iska ye galat soln hai.....
shivang- Posts : 42
Join date : 2009-01-30
Age : 35
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|