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.