Re: [algogeeks] Re: Array Ranking Problem

2010-12-23 Thread Ankur Khurana
how will you choose that ?? without sorting . can you please mention what method you intend to use to achieve that purpose ? On Fri, Dec 24, 2010 at 8:16 AM, Terence wrote: > @Ankur: > It is just 0/1 knapsack problem: >    Choose a subset of the questions with sum of scores not exceeding (Total >

Re: [algogeeks] Re: Array Ranking Problem

2010-12-23 Thread Terence
@Ankur: It is just 0/1 knapsack problem: Choose a subset of the questions with sum of scores not exceeding (Total Score - Pass Score), while maximize the sum of time of the subset. So I do not think O(nlogn) greedy algorithm will solve this problem. On 2010-12-23 23:38, Ankur Khurana wrote:

Re: [algogeeks] random function

2010-12-23 Thread Puneet Ginoria
There is a book called "The art of computer programming" by donald knuth. He had discussed the random function in great detail. On Tue, Dec 21, 2010 at 8:06 PM, snehal jain wrote: > How do you write your own random function? > > -- > You received this message because you are subscribed to the Go

Re: [algogeeks] Simulation algo

2010-12-23 Thread Chi
Ant-Colony-Optimization - Ursprüngliche Mitteilung - > Hello, I'm looking for an algorithm of computer science simulation and > specifically the discrete simulation of any model. Please > All the best. > > -- > You received this message because you are subscribed to the Google > Groups "

[algogeeks] Simulation algo

2010-12-23 Thread Glauben BI
Hello, I'm looking for an algorithm of computer science simulation and specifically the discrete simulation of any model. Please All the best. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@goog

[algogeeks] Re: mapping of 2-d arrays

2010-12-23 Thread juver++
Represent your pair in some radix system. So Hash=(a*Base + b) mod SomePrime. -- 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 alg

[algogeeks] Re: mapping of 2-d arrays

2010-12-23 Thread mohit mittal
how to use hash table i have a pair (a,b) with which i want to use. if i use hash function like a+nb there will be number of clashes. also , i have tried map stl in some of programs and most of them give TLE. So, is there a better way for this or i have to look a different approach to this. Thank

Re: [algogeeks] Re: Array Ranking Problem

2010-12-23 Thread Nikhil Agarwal
@Ankur Now its clear.:) On Thu, Dec 23, 2010 at 10:25 PM, Ankur Khurana wrote: > i will try to elaborate or rewrite tat part > > On Thu, Dec 23, 2010 at 10:25 PM, Ankur Khurana > wrote: > > wverything i mentioned above can be done in O(n) but sorting part is > > nlogn . so that is what i was say

Re: [algogeeks] Find the element with more than n/k occurrences

2010-12-23 Thread Saurabh Koar
ya,u r right.U can find max and min by O(n) time.Bt I already mentioned that there will be additional space complexity.If u want to avoid that u can follow juver++ approach other than ur solution. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" grou

Re: [algogeeks] Re: Array Ranking Problem

2010-12-23 Thread Ankur Khurana
i will try to elaborate or rewrite tat part On Thu, Dec 23, 2010 at 10:25 PM, Ankur Khurana wrote: > wverything i mentioned above can be done in O(n) but sorting part is > nlogn . so that is what i was saying. can you specify where i was not > clear ? > > On Thu, Dec 23, 2010 at 9:22 PM, Nikhil A

Re: [algogeeks] Re: Array Ranking Problem

2010-12-23 Thread Ankur Khurana
wverything i mentioned above can be done in O(n) but sorting part is nlogn . so that is what i was saying. can you specify where i was not clear ? On Thu, Dec 23, 2010 at 9:22 PM, Nikhil Agarwal wrote: > @ankur can you hint your nlogn solution? > > On Thu, Dec 23, 2010 at 9:08 PM, Ankur Khurana

Re: [algogeeks] Find the element with more than n/k occurrences

2010-12-23 Thread snehal jain
@saurabh for counting sort we shd know the range.. isnt der ny other better approach.. On Wed, Dec 22, 2010 at 1:47 PM, Nikhil Agarwal wrote: > @saurabh : This solution is applicaiton to some special K .Not in > general .sorry. > > On 12/22/10, Saurabh Koar wrote: > > @Nikhil: What if the array

[algogeeks] Re: matrix [MS]

2010-12-23 Thread Nik_nitdgp
Can you please explain your logic for the following example: W W W W B B B B B B B B W B B B On Oct 27, 11:00 am, rahul patil wrote: > hello all, > > suppose given matrix contains the 0(white) and 1(black) > > 0 > 11100 > 00100 > 11100 > 01100 > > create the matrix R as follows >

Re: [algogeeks] Re: difference x

2010-12-23 Thread Amit Jaspal
@ jai nice solution I think for O(n) solution we will have to use extra array. Otherwise we will have to do this in O(nlogn). Correct me if i am wrong. On Thu, Dec 23, 2010 at 1:04 PM, jai gupta wrote: > make another array(B) from (A) with all elements negated > now find one element from B an

Re: [algogeeks] Re: Array Ranking Problem

2010-12-23 Thread Nikhil Agarwal
@ankur can you hint your nlogn solution? On Thu, Dec 23, 2010 at 9:08 PM, Ankur Khurana wrote: > it is just like 0/1 knapsack problem with maximum weight of knapsack > as 40. but in this case that is minimum that we have to calculate. > calculate marks/time for every element . then try finding th

Re: [algogeeks] Re: difference x

2010-12-23 Thread Nikhil Agarwal
Divya and saurabh please post your working solution different from that of Bhupen's. On Thu, Dec 23, 2010 at 1:04 PM, jai gupta wrote: > make another array(B) from (A) with all elements negated > now find one element from B and one from A whose sum is x or -x. This can > ofcourse be done in O(

Re: [algogeeks] Re: TopCoder Bad Neighbour

2010-12-23 Thread mohit ranjan
@Amit, please refer http://www.topcoder.com/tc?module=Static&d1=match_editorials&d2=tccc04_online_rd_4 the recurrence relations is f(x) = max(f(x-2)+element[x], f(x-3)+element[x-1]) you are missing the 2nd part here Mohit On Wed, Dec 22, 2010 at 9:55 PM, Amit Jaspal wrote: > Hi all, > > I w

Re: [algogeeks] Re: Array Ranking Problem

2010-12-23 Thread Ankur Khurana
it is just like 0/1 knapsack problem with maximum weight of knapsack as 40. but in this case that is minimum that we have to calculate. calculate marks/time for every element . then try finding the elements with max value/time to fulfill the quota of marks. i dont know if this can be done in O(n) b

[algogeeks] Re: Array Ranking Problem

2010-12-23 Thread Davin
Thanks for reply. I am looking for O(n) for solution. Davin On Dec 23, 8:29 pm, snehal jain wrote: > hint : use dp > > > > > > > > On Thu, Dec 23, 2010 at 8:30 PM, Davin wrote: > > Marks for Questions(1,6): {10,15,20,25,10,20} > > Time for Each Questions(1,6) : { 2, 4,3,4, 2,4} > > Passing Mark

Re: [algogeeks] Re: Array Ranking Problem

2010-12-23 Thread snehal jain
hint : use dp On Thu, Dec 23, 2010 at 8:30 PM, Davin wrote: > Marks for Questions(1,6): {10,15,20,25,10,20} > Time for Each Questions(1,6) : { 2, 4,3,4, 2,4} > Passing Marks : 40 Out of 100 > > Find Questions with minimum time to pass the exam? > > On Dec 23, 7:04 pm, juver++ wrote: > > Please

Re: [algogeeks] Re: difference x

2010-12-23 Thread snehal jain
bhupendra's solution is right.. On Thu, Dec 23, 2010 at 1:04 PM, jai gupta wrote: > make another array(B) from (A) with all elements negated > now find one element from B and one from A whose sum is x or -x. This can > ofcourse be done in O(n). > > -- > You received this message because you

[algogeeks] Re: Array Ranking Problem

2010-12-23 Thread Davin
Marks for Questions(1,6): {10,15,20,25,10,20} Time for Each Questions(1,6) : { 2, 4,3,4, 2,4} Passing Marks : 40 Out of 100 Find Questions with minimum time to pass the exam? On Dec 23, 7:04 pm, juver++ wrote: > Please clarify the problem statement. Provide example. > From the first view problem

[algogeeks] Re: Amazon Interview Question about Linked Lists

2010-12-23 Thread soundar
@shiva , U didn't check for the cycles.Since in question it is never mentioned about cycles u can add few steps to check cycles. (eg) 1 > 3 -> 5 > | | | | | | 4-3--3 -- You received this message because you are subscribed to the Google Groups "Algorith

[algogeeks] Re: Array Ranking Problem

2010-12-23 Thread juver++
Please clarify the problem statement. Provide example. >From the first view problem seems to be unclear. -- 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

[algogeeks] Array Ranking Problem

2010-12-23 Thread Davin
Problem Definition : Find minimum time X from set of questions to pass the exam : Input : Array of Marks [0, n-1] corresponding Array of Time of Each Questions[0, n-1]. Thanks for help in advance. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" gr

Re: [algogeeks] how to delete a substring from a given string.???

2010-12-23 Thread Ankur Khurana
you can use direct c++ tem-plates. anyways , in c format. use strstr() to find the pointer to the substring present in the main given string. then just shift all the contents after the subtring to the starting of your substring. On Thu, Dec 23, 2010 at 3:47 AM, Ajay Kumar wrote: > i dont noe the