1) Declare a class CircularList which contains the proper data structure which support the implementation of the circular linked list. Each node in the linked list contain only integer element. [3 marks]
2) Implement the method showDetail, which serves the purpose of displaying all the data above circular linked list. [5 marks]
3) Add to your class another method passMark, that takes an integer pass parameter. The method should return the number of nodes with values above the pass value. [5 marks]
index = ( index + 1 ) % 5;
5/5 has no remainder, so the index goes to 0.
Now, I'm talking about index, so you might be thinking ... array? If your circular list is of fixed size, an arry would be a fine implementation. Circular lists or buffers are usually fixed size, maybe configurable when you create it. Give you any ideas?
BTW: I get crazy trying to do mod on negatives. How would you go backward from 0 to 4 without going negative? That is, avoid this at index 0 (or any other):
index = ( index - 1 ) % 5;
Shall this be a ringbuffer - like the clock, where it starts from the beginning after reaching the end: '..., 10, 11, 12, 1, 2, ...'?
Yes that's right, the next reference of the list's last node references the first node, instead of null.
Is the size of this circular list known in advance, or shall it be possible to in- and decrease it's size?
Now, I'm talking about index, so you might be thinking ... array? If your circular list is of fixed size, an arry would be a fine implementation.
since the question does not mention whether they want it to be fixed or expandable, so to make it a good program lets implement it as a reference-base list (expandable) . any suggestions?