Suppose u have n1 items of size s1,
n2 items of size s2 and n3 items of size s3. You'd like to pack
all of these items into bins each of capacity C, such that the
total number of bins used is minimized.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks
Priority Queue:
when popped ... returns the max priority element and if the priorities
of two or more elements are same...then they will popped as they are
inserted ..
when pushed the element : puts the element in the list according to the
priority...
For making priority queue into
amount displaced by (boat +man + suitcase) = amount displaced by
(boat+man) + amount displaced by suitcase
therefore no change of level...
With regards,
Praveen Raj
DCE-IT 3rd yr
735993
praveen0...@gmail.com
On Thu, Sep 15, 2011 at 4:24 PM, hary rathor harry.rat...@gmail.com wrote:
no
@jitesh rightly said... since there is no limit of depth...
we can go for BFS..
we can reduce space by comparing A's and C's profile...
whatever is common ... we can use it to find connection... between A and C
With regards,
Praveen Raj
DCE-IT 3rd yr
735993
praveen0...@gmail.com
does y goes to d of %*d and it print 5???i hav a doubt
On Fri, Oct 28, 2011 at 9:32 PM, amrit harry dabbcomput...@gmail.comwrote:
let this statement int x=100,y=5;printf(%*d,x,y);
in this line first x is assign to '*' and it become %100d
and it will padd 100 spaces before print. and if we
if length is even : then every element must occurs even times
if length is odd : then every element must occurs even times except one
element occurs odd...
With regards,
Praveen Raj
DCE-IT
735993
praveen0...@gmail.com
--
You received this message because you are subscribed to the Google
I think we could use Algorithm A* where in subgraph(G) maintains all the
paths to the required profile and subtree(Tr) gives us the optimal
path..
On Tue, Sep 13, 2011 at 5:43 PM, JITESH KUMAR jkhas...@gmail.com wrote:
Suppose you are visiting someone's profile in fb or linkedin, you get to
Greedy knapsack algorithm will work fine in this case as in each bin
n1s1+n2s2+..nrsr=C gives the optimal solution...
On Sat, Oct 29, 2011 at 4:34 AM, SAMMM somnath.nit...@gmail.com wrote:
Suppose u have n1 items of size s1,
n2 items of size s2 and n3 items of size s3. You'd like to
remains same
On Sat, Oct 29, 2011 at 12:21 PM, praveen raj praveen0...@gmail.com wrote:
amount displaced by (boat +man + suitcase) = amount displaced by
(boat+man) + amount displaced by suitcase
therefore no change of level...
With regards,
Praveen Raj
DCE-IT 3rd yr
735993
On 10/29/11, praveen raj praveen0...@gmail.com wrote:
Priority Queue:
when popped ... returns the max priority element and if the priorities
of two or more elements are same...then they will popped as they are
inserted ..
when pushed the element : puts the element in the list
You can do something like this:
( n* alpha) * ( m*alpha) *p
where 0alpha1 which maps product onto (0,1) interval. You can use
golden ration instead.
On Sat, Oct 22, 2011 at 9:45 PM, Aamir Khan ak4u2...@gmail.com wrote:
On Sat, Oct 22, 2011 at 9:04 PM, Mad Coder
yes 5 will be printed with 99 extra padding spaces.
On Sat, Oct 29, 2011 at 4:16 PM, rahul sharma rahul23111...@gmail.comwrote:
does y goes to d of %*d and it print 5???i hav a doubt
On Fri, Oct 28, 2011 at 9:32 PM, amrit harry dabbcomput...@gmail.comwrote:
let this statement int
yea, i'd go with greedy also. Fill bin with biggest size s1 as much
as possible (and same for other bins), then try to squeeze in next
biggest size s2, etc.
On Oct 29, 7:17 am, teja bala pawanjalsa.t...@gmail.com wrote:
Greedy knapsack algorithm will work fine in this case as in each bin
grt :)
With regards,
Praveen Raj
DCE-IT 3rd yr
735993
praveen0...@gmail.com
--
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
int func(int x)
{
int y=(1i)+(1j);
int z=xy;// if after bitwise and ..we get power of 2 then ...
we have to flip the bits..
if((z(z-1))==0)
return(x^y);
else
return x;
}
With regards,
Praveen Raj
DCE-IT
735993
praveen0...@gmail.com
--
You received
@Dave
Your solution works if the total no.of records(ssn numbers) is 1000 million.
But the question states that there are only 300 million numbers.
I think some modification is needed to your answer.
Correct me if i am wrong.
On Fri, Oct 28, 2011 at 2:04 AM, Dave dave_and_da...@juno.com wrote:
Assuming that we know the lower bound and upper bound of the range of
numbers (If not then we can determine it in one pass).
// Solution 1
let lb = lower bound, ub = upper bound, sum = 0;
for each number read from file - sum = sum - number + ub--;
at the end of for loop sum += lb; // This is
Given the SSN number is 9 digit number, the total space of possible numbers
are 1000million. So I think Dave's solution works.
On Sat, Oct 29, 2011 at 8:47 AM, bharat b bagana.bharatku...@gmail.comwrote:
@Dave
Your solution works if the total no.of records(ssn numbers) is 1000
million.
But
Hi All,
Please explain the difference between thread safe functions and re-entrant
functions with example.
Regards,
Aman.
--
AMAN AGARWAL
Success is not final, Failure is not fatal: It is the courage to continue
that counts!
--
You received this message because you are subscribed to the
I dont think the greedy approach gives the optimal solution here. Take the
below case -
Items are - 5, 4X2, 3, 2X2 and bins are of size 10. Greedy approach will
make choice in order -
bin1 - 5 + 4
bin2 - 4 + 3 + 2
bin3 - 2
Total bins required - 3
While in optimal solution -
bin1 - 5 + 3 +2
bi2 -
can someone give me a short explanation of Dave solution? I understand that
a[n%10] 1 is trying to find the bin which has less than what
maximum numbers it can hold and the bin is such that all numbers counted in
this have the same remainder when divided by 10. I do not get the
In a university, students can enroll in different courses. A student may
enroll for more than one course. Both students and courses can be identified
by IDs given to them. Design a data structure to store students, courses,
and the student-course relationships. You can use arrays, lists, stacks,
@Arun: If, for example, you find that a[54321] 1, you know that
there is an available number with those low order digits. Then you
look through the numbers with those low order digits to find an unused
set of high order digits. If, for example, on the second pass you find
that a[9876] is = 0,
@Ravindra: As given in the problem, the lower bound is 100,000,000 (my
interpretation of 9 digit number) and the upper bound is
999,999,999. Suppose that the numbers in the file are the first 300
million of these, i.e., 100,000,000 to 299,999,999. It is not obvious
that your algorithm finds a
Total possible 9 digit numbers = 10^9 2^32
We have = 3 X 10^8 numbers 2^32
notice that if we observe only 16 msb of social security numbers, we will
have atleast one combination (of the 16 most significant bits) which will
occur less that 2^16 times.
1. Now with this, we build an array A
Assuming students and courses have unique integer ids.
Use an adjacency list kind of data structure. Where the location of the
student/course in the list can be decided by hashing.
Essentially, there will be 3 hash tables,
1. To store student objects. Key - student id, value- student object.
2.
Create a hash table for students and another hash table for course..
For each record in the student table create a linklist that stores the list
of all the course in which the particular student in enrolled.
For each record in the course table create a linklist that stores the list
of all the
How abt this?
we need to swap only if both the bits are not same
if((n^(1i)n)!=(n^(1j)n))
n^=(1i)+(1j);
On 10/29/11, praveen raj praveen0...@gmail.com wrote:
int func(int x)
{
int y=(1i)+(1j);
int z=xy;// if after bitwise and ..we get power of 2 then ...
we have to flip
we need to swap only if both the bits are not same
if((n^(1i)n)!=(n^(1j)n))
n^=(1i)+(1j);
On 10/29/11, praveen raj praveen0...@gmail.com wrote:
int func(int x)
{
int y=(1i)+(1j);
int z=xy;// if after bitwise and ..we get power of 2 then ...
we have to flip the bits..
29 matches
Mail list logo