Hi Rohit & all, Sorry that there was a small typo in the 'n' 'm' texts. The example given by me is anyway the correct one. Sravan Reddy's solution worked fine.
On Jun 4, 10:08 am, rohit <rajuljain...@gmail.com> wrote: > i think solution would be like this > > eg: > A : 1 2 3 B: 0 1.5 4 5 9 > Output: > A can contain any combination of nos 0,1,1.5 > and B should contain 2 3 4 5 9 (in any order.) > > this example is given by ROSS itself. > > so sravanreddy solution is right , correct me if i'm wrong. > > On Jun 3, 8:07 pm, bittu <shashank7andr...@gmail.com> wrote: > > > > > > > > > @sravanreddy...logical bugs if A is size of n & B is size m from your > > example assuming n<m so if you want smallest m elements in A then u > > only capacity of n elements & didn't allocate memory so these elements > > initialized by INT_MIN for m-n nodes so thatarrayA can hold m > > smallest elements then what r u swapping u dude..isn't garbage > > value ?? you will get at 1st step only just run it ?? in you algo > > A_End=m-1(which 4th position inArraythat DNE)..?? & also you have to > > free memory for m-n inarrayB as it contains n largest elements . > > > take > > A= 1,2,3 n=3 > > B= 0,1,4,5,9 m=5 > > > after allocating memory toArrayA for m-n elements A will looks > > likes 1 2 3 INT_Max INT_Max > > now what you wants A should contains m smallest elements & B have n > > largest elements > > so O/P should be A=1,2,3,1,0 & B=INT_Max,INT_Max,4,5,9 now free > > memory used by 1st elements inarrayB so that A will represent M > > smallest elements & B will have n Largest elements > > > so that above will work. > > > Hope I am Correct let me know if any issue with explanation > > > Thanks > > Shashank>>"The Best Way To Escape From Theproblemis To Solve It" > > CSE,BIT Mesra -- 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 more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.