plz help me out with the code here
thanks,
Ravna

Recommended Answers

All 8 Replies

Use this algorithm to delete the last node.

void DelLast(List L)
{
	List Temp;
	if(L==NULL||L->Next==NULL)
	{
		printf("List contains no or just one element.");
		return;
	}
	while(L->Next->Next!=NULL)
		L=L->Next;
	Temp=L->Next;
	L->Next=NULL;
	free(Temp);
}

// Won't work for a single unit I guess.

However, am not sure what you mean by n'th last node. Isn't last ... just last?

>However, am not sure what you mean by n'th last node. Isn't last ... just last?
Last is just last, but nth isn't necessarily the last. If you're given n, you delete the node at that position. It's actually painfully easy to do with one traversal if you think about it for a few seconds. ravina_malik is just lazy and wants free homework solutions.

hey Narue Meanie,
when i say nth last node..i mean if u keep a counter on the last node & count backwards, its the nth node .. assuming the last node to b node no 1 ..count in opposite direction
hope this clarifies my being lazy & lets c how u do ur homework ....
Ravina

>when i say nth last node..i mean <snip my explanation in different words>
I know exactly what your requirements are. In fact, if you had been paying attention, you would have seen that I clarified QwertyManiac's confusion.

>hope this clarifies my being lazy
Your being lazy was very clear to begin with.

>& lets c how u do ur homework ....
I did my homework. That's why I make a very good living as a professional programmer. Why should I do your homework too?

hey ill rather not get into this..
end of the day i needed help
if u can priovide well & good if not...well plz ignore my post..
i prefer u not making assumptions on who or what i am...
ok???
lets keep it polite here

>lets keep it polite here
Okay, well as long as we're keeping it polite, how about we keep it official too? Please read this announcement and our policies. I'm also giving you a warning for breaking the Keep It Organized rule.

If you want help with your problem, please post your latest attempt that proves you've actually tried to solve it yourself. If you continue to ask for code without showing any effort, I'll lock your thread and be forced to give you an infraction.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.