@atul anand: the question simply says that in each node the second should
point to the next larger no. which means in your case 7 3 5 1 5 9
the output should be
7-9
5-7
3-5
1-3
On Mon, Mar 26, 2012 at 10:37 AM, Dheeraj Sharma
dheerajsharma1...@gmail.com wrote:
Correct me if am wrong.. i think
Correct me if am wrong.. i think we can use Stack as follows
node * minFun(node *head)
{
stacknode * st;
return fun(head,st);
}
node * fun(node *ptr,stacknode * st)
{
if(ptr)
{
node *x=fun(ptr-next,st);
while(!st.empty() (ptr-data)(st.top()-data))
@all : i am getting this right , i guess given a linked list ...you need to
point to next larger element.
so if input linked list is 7 3 5 1 5 9
then nextLarger of each node will point as follows:-
3-5
1-5
5-9
7-9
9-NULL;
i have no idea why the linked list is modified using merge sort...
after push(s,next) move head also
head=head-next;
On Sun, Mar 25, 2012 at 12:10 AM, atul anand atul.87fri...@gmail.comwrote:
@all : i am getting this right , i guess given a linked list ...you need
to point to next larger element.
so if input linked list is 7 3 5 1 5 9
then nextLarger of
It is basically sorting the linked list. Do not change the first pointer of
nodes and use the second pointer for sorting. return the pointer to the
smallest element. That's it.
On Sat, Mar 24, 2012 at 12:50 AM, Atul Singh atulsingh7...@gmail.comwrote:
Given a linked list with each node having
don't know if i am complicating..assumption,
build a multimap of values and the corresponding node address as well as a
heap from the given nodes in first pass.
now from minheap pick one by one and set the second pointer of previous
picked min element to this element using multimap(remove from
actually, multimap can be avoided, each element of heap is key,value where
key is the element and value is address and build heap on key.
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
On Sat, Mar 24, 2012 at 1:40 AM, Ashish Goel ashg...@gmail.com