How to traverse linked list in c++?

C program, urgent help req, linked list?

  • (a) define using typedef a type suitable for each element of the list of integers – let us call it LISTEL, (b) define a suitable data type for the list – let us call it LIST (Hint: Obviously it would be of type pointer to LISTEL), (c) write a C function for each of the following operations on the object LIST: i. LIST construct (), which returns an empty list, ii. short int is empty (LIST), which returns 1 if the passed list is empty and 0, otherwise, iii. LISTEL head (LIST) which is to return the first element of the list; the input list does not get disturbed, iv. LIST tail (LIST) which returns the tail of the list, i.e., the original list with its head (i.e., the first element) removed, v. void printList (LIST) which prints the input list elements, vi. LIST concat (LIST, LIST) which concatenates the second list at the end of the first list, vii. LIST insert (LIST, int, int) – inserts the second parameter at a position in the list designated by the third parameter and returns the new list ; note that when the third parameter is 1 the pointer to the first element itself gets changed but this is taken care of by having the datatype LIST itself as a pointer and having the function return this new pointer value to the calling function which can be assigned to the original pointer variable. However, here also you would gain in terms of uniformity if you use a dummy element at the beginning. viii. LIST reverse (LIST), a recursive function which returns a list which is the reverse of the input list. ix. LIST alternate (LIST, LIST) which takes two lists and returns a new list having elements chosen from the two lists alternatively; thus, in the new list, the first one will be the first element of the first list, the second one will be the first one of the second list, and so on. The original lists are left undisturbed. x. Write a main function to demonstrate the working of the above functions.

  • Answer:

    Sorry. You have to do and ask us for help.

Prateek K at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

Sorry. You have to do and ask us for help.

James Bond

i can do it, if u can pay me

Abdul Nawaf

i can do it, if u can pay me

Abdul Nawaf

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.