The Student Room Group
Reply 1
piginapoke
Not entirely sure if this is what you mean, but in a single-linked list each item has a pointer that points to the address of the next item. So you would have:

1 A, pointer to (2)
2 B, pointer to (3)
3 C, pointer to (4)
4 D, null pointer or pointer to self

So to traverse the list from head to tail you just follow the pointers.


on other answers to questions it gave random right hand numbers, this subject is so unclear at times
Reply 2
piginapoke
I thought the numbers on the right you're referring to are just pointers to other list nodes. That's how a list works anyway; each node has a data item (or a pointer to a data item) and a pointer to the next item in the list.


exampple

addres name pointer
1 Brown 4
2 Turn 0
3 jon 2
4 Cray 3
5
6
Reply 3
1 A, pointer to (2)
2 B, pointer to (3)
3 C, pointer to (4)
4 D, null pointer or pointer to self

YES what you said is good,
Reply 4
DazzYaa711
exampple

addres name pointer
1 Brown 4
2 Turn 0
3 jon 2
4 Cray 3
5
6


* sigh *
Reply 5
piginapoke
So traversing this list we get:

1 = brown, go to 4
4 = cray, go to 3
3 = jon, go to 2
2 = turn, end of list.

So the order of the list is brown, cray, jon, turn.


BUT in the question it says " put the names A, B , C , D " in a list

so i do

1. A
2. B
3. C
4 D

i check the fucking mark scheme and i get 1 out of the 2 marks cuz they have a load of numbners on the right hand side out of NO WHERE
Reply 6
piginapoke
Well it seems you need to include the pointer to the next list item, like I posted above.

In the notation of the example you gave it would be:

1 A 2
2 B 3
3 C 4
4 D 0


but if i recall correctly the numbers on the right were mixed up :frown::frown::frown: bllah
Reply 7
piginapoke
Well the numbers on the right just determine the ordering of the list when its traversed. So if you wanted to change the order of the letters around, you'd just change the numbers on the right.


i'll be getting up at 5 in the morning tomorrow to go over it all anyway sooooo much to learn
Reply 8
piginapoke
Write it all on your hand or a piece of paper inside your calculator :tongue:


lol.. too risky
Reply 9
If this is a linked list and you are to put it in alphapetical order (which is very stupid)
Reply 10
If it is Just a list

[A,B,C,D]

Latest

Trending

Trending