struct node
{ int data; struct node *next; struct node *next_larger; }
initially next_larger of every node points to NULL.
now write a c code which set all node's next_larger pointer.
where next_largest point to the next larger then its own value and largest value node's next_larger pointer points to NULL
http://www.geeksforgeeks.org/point-to-next-higher-value-node-in-a-linked-list-with-an-arbitrary-pointer/
http://effprog.blogspot.in/2011/04/populate-next-higher-in-singly-linked.html
ReplyDelete