I am transfering from a jounior college to a four year college. This semester I am taking science classes (no programming classes). I have talked to other students in the computer science program and most of them are clueless about pointers. I have taken up to the first data structures at the jounior college I was attending. Is it possible to do a linked list or a Queue without pointers? The students at the four year college I have started going to are focused on pass by reference.
No there is not and why should there? Pointers aren't THAT difficult...
I honestly do not see the problem everyone has with pointers. A pointer is simply a variable that holds an address. Everyone gets so caught up in implementation that they forget that basic fact and become confused.
I think that many people get confused because they think too abstract. As Prelude says, a pointer is just a variable. The only difference with 'usual' variables is that it contains an address. Perhaps programming books should tell something about how memory in a computer is organised, like K&R does. Then people would better understand what a pointer is.
I know that when I was learning about them, the main problem wasn't understanding what they are (since every tut under the sun says "it's a variable that contains an address"), but how to use them. When to dereference them, and the like. Also, I think scop should be taught before this - when I was beginning to learn, I couldn't figure out why you'd ever want to use them, because I didn't totally get that variables declared in a function couldn't be altered in another one without the use of them.
You can do a Queue without pointers. But a linked list would be difficult.
For a linked list without pointers, you'll have to create 2 arrays:
data will contain the actual data values, and corresponding next will contain the next element after the current one.
index data next
0 20 2
1 25 -1 < --- can use this to indicate end of list
2 56 4
3 99 1
4 23 3
So the linked list goes like this: 0 -- 2 -- 4 -- 3 -- 1 -- END
There are many modifications/additions possible to this of course.
Hope this helps :)
You can also have a prev array to hold index of previous element in case you want a doubly linked list.