hmmm ... Atleast I was of the opinion that such nos. were required and hence
was thinking fib is not the thing. Thanks for clarifying.
On Wed, Jun 9, 2010 at 8:02 AM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote:
Fib comes because she wants the number of such sequences
--
I have a stream of numbers coming one by one from a computer generated
program. I know that these numbers will be between 0 and 1. In
minimum time how can I sort them. Space is no constraint.
Later we have to try and optimize the space to as minimum as possible
--
You received this message
Whats the logic behind using Fibonacci in determining the number of such
sequences?
-Sundeep.
On Wed, Jun 9, 2010 at 8:02 AM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote:
Fib comes because she wants the number of such sequences
--
--
Rohit
can any one tell me how to code for vertical level traversal of a
binary tree?
1
/\
2 3
/ \/ \
here is a sel explainatory algo
given:
abcd1234
abc1d234
ab1c2d34
a1b2c3d4
here is the link for the code : http://codepad.org/SZnufGc6
--
Regards
Jitendra Kushwaha
MNNIT, Allahabad
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post
Using an n*n array, am afraid, will not solve the problem, since its not
capable to capture transitivity.
Consider the case:
v1=v2
v3=v2
v3!=v1
we will place 0 in arr(1,2) arr(2,1) for v1=v2
we will place 0 in arr(2,3) arr(3,2) for v3=v2
and place 1 in arr(1,3) and arr(3,1) for v3!=v1.
no
But what if the same same problem is extended for multiple lists. As the
individual lists have already been sorted, is there any efficient way or any
other sorting algo which exploits this fact.
On Tue, Jun 8, 2010 at 10:56 PM, divya jain sweetdivya@gmail.comwrote:
merging as in merge sort.
First 20 fibo no as follows with binary form
0 = 0
1 = 1
1 = 1
2 = 10
3 = 11
5 = 101
8 = 1000
13 = 1101
21 = 10101
34 = 100010
55 = 110111
89 = 1011001
144 = 1001
233 = 11101001
377 = 10001
610 = 1001100010
987 = 011011
1597 = 1100001
2584 = 10111000
4181 =
@debajyoti: read the prob before posting
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14
On Wed, Jun 9, 2010 at 2:37 PM, Debajyoti Sarma
I had answered this question(of multiple lists) 2 or three days back.
Go into the archive if u wanna see :P
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14
On Wed,
@junta : are fibonacci sequence is the answer of the prob, it is not used :D
--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14
On Wed, Jun 9, 2010 at 9:13 PM, Rohit
multiply the no. with 10 nd store in temp. now subtract no from temp. check
if the decimal part is zero if yes. then 1st digit after decimal is
recurring. if no. multiply the no with 100 and repeat . if this time decimal
part is zero then 2 digits after decimal r recurring nd so on..
On 8 June
Below iterative solution of the tower of hanoi problem...
#include stdio.h
#include stdlib.h
int main()
{
int n, x;
printf( How many disks? );
scanf( %d, n );
printf(\n);
for (x=1; x (1 n); x++)
printf( move from tower %i to tower %i.\n,
(xx-1)%3,
@vadivel and anand
{ 1,2,3 } is *isomorphic* to { 1,3,2 }
{ 1,2,3,4,5,6,7 } is *isomorphic* to { 1,3,2,7,6,4,5 }
{ 1,2,3,4,5,6,7 } is NOT *isomorphic* to { 1,3,2,4,5,6,7 }
so its nt necessary that right and left will interchange. it may or may not.
if all right and left are interchanged then it
Its not O(n) time.
Anurag Sharma
On Wed, Jun 9, 2010 at 5:46 PM, Jitendra Kushwaha
jitendra.th...@gmail.comwrote:
here is a sel explainatory algo
given:
abcd1234
abc1d234
ab1c2d34
a1b2c3d4
here is the link for the code : http://codepad.org/SZnufGc6
--
Regards
Jitendra Kushwaha
Assuming that the only moves you can make are to pour the contents of
one jug into another until either the source is empty or the
destination is full, the following are the only positions possible:
0: initial position (15,0,0)
1: starting from 0, pour 10
See http://en.wikipedia.org/wiki/Tower_of_Hanoi#Binary_solutions
Dave
On Jun 9, 10:37 am, Jitendra Kushwaha jitendra.th...@gmail.com
wrote:
Below iterative solution of the tower of hanoi problem...
#include stdio.h
#include stdlib.h
int main()
{
int n, x;
printf( How many disks?
The Definition of isomorphic trees given in the first post is incomplete
We say two rooted unordered trees are isomorphic if
1. a tree with a single node (the root) is only isomorphic to a tree with a
single node;
2. two trees with roots A and B, none of which is a single-node tree, are
isomorphic
@ anurag we can do operation only at bit level sowe will need o(32n)
although it is also O(n) bt if word size is more then its quite inefficient
so suggest 4 that
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send
1
/\
2 3
/ \/ \
45 67
print
4 2156
One question:
No x = 23.34563456
temp = x X 10 = 233.4563456
temp = temp - x = 210.11071104
decimal part zero? No.
Now multiply the no. with 100. Which no? original x (= 23.34563456) or
new no. temp (=210.11071104)?
On Jun 9, 8:12 pm, divya jain sweetdivya@gmail.com wrote:
multiply the no.
Do you have 'parent pointers' stored at every node?
Anurag Sharma
On Wed, Jun 9, 2010 at 2:26 PM, sharad sharad20073...@gmail.com wrote:
can any one tell me how to code for vertical level traversal of a
binary tree?
1
For multiple ordered lists you can build a single Max heap out of elements
from all this list and Process as its done in heapsort
On Wed, Jun 9, 2010 at 9:14 PM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote:
I had answered this question(of multiple lists) 2 or three days back.
Go into the
is-isomorphic(t1, t2) {
t1ld = t1-left-data
t2ld = t2-left-data
//.
//base case for null or replace by sentinels and check
if( t1ld == t2ld t1rd == t2rd)
return is-isomorphic(t1ld, t2ld) return is-isomorphic(t1rd, t2rd)
if (t1ld == t2rd t1rd == t2ld)
Proceed with the above logic of 2D array and only fill the matrix
considering only the equality constraints ( xi=xj)
Using the Floyd warshall All pair shortest path algorithm, we can know the
all reachable places from every other place.
Now fill the matrix as per the inequality constraints(xi!=xj)
Guys
We can solve this in O(n) time like this:
Let me say total elements in array is 2N such that 1 to N are a's and N
+1 to 2N (which I will again refer to as 1 to N) are b's
Observation:
If an element is on first 1 to N (an 'a') and has index i then in the
final array its position index (in
In case of array representation of this binary tree where we can traverse
through all the leaf nodes and move to their parents, this problem becomes
quite easy.
for the example stated consider its array representation
arr[]={1,2,3,4,5,6,7} and take another array marked[7]={false} indicating
but you have already given the range of numbers from 1 to 1 for which I
think it should work pretty fine.
We can just keep a count of every number arriving in an array since we know
its in the range 1..1 and later get the sorted array accordingly
repeating the elements that many times. Its
As per @Algoose's explanation, this can be found using the algorithm
to comapre if 2 binary trees are equal (quite often asked and found in
net). In this we generally go recursive and say
T1 is equal to T2
if T1=T2
and same holds for T1-Left, T2-Left (recursive call on left tree)
and same holds
multiply the original number x=23.34563456
Anurag Sharma
On Wed, Jun 9, 2010 at 10:36 PM, Veer Sharma thisisv...@rediffmail.comwrote:
One question:
No x = 23.34563456
temp = x X 10 = 233.4563456
temp = temp - x = 210.11071104
decimal part zero? No.
Now multiply the no. with 100. Which
Thanks Sharad
On Wed, Jun 9, 2010 at 10:01 PM, sharad kumar sharad20073...@gmail.comwrote:
1
/\
2 3
/ \/
can u reduce the size by making use of bucket sort
On Wed, Jun 9, 2010 at 5:01 PM, sharad sharad20073...@gmail.com wrote:
I have a stream of numbers coming one by one from a computer generated
program. I know that these numbers will be between 0 and 1. In
minimum time how can I sort
32 matches
Mail list logo