shanuapril
BAN USERRight, but not just the 20->null, all the memory used in LL following 20 should be deleted.
- shanuapril December 11, 20111) Assume list 2 to be shorter list, list 1 to be longer one
2) loop x from head:list1 to NULL
loop y from head:list2 to NULL
if ( x == y )
intersection = x;
return;
um guys.... Pointers don't take memory from stack right? O.o They take it from heap. Shouldn't answer be 0?
- shanuapril November 06, 2011hmmm.... tricky question. This involves you knowing EVERYTHING good and bad about a product :-D
- shanuapril November 06, 2011pseudo code:
node* current = begining_of_list;
int location = 1;
while( current != NULL)
{
if(location % 2 == 1 && isDigit(current->element) ) //Ele is a number, OK
{
location++;
current = current -> next;
continue;
}
else
{
for( node* temp = current; temp!= NULL; temp= temp->next)
{
if( isDigit(temp->ele) )
{
node* mid->ele = temp->ele;
temp->ele = current->ele;
current->ele = mid->ele;
break;
}
}
}
if(location % 2 == 0 && !(isDigit(current->element)) ) //Ele is a char, OK
{
location++;
current = current -> next;
continue;
}
else
{
for( node* temp = current; temp!= NULL; temp= temp->next)
{
if( !isDigit(temp->ele) )
{
node* mid->ele = temp->ele;
temp->ele = current->ele;
current->ele = mid->ele;
break;
}
}
}
}
Create a BST or a sorted list of addresses only. If there's a clash, you've the directory that links to one of the parents.
- shanuapril December 11, 2011