Thanks
On Wed, Jun 29, 2011 at 2:45 AM, aditya kumar
aditya.kumar130...@gmail.comwrote:
@sagar : it works perfectly fine.
On Tue, Jun 28, 2011 at 3:29 PM, sagar pareek sagarpar...@gmail.comwrote:
Check out my solution above :)
Its reversing the string
On Tue, Jun 28, 2011 at 1:56
@bittu :
In your first approach which u pointed out :
What if the minimum element is poped out of the stack ?? We may have
to search the whole stack to get the minimum element. O(n) in
worst case
In your second approach which u pointed out :
If u use 2 stacks, consistency of 2 stacks in
http://geeksforgeeks.org/?p=12000
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/OnLux79bj3MJ.
To post to this group, send email to
scanf returns no of integers it read,not the read integer.
On 6/26/11, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote:
It breaks out correctly when test condition value is 0 i.e when value of t
is 1
On Sat, Jun 25, 2011 at 4:41 PM, sunny agrawal
sunny816.i...@gmail.comwrote:
No,
In TRIE , we can store nodes by characters. So it is very easy to search by
names and hence their corresponding numbers :) .
TRIE saves a lot memory coz it stares a character only once.
LIKE :-
if i want to save sagar with phone no. 123456789 then we store it in TRIE
as :
s-NULL
|
a-NULL
|
Sorry for the previous post it got a mistake here take a look again :-
In TRIE , we can store nodes by characters. So it is very easy to search by
names and hence their corresponding numbers :) .
TRIE saves a lot memory coz it stares a character only once.
LIKE :-
if i want to save sagar
Thanks for the link!
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/xHZEwuTNT2kJ.
To post to this group, send email to algogeeks@googlegroups.com.
To
I wonder why people have discarded the idea of Hash map here.
Searching is obviously the most important task here and if we are to
assume that names can be uniformly hashed over a table of 1000 rows
with each row containing 1000 names each.
Further optimization can be achieved by having names
Well, according to gnu standards, it's never safe to depend on the order of
evaluation of the arguements passed to a function. So the output in the
above case would vary from compiler to compiler
Source:
http://gcc.gnu.org/onlinedocs/gcc/Non_002dbugs.html
read the second last point
--
You
1. write iterative program to find if a binary tree is binary search tree or
not.
2. write iterative program to convert a binary tree into its mirror image.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web
@rizwaan u r ryt
bt i want a O(n) soln ..
whats say
On Wed, Jun 29, 2011 at 2:55 PM, rizwan hudda rizwanhu...@gmail.com wrote:
http://ideone.com/MSLXT
The constraints are so less that you can brute force the solution..N100.
My solution is O(N^3)
On Thu, Jun 30, 2011 at
For 1. you need an in-order traversal. During the visit check to see
that each successive key is non-decreasing.
For 2. you need a post order traversal. During the visit swap the left
and right child pointers.
Now you can look up the standard algorithms for these traversals.
On Jun 30, 3:34
@samby
You are wrong anyway. Main problem is to reduce memory while storing phone
numbers.
We have 1 million of phones, they have many common prefixes which can be
addressed by trie.
For storing names, you may use any data structure which is best for the
particular problem.
Key is name, and
@Navneet
Please read problem again - it is about memory efficient storing.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/-hsmsOgm2YUJ.
To post to this
for 1 i did implement exactly the same algorithms.
and for 2 i donot know why but at that time i was not able to implement it
iteratively and hense implemented its recursive version only.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To
guy can anybody reverse without taking 0 extra variables ?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
We need at least one variable - loop counter. All other can be done via XOR.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/AzSS4tMoDlYJ.
To post to this
@ juver++ :
that i have already done.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For
On Tue, Jun 28, 2011 at 3:04 PM, sagar pareek sagarpar...@gmail.com wrote:
I have 1 more solution :-
#includestdio.h
#includestring.h
main()
{
int i,j,l;
char arr[100];
printf(Enter the string\n);
fgets(arr,100,stdin);
for(i=0,l=strlen(arr),j=l;i=l/2;i++)
{
arr[j--]=arr[i];
1. check here http://ideone.com/VjjqN
*int isBSTiterative(Tnode *root) {*
*int prev = -9;*
*Tnode *node = NULL;*
*while (root) {*
*push(root);*
*if (root-left == NULL) {*
**
*do {*
*node = pop();*
*if
1.
int chk_bst(node *root)
{
if(root)
{
enqueue(root);
while(!isempty())
{
p=dequeue();
if(p-left)
{
if(!(p-left-data p-data))
return 0;
enqueue(p-left);
}
if(p-right)
{
if(!(p-right-data = p-data))
return 0;
enqueue(p-right);
Try traversing in LEVEL order and maintain array for each level...(Levels
can be found by height of tree)
then try by calculating sums starting from root(level zero) to higher level.
Its typical to explain here but i found it as a solution and that will
definitely found the solution.
On Thu, Jun
Oh I got it.
If ( interview at google)
{
Map reduce
} else if(interview at yahoo) {
Hadoop
} else {
Your personal preference.
}
On Thu, Jun 30, 2011 at 4:02 AM, bittu shashank7andr...@gmail.com wrote:
1.Use Haddop Map Reduce Framework .Obviously We Need Distributed
Algo we will make
Here is one approach which works :)
Traverse the list from a pointer name ptr
when encounter odd then start traversing from a tmp pointer (start point is
ptr-next) to find even no. when find it swap the numbers.
then again start forwarding ptr. If during traversing ptr==tmp make
flag=0(at start
can we not use count sort because of O(n) .?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
Check this
http://ideone.com/1I40z
On Wed, Jun 29, 2011 at 8:04 PM, Nishant Mittal
mittal.nishan...@gmail.comwrote:
segregate even and odd nodes in a singly linked list.Order of even and
odd numbers must be same...
e.g:-
i/p list is 4-1-3-6-12-8-7-NULL
o/p list 4-6-12-8-1-3-7-NULL
--
@sagar pareek
If there are more fields in the node like:
struct node{
int data;
float mark;
char ch;
struct node *link;
};
Here swapping *data* alone will corrupt the list right!!
On Thu, Jun 30, 2011 at 4:38 PM, sagar pareek sagarpar...@gmail.com wrote:
Here is one
what is meaning of (null) in d output in cnd what r d possible
reason nd causes for dt
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group,
somewhere i read dt conditional compilation such as #if and #elif etc
cn only use constant expressions and previously defined macrosthey
cant use variables cz preprocessng is done b4 compilation...
bt whn i try it on gcc and vc both r compiling it with variables abs.
fyneven disabling
1 more thngif its possible to eval. variable expression lyk abv...
thn...
int i=2;
#if i==2
printf(hi);
#else
printf(bye); //prints byei think it shld print hi...
#endif
even this code prints bye.
int i=3;
#if i==2
printf(hi);
#else
printf(bye);
#endif
On Thu, Jun 30, 2011 at
My approach :
int FindPath(Node n , sum s )
{
FindPath(n-left , s ) ||
FindPath(n-right , s) ||
OneOf { a1 = AllSumsFromLeafToRoot( n-left ) } + n-value +
Oneof { a2 = AllSumsFromLeafToRoot( n-right ) == s ) }
// Use a1 and a2 to find out the actual path
}
Here all possible
Hello,
I've been working on a problem in which I want to generate half,
partial, and full round-robin schedules for teams. The half roundrobin
was no problem, and the full can be done by repeating the process and
by checking who was home/away in the first half roundrobin and
flipping it in the
Any idea how to solve this problem?
I am currently using graph and counting adjacent edges for the index.
1 2
\
\
3
eg for this graph structure 2 will have maximum possible friends.I am still
sorting out the bugs in my code.
Anybody has better solution?
--
Saurabh Singh
B.Tech (Computer
Is it possible to create a binary search tree (not binary tree) from post
order traversal only?
If give, how and if not please give reason/counter examples.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
if BST contains integers then sort the postorder traversal which will
give you inorder traversal...
On Jun 30, 6:27 pm, oppilas . jatka.oppimi...@gmail.com wrote:
Is it possible to create a binary search tree (not binary tree) from post
order traversal only?
If give, how and if not please give
it can be done without sorting(Finding any other traversal)
Do it recursively,
last element of the traversal will be head, and now if you will see in the
traversal left part of the traversal will be its LST and Right will be RST
(except Head) only thing you need to find will be the index of the
Problem Link ?
On Thu, Jun 30, 2011 at 6:48 PM, saurabh singh saurab...@gmail.com wrote:
Any idea how to solve this problem?
I am currently using graph and counting adjacent edges for the index.
1 2
\
\
3
eg for this graph structure 2 will have maximum possible friends.I am still
very sorry..
https://www.spoj.pl/problems/socialne/
https://www.spoj.pl/problems/socialne/apologies once again
On Thu, Jun 30, 2011 at 7:23 PM, sunny agrawal sunny816.i...@gmail.comwrote:
Problem Link ?
On Thu, Jun 30, 2011 at 6:48 PM, saurabh singh saurab...@gmail.comwrote:
Any idea
http://www.spoj.pl/problems/SOCIALNE/
On Thu, Jun 30, 2011 at 7:25 PM, saurabh singh saurab...@gmail.com wrote:
very sorry..
https://www.spoj.pl/problems/socialne/
https://www.spoj.pl/problems/socialne/apologies once again
On Thu, Jun 30, 2011 at 7:23 PM, sunny agrawal
I am unable to find a test case where this particular approach fails( I
hardly thinks it's correct but anyway here it is).
We make the last element the root of the BST.
And keep inserting each element one by one just like normal binary tree
insertion.
This will take O(n^2) time in worst case(
Check this http://ideone.com/ARsJ1
On Thu, Jun 30, 2011 at 7:48 PM, oppilas . jatka.oppimi...@gmail.comwrote:
I am unable to find a test case where this particular approach fails( I
hardly thinks it's correct but anyway here it is).
We make the last element the root of the BST.
And keep
@kartik sachan:
I just compared your output file with the output file
for this test case
5 1 2 3 4 5
19 ab ab 100 50
20 20 20 75 75
10 0 ab 88 0
13 12 15.5 88 99
12 7 9 66 66
11 ab ab 99 100
your code outputs FAILED, 4.35 but actually he's PASSED, 7.20
I think you are assuming he's fail if he
circular linklist containing three pointers start,end,current
On 6/27/11, vaibhav agarwal vibhu.bitspil...@gmail.com wrote:
@radha k but i think we need to store the bottom of the stack for deleting
the last node in O(1).
as we can click the redo or undo fixed number of times
and we would
Hello Associates,
Wishes for the day!!
Please go through the below requirement and let me know if you have any
consultants for the below position?
*Job Title: Java Developer
Location: Silver Spring, MD
Duration: 7-12 Months*
Must have skills:
Java 5; JEE technologies
Expertise with Spring,
banned
On Thu, Jun 30, 2011 at 10:13 PM, Leon Parker leon.pan...@gmail.com wrote:
Hello Associates,
Wishes for the day!!
Please go through the below requirement and let me know if you have any
consultants for the below position?
*Job Title: Java Developer
Location: Silver Spring, MD
banned in 6 mins pretty cool... :)
On Thu, Jun 30, 2011 at 10:19 PM, shady sinv...@gmail.com wrote:
banned
On Thu, Jun 30, 2011 at 10:13 PM, Leon Parker leon.pan...@gmail.com wrote:
Hello Associates,
Wishes for the day!!
Please go through the below requirement and let me know if you have
stack is the best option, isnt it ? O(1) for both operations.
On Thu, Jun 30, 2011 at 9:55 PM, Jitendra singh jsinghrath...@gmail.comwrote:
circular linklist containing three pointers start,end,current
On 6/27/11, vaibhav agarwal vibhu.bitspil...@gmail.com wrote:
@radha k but i think we
can anybody give an example...pls..
On Thu, Jun 30, 2011 at 9:26 AM, Jitendra singh jsinghrath...@gmail.comwrote:
kthlargest(a[],b[],lefta,righta,leftb,rightb,k)
{
mida=lefta+(righta-lefta)/2;
midb=leftb+(rightb-leftb)/2;
if(a[mida]bmidb])
null macro is defined as #define NULL (void*)0..is there any
difference in null macro definition in c and c++?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from
@Jitendra: where r u using k in the first call?
On Jun 30, 8:56 am, Jitendra singh jsinghrath...@gmail.com wrote:
kthlargest(a[],b[],lefta,righta,leftb,rightb,k)
{
mida=lefta+(righta-lefta)/2;
midb=leftb+(rightb-leftb)/2;
if(a[mida]bmidb])
stack, real implmentation is also stack AFAIK
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
On Thu, Jun 30, 2011 at 10:34 PM, shady sinv...@gmail.com wrote:
stack is the best option, isnt it ? O(1) for both operations.
On Thu, Jun 30, 2011 at
we can convert all rows in an equivalent integer and then sort all numbers and
for(int i=1;i=n;i++)
{
if(sorted[i]==sorted[i-1])
prinf(sorted[i]);
}
On 6/28/11, sunny agrawal sunny816.i...@gmail.com wrote:
@Ankit
if N is large how will you hash the rows, numbers will be very large
can
heres the code: http://ideone.com/aiG1m
using the algo from
http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/
On Jun 21, 11:31 pm, Swathi chukka.swa...@gmail.com wrote:
Does any one know how to return the Longest palindrome in a string in
O(n).
From
any1???
On Thu, Jun 30, 2011 at 12:45 AM, harshit pahuja hpahuja.mn...@gmail.comwrote:
@rizwaan u r ryt
bt i want a O(n) soln ..
whats say
On Wed, Jun 29, 2011 at 2:55 PM, rizwan hudda rizwanhu...@gmail.comwrote:
http://ideone.com/MSLXT
The
lets take the example {1,2, 10, 2, 3, 5, 1, 1,2,3,5,2} clearly min
distance is 1 between a=2 b=5
take variables current=-1 min=INT_Max
so we start from last element say its index is last which is array
size -1 check it with a b if its equal to any of these then check
current !=-
no difference
On Thu, Jun 30, 2011 at 11:24 PM, simran ngxprerna2...@gmail.com wrote:
null macro is defined as #define NULL (void*)0..is there any
difference in null macro definition in c and c++?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks
program 1;
output :1
int main()
{
int i;
i= 1,2,3;
printf(i:%d\n,i);
return 0;
}
program 2;
output: ERROR
int main()
{
int i=1,2,3;
printf(i:%d\n,i);
return 0;
}
pls explain
--
You received this message because you
this code gives an error ([Warning] passing arg 1 of `maxdiff' makes integer
from pointer without a cast) . Please explain the reasons.
#includestdio.h
#includeconio.h
int maxdiff(int );
main()
{
int p,arr[]={2,4,1,6,23,4};
p=maxdiff(arr);
printf(\n MAX Diff is \t %d,p);
@harry: it ll b btr if u go to this link n clr ur doubts link :
http://en.wikipedia.org/wiki/Comma_operator
On Fri, Jul 1, 2011 at 3:56 AM, hary rathor harry.rat...@gmail.com wrote:
program 1;
output :1
int main()
{
int i;
i= 1,2,3;
printf(i:%d\n,i);
int maxdiff(int );
int maxdiff(int arr[]);
The signatures of maxdiff function are not the same.
On Fri, Jul 1, 2011 at 6:53 AM, ashwini singh asingh...@gmail.com wrote:
this code gives an error ([Warning] passing arg 1 of `maxdiff' makes
integer from pointer without a cast) . Please
still it's not working
On Thu, Jun 30, 2011 at 4:42 PM, Rujin Cao drizzle...@gmail.com wrote:
int maxdiff(int );
int maxdiff(int arr[]);
The signatures of maxdiff function are not the same.
On Fri, Jul 1, 2011 at 6:53 AM, ashwini singh asingh...@gmail.com wrote:
this code gives an
actually u r passing arr,and receiving arr[] which actually receives the
first element address. So arr will be a reference to first address. so its
size will be 4 bytes and arr size will also be 4 bytes. so ur len contains
only 1. so ur loop runs only once.i hope it clears.
On Thu, Jun 30, 2011
check this code http://ideone.com/rX130
compares k/2 values of each array taking care of extremes.
On Jun 24, 9:48 pm, Decipher ankurseth...@gmail.com wrote:
Can anybody please explain how to solve this question with logarithmic
time complexity ?
Write the code/algorithm to find the k-th
i think it will take a garbage value for i because these are
preprocessor directives.
On Jun 30, 4:46 pm, himanshu kansal himanshukansal...@gmail.com
wrote:
1 more thngif its possible to eval. variable expression lyk abv...
thn...
int i=2;
#if i==2
printf(hi);
#else
printf(bye);
please suggest me or mail me a good interview questions ebook
thanks
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
Rujin is right, here is the code which compiles..
vishal@ubuntu:~/progs/c\ 11:04:37 AM $ cat alg.c
#includestdio.h
int maxdiff(int arr[]);
int main()
{
int p,arr[]={2,4,1,6,23,4};
p=maxdiff(arr);
printf(\n MAX Diff is \t %d,p);
return 0;
}
int maxdiff(int arr[])
{
why is the value of sizeof(arr) in maxdiff function = 4 ?
where as in main function it is 24
On Fri, Jul 1, 2011 at 11:05 AM, Vishal Thanki vishaltha...@gmail.comwrote:
Rujin is right, here is the code which compiles..
vishal@ubuntu:~/progs/c\ 11:04:37 AM $ cat alg.c
#includestdio.h
int
67 matches
Mail list logo