• We should now be fully online following an overnight outage. Apologies for any inconvenience, we do not expect there to be any further issues.

Thinking of going into Comp. Sci? (or if you just like linked lists) look here.

notfred

Lifer
Feb 12, 2001
38,241
4
0
Here to educate people about what a computer science curriculum actually consists of...


Here's an assignment

That's assigment #1 for CSC 130 - Data Structures and Algorithms Analysis. We were given one week to complete the assignment. This is the absolute first assignment in the absolute first upper division CS course. When printed out, there's 17 pages of cade (keep in mind - 1 week).

Just wanted to let you know what you'd be getting into :)

BTW, if you want to run the code, the names are case sensitive and you have to have the java virtual machine installed.
 

bUnMaNGo

Senior member
Feb 9, 2000
964
0
0
UCSD if I'm not mistaken. Even though he's from Sactown and didn't take too well to my statements reguarding the Sacramento Queens :) hehehe
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
CSU Sacramento. There was another guy from sacramento in So. Cal. who you were arguing with, I forget who it was.... I'm from Santa Cruz, living in Sac'to.
 

Kev

Lifer
Dec 17, 2001
16,367
4
81
What do you have to do for the assignment? (I don't feel like reading code today)
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
Assignment 1A:

Create a DoublyLinkedList class. (has to include find, remove, next, previous, etc).

test it by reading in a file (each line gets pushed onto the list as a new node) and moving around in your lsit a bit and then saving the list to a file.

Assignment 1B:

Create a StackList class. build a stack based on an array. If the array gets full, create a new larger array, copy in the contents of hte old array, and assign the pointer to the old array to the new array.

Test it the same way.
 

bloinkster

Member
Jun 13, 2002
25
0
66
That project took 17 pages of code? are you printing it at like 18 pt? I remember having to do an assignment like this, i think we had 2 weeks, but its not really that bad. The worst part is that in the next class they tell you to use the STL to implement all of these things. Oh wait, you're coding in Java, we used C++.
 

Jfur

Diamond Member
Jul 9, 2001
6,044
0
0
Be glad :) From what I hear some places would have you looking at photos of network connectors and writing 3 page papers about Moore's law.

 

JayHu

Senior member
Mar 19, 2001
412
0
0
Originally posted by: notfred
Here to educate people about what a computer science curriculum actually consists of...


Here's an assignment

That's assigment #1 for CSC 130 - Data Structures and Algorithms Analysis. We were given one week to complete the assignment. This is the absolute first assignment in the absolute first upper division CS course. When printed out, there's 17 pages of cade (keep in mind - 1 week).

Just wanted to let you know what you'd be getting into :)

BTW, if you want to run the code, the names are case sensitive and you have to have the java virtual machine installed.


Say.. Data Structures and Algorithms Analysis. That seems to describe my CS240 Class this year.
Of course the first assignment was all written and required proofs of runtimes of algorithms. That was fun.
But SLL and DLL are fairly easy, especially in Java.
and 17 pages of code, that's awfully inefficient isn't it? ;)

*edit* used a wrong word.
 

soccerbud34

Senior member
Nov 15, 2001
747
0
0
Linked List was a breeze, especially with doubly linked list.

I had an assignment similar to that last year; however, it was a singlely linked list.
Draw out the linked list, it will make life much easier.

A hint for you, use something(whatever it may be, double or single list) and point it the the first item in the linked list and a tail for pointing to the last itme in the link list.

Good luch!

 

mchammer187

Diamond Member
Nov 26, 2000
9,114
0
76
1A i coded a doubly linked list in C++ a couple years couldnt have been more than 2 pages

does your school teach everything in Java except LISP obviously, and do you learn Java before C/ C++?

here everything is c/c++ and there is like

I still cannot see it taking 17 pages for something like this are you sure there is not an easier way

because if that demo of the Red Black tree that Ameesh linked was only like 5 pages (estimate) i still cant imagine it taking that long

but i could be wrong

1B doesnt seem that difficult either though I have only done it in C++ though and did not have to create a new array and copy the contents if the current stack size was too small
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
it's 17 pages long cause there's a class for implementing ListObjects that contain the data for the lsit (it's more than just alist of strings) and because my List class is a lot longer than it really has to be. It implements a bunch of methods that go way above and beyond the requirements for the assignment (for example, splice and unsplice listobjects from the middle of the list, along with a bunch of other stuff). Also ,the 17 pages includes all reuired comments (Which are over half of the text).

Linked List was a breeze, especially with doubly linked list.

I had an assignment similar to that last year; however, it was a singlely linked list.
Draw out the linked list, it will make life much easier.

A hint for you, use something(whatever it may be, double or single list) and point it the the first item in the linked list and a tail for pointing to the last itme in the link list.

Good luch!

guess you didn't notice that I already posted the finished code, huh? ;)
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
Originally posted by: charrison
So how do you implement a linked list in java without pointers and memory allocation?

Yeah, read the DLList class from the file I posted :)
 

charrison

Lifer
Oct 13, 1999
17,033
1
81
Originally posted by: notfred
Originally posted by: charrison
So how do you implement a linked list in java without pointers and memory allocation?

Yeah, read the DLList class from the file I posted :)

I would prefer a 2 line high level explaination:p
 

Ameesh

Lifer
Apr 3, 2001
23,686
1
0
Originally posted by: charrison
Originally posted by: notfred
Originally posted by: charrison
So how do you implement a linked list in java without pointers and memory allocation?

Yeah, read the DLList class from the file I posted :)

I would prefer a 2 line high level explaination:p

java does have refernece varabiles and allocating memory isnt a problem you just use the keyword new.
 

JayHu

Senior member
Mar 19, 2001
412
0
0
Originally posted by: charrison
So how do you implement a linked list in java without pointers and memory allocation?

The VM handles it all for you. No need to worry about anything. References do the trick for pointers.