answersLogoWhite

0

With two pointers, the first simply goes through the list, the second does the same thing, but with half speed:

List *first, *last, *mid;

int cnt;

for (last= mid= first, cnt= 0; last != NULL; last= last->next, ++cnt) {

if (cnt%2==1) mid= mid->next;

}

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

3 Write the algorithm of inserting an element at middle of a linked?

theory part to how u can insert element at middle of link list ?


Where are good sites where you con find facts about the element chromium?

See the link below


Where to find information of a real knight from the middle ages?

See the link below.


Where can you find the whole picture of the element nickel?

Type in periodic table in Google and search for a link. Type in picture of the element Nickel in Google.


What does data structure mean?

When we speak of linear and no-linear data structures, we are referring to the links between one element and the next. These links determine how we traverse the structure such that we "visit" every element in the structure. When every element has only one possible link to the next in sequence, then the structure is said to be linear. If any element has two or more possible links, it is said to be non-linear. Arrays, lists, stack and queues are examples of linear structures. Trees, networks and graphs are examples of non-linear structures. A binary tree is the simplest example of a non-linear structure because every element has, at most, two possible links, a left link and a right link. If we follow the left link, then at some point we must return to that same element in order to follow its right link. This means we must backtrack. Any structure that requires us to backtrack during a traversal is therefore non-linear. Linear traversal is more efficient than non-linear traversal because there is no need to backtrack to traverse a linear data structure.


What does non-linear data structure mean?

When we speak of linear and no-linear data structures, we are referring to the links between one element and the next. These links determine how we traverse the structure such that we "visit" every element in the structure. When every element has only one possible link to the next in sequence, then the structure is said to be linear. If any element has two or more possible links, it is said to be non-linear. Arrays, lists, stack and queues are examples of linear structures. Trees, networks and graphs are examples of non-linear structures. A binary tree is the simplest example of a non-linear structure because every element has, at most, two possible links, a left link and a right link. If we follow the left link, then at some point we must return to that same element in order to follow its right link. This means we must backtrack. Any structure that requires us to backtrack during a traversal is therefore non-linear. Linear traversal is more efficient than non-linear traversal because there is no need to backtrack to traverse a linear data structure.


Where do you find radio codes on a 2006 Honda Element?

Go to the Honda Website and sign up on the Owner's Link. There you will be able to get the code. Click the link.


Where on WikiAnswers can you find questions and answers on the Middle Ages?

Here is the link to the sub-category dealing with the Middle Ages:http://wiki.answers.com/Q/FAQ/3964


What carol contains the line bearing gifts you traverse afar?

We Three Kings We three kings of Orient are Bearing gifts we traverse afar. Field and fountain, moor and mountain, Following yonder star. See the link:


When do you find an elf?

You can't. Elves don't exist. Middle earth, here is a link from wikipedia to get more info.


Where to buy Bare Minerals in Middle Tennessee?

Google ULTA stores and clikc on their "find a store location" link.


Where can you find the Plaza Middle School back to school supply list?

Go To the Plaza Website at the Related Link.