mockers
Would you like to react to this message? Create an account in a few clicks or log in to continue.

@CITRIX ..............

4 posters

Go down

@CITRIX .............. Empty @CITRIX ..............

Post  ballu Sun Feb 01, 2009 11:03 pm

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
ballu
ballu

Posts : 58
Join date : 2009-02-01

Back to top Go down

@CITRIX .............. Empty Re: @CITRIX ..............

Post  Admin Mon Feb 02, 2009 12:05 am

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

Admin
Admin

Posts : 47
Join date : 2009-01-29

https://mockers.forumotion.com

Back to top Go down

@CITRIX .............. Empty Re: @CITRIX ..............

Post  $corpion Mon Feb 02, 2009 12:14 am

#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;
$corpion
$corpion

Posts : 25
Join date : 2009-01-30
Age : 37

Back to top Go down

@CITRIX .............. Empty Re: @CITRIX ..............

Post  shivang Mon Feb 02, 2009 9:21 am

Bhai logon Largest Binary Tree vaala karne ka try karo....its an awesome ques......
shivang
shivang

Posts : 42
Join date : 2009-01-30
Age : 35

Back to top Go down

@CITRIX .............. Empty @all

Post  shivang Wed Feb 25, 2009 3:08 am

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 cheers

iske aur bhi solns hain .....try akro varna i'll post... cheers
shivang
shivang

Posts : 42
Join date : 2009-01-30
Age : 35

Back to top Go down

@CITRIX .............. Empty Re: @CITRIX ..............

Post  shivang Wed Feb 25, 2009 12:58 pm

sorry bhai logon./...iska ye galat soln hai..... pale
shivang
shivang

Posts : 42
Join date : 2009-01-30
Age : 35

Back to top Go down

@CITRIX .............. Empty Re: @CITRIX ..............

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum