Discrete maths problem - tracing an algorithm

Click For Summary

Discussion Overview

The discussion revolves around understanding a specific symbol, Xc, in the context of an algorithm related to discrete mathematics. Participants explore the meaning of indexing within the algorithm, particularly how the variable C interacts with other variables in the loop structure.

Discussion Character

  • Conceptual clarification
  • Technical explanation
  • Homework-related

Main Points Raised

  • One participant seeks clarification on the meaning of the symbol Xc in relation to the variable C := 1.
  • Another participant explains that Xc represents indexing, where C is incremented to access different values (x1, x2, etc.) in a loop.
  • A participant proposes that the variable i counts the number of 1's in the input, suggesting that it would equal 4 by the end of the algorithm.
  • There is a confirmation that the loop stops when C = 7, indicating an understanding of the algorithm's flow.

Areas of Agreement / Disagreement

Participants generally agree on the interpretation of indexing and the behavior of the variables within the algorithm. However, there is some uncertainty regarding the specific counting mechanism and the final value of i, which is based on the input provided.

Contextual Notes

The discussion does not clarify the exact nature of the input or the complete structure of the algorithm, which may affect the understanding of how the variables interact.

Sterling1
Messages
2
Reaction score
0
Hello,

I'm working on a discrete mathematics for computing paper and am stuck on what a symbol is trying to convey. Sorry if this seems like a stupid question (I feel stupid for not being able to work it out myself), I've just started this subject and am still getting used to it.

My question is what does the Xc mean in this algorithm (picture attached)? I understand that X1, X2 etc are the different variables, but does the Xc have something to do with the variable C := 1? If so, what does that symbol mean? I.e. what am I supposed to do with the variable in relation to C?

I hope this is clear enough and that once it's been explained to me I can crack on with the paper. Thank you very much in advance.

DM screen.PNG
 
Last edited by a moderator:
Physics news on Phys.org
It's indexing. So you have a bunch of values, $x_1, x_2, \dots,x_n,$ right? As you're looping through the repeat section, you're updating $c$. When you start, you have $c=1,$ so that $x_c=x_1.$ The next time you come through the loop, $c$ has been incremented by one, which is what the $c:=c+1$ line does. That means this time through the loop, $c=2,$ making $x_c=x_2.$ So essentially, the incrementing of $c$ allows you to examine each of the $x_1, x_2,\dots,x_n$ values one-by-one. Does that help?
 
Ackbach said:
It's indexing. So you have a bunch of values, $x_1, x_2, \dots,x_n,$ right? As you're looping through the repeat section, you're updating $c$. When you start, you have $c=1,$ so that $x_c=x_1.$ The next time you come through the loop, $c$ has been incremented by one, which is what the $c:=c+1$ line does. That means this time through the loop, $c=2,$ making $x_c=x_2.$ So essentially, the incrementing of $c$ allows you to examine each of the $x_1, x_2,\dots,x_n$ values one-by-one. Does that help?

Ah right, so essentially the i variable is counting how many 1's are in the input? I.e. in this algorithm i would equal 4 by the end? And the loop stops when C = 7? If I'm correct in that thinking then I've understood your explanation, and if I'm wrong then clearly I've missed something.

Thank you very much for your help, it makes sense to me (I think) now. It seems stupid to have not understood such a basic concept as indexing. Thank you.
 
Sterling said:
Ah right, so essentially the i variable is counting how many 1's are in the input?

Yep!

Sterling said:
I.e. in this algorithm i would equal 4 by the end?

Yes, I would agree.

Sterling said:
And the loop stops when C = 7?

Also correct.

Sterling said:
If I'm correct in that thinking then I've understood your explanation, and if I'm wrong then clearly I've missed something.

Thank you very much for your help, it makes sense to me (I think) now. It seems stupid to have not understood such a basic concept as indexing. Thank you.

You're very welcome!
 

Similar threads

Replies
86
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 4 ·
Replies
4
Views
10K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K