Create the mirror copy of the tree and compare with original. If same then
symmetric.
On Tue, May 22, 2012 at 10:50 AM, algogeek dayanidhi.haris...@gmail.comwrote:
How to check if a given binary tree is structurally symmetric ie. the
left sub tree should be mirror image of right sub tree and
// countIslands.cpp : Defines the entry point for the console application.
//
#include stdafx.h
const int rows = 5;
const int cols = 6;
bool visited[rows][cols] = {0};
int arr[rows][cols] =
{
0,0,0,0,1,1,
0,1,0,0,0,1,
1,1,0,0,0,0,
1,0,0,0,1,1,
0,0,1,0,1,0};
void initialize()
{
for (int i=0;
no need of creating another mirror tree
you just need to call the function func(root-left,root-right);
now left sub tree and right sub tree will be considered as if you are
checking 2 different trees
same code to check if 2 tree are structurally similar will work.
On Tue, May 22, 2012 at 10:50
Has anyone under gone interview process of STUDYPAD inc ?
I have interview scheduled day after tomorrow, can somebody help me in
what sort of questions do these people ask.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group,
okay thanks... :-)
On Tue, May 22, 2012 at 2:50 PM, atul anand atul.87fri...@gmail.com wrote:
no need of creating another mirror tree
you just need to call the function func(root-left,root-right);
now left sub tree and right sub tree will be considered as if you are
checking 2 different
Write a method to sort an array of strings so that all the anagrams are
next to each other.
What i could think of is preparing a multi linked list( multimap) whereby
the key for each string is the sorted representation of the string(eg if
string is gac, its sorted representation is acg). Walk of
What I Could possibly think of is
For each string S1 that is an anagram of some string S, use Map and Store
the Key Value as (S1,S). Now there is a trick here abt how to reduce Time
Complexity here...
Now its easy to put all string which has correspondence S next to each
other. This is Simple
write a program to find the longest word made of other words. For instance,
If my file has the following words (sorted):
test
tester
testertest
testing
testingtester
The longest word should be testingtester. Trie is the solution, what is the
best Order possible?
Best Regards
Ashish Goel
Think
The no. of transformations = cost of (no. of replace operations + no.
of deletes + no. of additions) / 2
where,
cost of replace operation = 2
cost of delete/addition operation = 1
On May 22, 8:12 am, UTKARSH SRIVASTAV usrivastav...@gmail.com wrote:
then waht will be it's recurrence relation
@Lucifer, do we need to add insert and del operations in the transformation
formula u gave? Isn't it just the number of substitutions/2?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
Yea this is a Straight Cut Trie Question No Doubt.. Perhaps DWAG may be
taken into consideration..
T(O)=O(n) can be done easily.. ( By tracking Second and First Longest word
found soFar and updating otherwise accordingly)
Can someone do it better?
On Tue, May 22, 2012 at 6:15 PM, Ashish Goel
Anyways we need to sort all the words atleast once, one way is
To travel throught the list sorting each word and making a pair of the
orginal and the sorted word.
For Ex. If one of the original word in list is aanchal sorted is
aaachln. So store the pair aanchal, aaachln
Now sort this list of
---
adarsh kumar wants to stay in better touch using some of Google's coolest new
products.
If you already have Gmail or Google Talk, visit:
http://mail.google.com/mail/b-838f0088c8-7ce2f0cfbf-whddt6Y3xfr109-a6qqOkRZmhu0
You'll
@krishna : tracking just second and first longest word would be enough??
what if input has word which is made by repeating small word again and again
test
tester
testertest
testing
testingtester
testtesttesttesttest // added word
and by saying O(n) .. n= total number of alphabets in the file
yes ,longest word can be found while inserting each word it the TRIE.
*By tracking Second and First Longest word found** -- *confused me ...what
you were trying to say.
tracking can be done but become little difficult if input is something like
this :-
best
bestest
test
testbest
testbesttest
Thank you to understanding Me..
Well For Trie.. I don't hv to say much more to say except the basic need
which says Collect Common Prefix . If it didnt ring the bell.. than Hv a
look at strings MADAM and MADAMIAMADAM stored in your TRIE .. Just draw a
pictorial representation.
On Wed, May
think in term of following input case :-
best
test
testbest
than i guess you will come to knw why i got confused at first place.
*madammadam*
*testtesttest *
ignore this type of test case.
On Wed, May 23, 2012 at 12:40 AM, Prem Krishna Chettri
hprem...@gmail.comwrote:
Thank you to
17 matches
Mail list logo