Hello everybody. I'm asked to find a 2 approximate solution to this
problem:
You’re consulting for an e-commerce site that receives a large number
of visitors each day. For each visitor i, where i € {1, 2 . n},
the site has assigned a value v[i], representing the expected revenue
that can be
#includestdio.h
int main()
{
char a,b;
printf(%d\n,12);
printf(%d\n,printf(%d,143));
printf(%d\n,scanf(%2d%3d,a,b));
}
y this prog is giving seg fault after all its o/p
--
You received this message because you are subscribed to the Google Groups
Algorithm
i knoe c++ well so i can understand java code bt
i m not able to understand this code so pl explain it or give algo
thnx in advance
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
Hi Sharad,
I suppose this is what you are looking for. Assume non-negative integers.
Otherwise, there are infinite possibilities.
#includeiostream
#includeset
#includevector
using namespace std;
vector vectorint allCombinations;
void findAllCombinations(vectorint elements, int left)
{
find the no. of bits set in a no. in logn time
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
%c is the format specifier for char.Provide space between them.
On Jun 22, 2:54 pm, sharad sharad20073...@gmail.com wrote:
#includestdio.h
int main()
{
char a,b;
printf(%d\n,12);
printf(%d\n,printf(%d,143));
printf(%d\n,scanf(%2d%3d,a,b));}
y this
i don't understand what this statement will do ?
scanf(%2d%3d,a,b);
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
prims and krushkal dont' work for directed graphs
On Tue, Jun 22, 2010 at 6:44 AM, Gene gene.ress...@gmail.com wrote:
On Jun 20, 7:48 am, jalaj jaiswal jalaj.jaiswa...@gmail.com wrote:
give an algo to find a minimum spanning tree of a directed graph ??
--
With Regards,
Jalaj Jaiswal
a bst is given whose leaf nodes having left as well as right pointers
not pointing to NULL. rather all the leaf nodes are forming a circular
doubly linked list. u have to calculate height of tree.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks
u r given a single linked list u have to make a minimally skewed tree
such that each child points to its parent..
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe
I think its due to typecasting of char to int
just change char a,b to int a,b
or
last line change inside scan %c
segementation fault will not come
as size of char is less than size of int
On Tue, Jun 22, 2010 at 3:37 PM, Shravan shravann1...@gmail.com wrote:
%c is the format specifier for
i am not getting any seg fault on gcc
any specific i/p you are giving for scanf ?
Mohit Ranjan
On Tue, Jun 22, 2010 at 2:54 PM, sharad sharad20073...@gmail.com wrote:
#includestdio.h
int main()
{
char a,b;
printf(%d\n,12);
printf(%d\n,printf(%d,143));
Which version of gcc are u using ? I do get a error in 4.3.2
If size of scanf's argument is smaller than format specified, behaviour is
undefined.
Hence implementation is free to choose a behaviour.
On Tue, Jun 22, 2010 at 3:37 PM, mohit ranjan shoonya.moare
h...@gmail.comwrote:
i am not
Assuming 32 bit integers:
n = ((x 1) 0x) + (x 0x)
n = ((n 2) 0x) + (n % 0x)
n = ((n 4) 0x0F0F0F0F) + (n 0x0F0F0F0F)
n = ((n 8) 0x00FF00FF) + (n 0x00FF00FF)
n = ((n 16) 0x) + (n 0x)
n now is the number of bits set in x. Time is O(1).
CFP: Optical SuperComputing Workshop 2010: Deadline Extension
3rd International Workshop on Optical SuperComputing in Bertinoro
(OSC10)
November 17-19, Bertinoro, Italy
http://www.cs.bgu.ac.il/~dolev/OSC10
SCOPE:
OSC, the International Workshop on Optical SuperComputing, is an
annual forum
For more such problems and solns
http://graphics.stanford.edu/~seander/bithacks.html
for (c = 0; v; c++)
{
v = v - 1; // clear the least significant bit set
}
O(k) -- no. of bits set in the number
--Koushik C
On Tue, Jun 22, 2010 at 7:16 PM, Dave dave_and_da...@juno.com wrote:
Given 23 chocolates and there are 7 kids. How many ways are there to spilt
the chocolates among the 7 kids? All of the chocolates must be distributed
and it can happen that some kids do not get any.
For example: first kid gets 23 chocolates and rest get none is one
possibility. First 6 kids get
x1+x2+x3+x4+x5+x6+x7=23,,,
noe no of solution is,,, of equation is,,
n+r-1C(COMBINATION )r-1 (n identical items to be distributed into R grups)
so ,, ans 23+7-1c7-1;(identical)
if unidentical case,
then each each cholate wud hav 7 options,,
so ,, ans -- 7^23 (different)
On Tue, Jun 22, 2010
(2^7-1)^23
On Tue, Jun 22, 2010 at 8:22 PM, Aarthi Thangamani
aarthi.thangam...@gmail.com wrote:
Given 23 chocolates and there are 7 kids. How many ways are there to spilt
the chocolates among the 7 kids? All of the chocolates must be distributed
and it can happen that some kids do not get
@Dhritiman
gcc 4.3.4
-
Mohit ran...@mohit-home ~
$ ./test
12
1433
1 // i/p given
2 // i/p given
2
-
Mohit Ranjan
On Tue, Jun 22, 2010 at 6:46 PM, Dhritiman Das dedhriti...@gmail.comwrote:
Which version of gcc are u using ? I do get a
How will you find the subarray whose sum is k in an array of negative and
positive numbers
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send
thnx Raajay n Jeeva for giving so clear explainations
bt actually my question is ...if i/p is 5 then u hve to print
1+4
1+1+3
1+1+1+2
1+1+1+1+1
1+2+2
1+4
2+3
and all such pairs giving 5
i hope i m clear this time
--
You received this message because you are subscribed to the Google Groups
@ Jeeva...abt ur soln
when a[1] comes i.e 2 so i think according to algo 10-2 i.e 8 must go in
plzz correct me if i wrongly understood it
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
Hi,
Given that u need to split 23 into 6 parts. Its all about placing + with
24 spots( wit 23 1's )(6 ,5...0). So, the answer is
Description :
1 1 1 1 1 1 1 1 1 1 1 1 .. 1
+ + +
1. Sharing with just one means there is no + - 24 C 0
2. Sharing with just
if we store the Binary tree in array as
array[1] = x1
array[2] = x2
array[3] = x3
array[4] = x4
array[5]= x5
array[6]= x6
array[7]=x7
x1 is first node at level 0 root node
x2 is left node and x3 is right node of x1 at level 1
x4 is left node and x5 is right node of x2 at level 2 and x5 is left
Hi Rohit,
Can you explain your approach a bit more?
On Sun, Jun 20, 2010 at 2:48 PM, Rohit Saraf
rohit.kumar.sa...@gmail.com wrote:
Why not just change the definition of when one number is bigger than another
and do normal sort ?
I guess that is better and simpler.
int HighestBitSet (unsigned int n)
{
double x;
int exp;
x = frexp((double)n, exp);
return exp-1;
}
To see how it works, look up the standard C++ function frexp.
Dave
On Jun 22, 2:37 pm, Anand anandut2...@gmail.com wrote:
How to find the Most significant bit position of a given
Let A[] be a array.
Step 1: Find Cumulative Sum array say C[]
if A[]={2,-1,3,5,6,-7,8}
C[]={0,2,1,4,9,15,18,16}
Now traverse through this C[] and keep storing C[i] in a BST.
Whenever C[j]-C[i] = K (We have found our needed subarray)
So for every element of C[] chk if C[i]-K is found in BST . If
Please send me a c++ code for a compressed trie.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
yes it must go into hashSet ...You have got it right.
On Tue, Jun 22, 2010 at 5:55 PM, sharad kumar sharad20073...@gmail.comwrote:
@ Jeeva...abt ur soln
when a[1] comes i.e 2 so i think according to algo 10-2 i.e 8 must go in
plzz correct me if i wrongly understood it
--
You received this
Two link lists are given ...check if one is reverse of other. Do it
without using extra space.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group,
coefficient of x^23 in (1 + x + x^2 + x^3 + ... + x^23) ^ 7
i.e. 29C23
--
Regards
Jitendra Kushwaha
MNNIT, Allahabad
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To
@ dave
how did u come to this formula... m nt getting the logic..
@ sathaiah
yes u r rite
On 22 June 2010 19:32, chitta koushik koushik.infin...@gmail.com wrote:
For more such problems and solns
Let m = 2^k - 1.
To check divisibility of n by m,
1. If n is zero, return true.
2. If n is negative, replace n with -n.
3. While n m, replace n with (n k) + (n m).
4. Return (n == m).
This is equivalent to the casting out nines algorithm to determine
if a number is a multiple of 9.
Dave
On
Did you actually try the code by hand on a number to see what it does?
If you do, you will see that the first statement replaces the bits in
each pair of bit positions with the number of bits in those positions.
The second adds the bits in each pair of pairs, replacing each nibble
with the number
Rohit's approach put into a typical c++ construct...
inline is_odd(int x)
{
return ((x 1) == 1);
}
struct new_compare {
bool operator () (int i, int j) {
bool b_i_odd = is_odd(i);
bool b_j_odd = is_odd(j);
if ((b_i_odd b_j_odd) || (!b_i_odd !b_j_odd))
36 matches
Mail list logo