# Please explain this code line by lin

Please post your code instead of a picture. Also, please tell us a bit about what you do and donâ€™t understand. The hĂ¶re you tell us, the more we can help. Thanks!

2 Likes

It would help to have the definition of a `NODE *`. I mean, thatâ€™s clearly a linked list holding the terms of a polynomial, but itâ€™s completely non-obvious that the list is circular.

What is it you donâ€™t understand? The list traversal or the polynomial evaluation?

Additionally, depending on the implementation of `pow(a,b)`, worst-case time complexity of this algorithm is O(n^2). Recommend you look into Hornerâ€™s Method which is linear in `n`.

2 Likes

If you need an explanation â€śline by lineâ€ť of something that includes basic declaration of variables - you should start learning programming instead of asking us.

Because what good will it do, if I tell you `*he` is a pointer, while `x` is an integer-variable, when you donâ€™t know what either of those mean?

If you actually understand the basics and just want to know what this code is doing â†’ do us a favor and post WHERE you got it from and WHAT itâ€™s supposed to do.
Because nobody here wrote that, so you gotta throw us a bone of what this is.

I mean, it looks like itâ€™s calculating some Plynomial out of a number encoded in a linked list. But Iâ€™m sure there is a task attached to this, that actually tells us the goal.

1 Like

There are services like JavaScript Tutor that will step through code line by line and visualize what is happening.

If you have questions about code, thereâ€™s lots of people here who want to help. However, when people ask â€śexplain this to meâ€ť they almost never get a response.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.