You are on page 1of 2

Sessional 2.

DSA
Name: Sobel Bhatti Reg No: SP19-BSE-112(A)

QUESTION 1:

public LinkList constructAnOrderedList(LinkList head1, LinkList head2)


{
if (head1 == null)
{
return head2;
}
if (head1 == null)
{
return head1;
}

LinkList head3 = new LinkList();


head3 = null;
if(head1.data < head2.data)
{
head3 = head1;
head1 = head1.next;
}
else
{
head3 = head2;
head2 = head2.next;
}

LinkList current = new LinkList();


current = head3;

while(head1 != null && head2 != null)


{
if(head1.data < head2.data)
{
current.next = head1;
head1 = head1.next;
}
else
{
current.next = head2;
head2 = head2.next;
}
current = current.next;
}

if(head1 == null)
{
current.next = head2;
}
else
{
current.next = head1;
}

return head3;
}

QUESTION 2:

int i;
if (front ==tail)
{cout(“queue is empty”);
}
else
for(int j=0, j.size,j++)

if (flightqueue(j).id==flightnumber)

{
i=front[j];
i=flightqueue[j];
front++
}

You might also like