here how you can do it :-
call construct(head,0,n-1); n=length of linked list
node* construct(node *head,int start,int end)
{
int mid;
if(start > end)
return NULL;
mid=(start+end)/2;
node * tleft=construct(dll,start,mid-1);
head->next=tleft;
head=head->next;
head->pr
you do the same using bottom up approach...complexity would O(n)
On 26 Feb 2012 03:54, "Supraja Jayakumar" wrote:
> Hi All
>
> A sorted doubly linked list is given. We are asked to construct a balanced
> binary tree.
>
> I have designed an n^2 solution. Kindly comment on it and also suggest
> po
Hi All
A sorted doubly linked list is given. We are asked to construct a balanced
binary tree.
I have designed an n^2 solution. Kindly comment on it and also suggest
possible improvements and definitely let me know if something is wrong.
Btree* ConstructTreeFromDLList(DLList *dll) {
// Assumin