programming exam
programming exam
I got my programming exam at 8:00am, gotta wake up at 6:30am, it's now 2:12am, and I can't sleep. I guess I shouldn't have gotten used to sleeping at 4:00am :P
Anyhoo, what are ppl on this board taking in school? I go to Ryerson for Information Technology.
Anyhoo, what are ppl on this board taking in school? I go to Ryerson for Information Technology.
Registered!!
Joined: Oct 2002
Posts: 1,267
Likes: 0
From: mr. and mississsauga, Ontario, Canada
Rep Power: 0 
woot woot! go C++! hehehehe... i don't know **** about Java... but it all looks the same hehehe... gotta looooove recursion with linked lists woohoo!
and oh, go MIPS!
Computer Science Honors Yorker guy floating around 2nd and 3rd year checking in
and oh, go MIPS!
Computer Science Honors Yorker guy floating around 2nd and 3rd year checking in
Originally posted by txtadik
woot woot! go C++! hehehehe... i don't know **** about Java... but it all looks the same hehehe... gotta looooove recursion with linked lists woohoo!
and oh, go MIPS!
Computer Science Honors Yorker guy floating around 2nd and 3rd year checking in
woot woot! go C++! hehehehe... i don't know **** about Java... but it all looks the same hehehe... gotta looooove recursion with linked lists woohoo!
and oh, go MIPS!
Computer Science Honors Yorker guy floating around 2nd and 3rd year checking in
with recursion and linked lists, do you mean making a list recursively? kinda lost on why you'd need recursion with a linked list.
i want a baby hummer :)
iTrader: (1)
Joined: Dec 2002
Posts: 1,588
Likes: 0
From: Richmond Hill, Ontario, Canada
Rep Power: 0 
Originally posted by 1982
ive been doing c++ for 2 yrs, and am now just taking java. same thing, just different syntax.
with recursion and linked lists, do you mean making a list recursively? kinda lost on why you'd need recursion with a linked list.
ive been doing c++ for 2 yrs, and am now just taking java. same thing, just different syntax.
with recursion and linked lists, do you mean making a list recursively? kinda lost on why you'd need recursion with a linked list.
you remove the head of the list and the result is still a linked list...etc. etc.
Originally posted by babychai
aren't linked lists a recursive data structure?
you remove the head of the list and the result is still a linked list...etc. etc.
aren't linked lists a recursive data structure?
you remove the head of the list and the result is still a linked list...etc. etc.
i want a baby hummer :)
iTrader: (1)
Joined: Dec 2002
Posts: 1,588
Likes: 0
From: Richmond Hill, Ontario, Canada
Rep Power: 0 
public LinkedList RecRemoveHead(LinkedList LL)
{
if ( LL.isEmpty() ) return null;
return RecRemoveHead(LL.removeHead());
}
say i have MyLinkedList has the following structure 1->2->3
if i call RecRemoveHead(MyLinkedList) then
after the first call i get:
2->3
after the second call i get:
3
after the third and final call i get:
null
note that everytime, a linked list is returned...so which means that if i remove an element from a linked list, i still get a linked list...so that's why they are recursive data structures...
same for trees...
Disclaimer: if the code is buggy, don't flame me..i'm using it for example sake...
search for "recursive data structure linked lists" on google
note to self: wow..all that money spent on tuition on crappy teachers and i still learned something!
{
if ( LL.isEmpty() ) return null;
return RecRemoveHead(LL.removeHead());
}
say i have MyLinkedList has the following structure 1->2->3
if i call RecRemoveHead(MyLinkedList) then
after the first call i get:
2->3
after the second call i get:
3
after the third and final call i get:
null
note that everytime, a linked list is returned...so which means that if i remove an element from a linked list, i still get a linked list...so that's why they are recursive data structures...
same for trees...
Disclaimer: if the code is buggy, don't flame me..i'm using it for example sake...
search for "recursive data structure linked lists" on google
note to self: wow..all that money spent on tuition on crappy teachers and i still learned something!
Last edited by babychai; Apr 16, 2003 at 09:26 PM.
im assuming the remove head function resets the head to point at the next node down right?
anyway, im not sure recursion is faster memorywise than a simple while loop
single linked list:
while (head->next()->getdata() != NULL)
{
tempnode = head->next();
head->next() = head->next()->next();
delete tempnode;
}
i know i left out a lot of steps in that loop but im too tired to think straight.
anyway, im not sure recursion is faster memorywise than a simple while loop
single linked list:
while (head->next()->getdata() != NULL)
{
tempnode = head->next();
head->next() = head->next()->next();
delete tempnode;
}
i know i left out a lot of steps in that loop but im too tired to think straight.
i want a baby hummer :)
iTrader: (1)
Joined: Dec 2002
Posts: 1,588
Likes: 0
From: Richmond Hill, Ontario, Canada
Rep Power: 0 
i was told that recursion performs a lot better than while loops...
ever heard of scheme? it's all recursion hahaha
all about making lists and stuff like that...interesting...
you can do loops with recursion, but you can't the other way around...
actually, the example wasn't about efficiency...
i only made that delete thing to stress that you get a linked list after you delete an element from it, which defines its recursive structure...
better example...
Directory is a recursive data structure. It has to be made recursively because you cannot make a subdirectory before making the actual directory
A Directory contains Files and a Directory contains other Directories. So to traverse through all the files in the Directory, you have to do something like this:
public void VisitDirectory(Directory dir)
{
Vector subdirectories;
Vector files;
dir.HasBeenVisited = true;
subdirectories = dir.GetSubDirectories()
files = dir.GetFiles()
for (int i=0; i< subdirectories.size(); i++)
{
VisitDirectory(subdirectories(i));
}
for (int i=0; i< files.size(); i++)
{
files(i).HasBeenVisited = true;
}
}
I don't know how you would traverse directories with a loop...
man, i feel so nerdy..having a discussion about recusive data structures...
but thanks 1982...you're helping me review...
* oops i forgot the casting, but oh well... *
ever heard of scheme? it's all recursion hahaha
all about making lists and stuff like that...interesting...you can do loops with recursion, but you can't the other way around...
actually, the example wasn't about efficiency...
i only made that delete thing to stress that you get a linked list after you delete an element from it, which defines its recursive structure...
better example...
Directory is a recursive data structure. It has to be made recursively because you cannot make a subdirectory before making the actual directory
A Directory contains Files and a Directory contains other Directories. So to traverse through all the files in the Directory, you have to do something like this:
public void VisitDirectory(Directory dir)
{
Vector subdirectories;
Vector files;
dir.HasBeenVisited = true;
subdirectories = dir.GetSubDirectories()
files = dir.GetFiles()
for (int i=0; i< subdirectories.size(); i++)
{
VisitDirectory(subdirectories(i));
}
for (int i=0; i< files.size(); i++)
{
files(i).HasBeenVisited = true;
}
}
I don't know how you would traverse directories with a loop...
man, i feel so nerdy..having a discussion about recusive data structures...
but thanks 1982...you're helping me review...

* oops i forgot the casting, but oh well... *
Last edited by babychai; Apr 16, 2003 at 10:47 PM.
Originally posted by babychai
aren't linked lists a recursive data structure?
you remove the head of the list and the result is still a linked list...etc. etc.
aren't linked lists a recursive data structure?
you remove the head of the list and the result is still a linked list...etc. etc.
know a guy named nick?.. he's in 3rd year comp sci coop too.
Re: programming exam
Originally posted by Swift
I got my programming exam at 8:00am, gotta wake up at 6:30am, it's now 2:12am, and I can't sleep. I guess I shouldn't have gotten used to sleeping at 4:00am :P
Anyhoo, what are ppl on this board taking in school? I go to Ryerson for Information Technology.
I got my programming exam at 8:00am, gotta wake up at 6:30am, it's now 2:12am, and I can't sleep. I guess I shouldn't have gotten used to sleeping at 4:00am :P
Anyhoo, what are ppl on this board taking in school? I go to Ryerson for Information Technology.
Originally posted by babychai
i was told that recursion performs a lot better than while loops...
ever heard of scheme? it's all recursion hahaha
all about making lists and stuff like that...interesting...
you can do loops with recursion, but you can't the other way around...
actually, the example wasn't about efficiency...
i only made that delete thing to stress that you get a linked list after you delete an element from it, which defines its recursive structure...
better example...
Directory is a recursive data structure. It has to be made recursively because you cannot make a subdirectory before making the actual directory
A Directory contains Files and a Directory contains other Directories. So to traverse through all the files in the Directory, you have to do something like this:
public void VisitDirectory(Directory dir)
{
Vector subdirectories;
Vector files;
dir.HasBeenVisited = true;
subdirectories = dir.GetSubDirectories()
files = dir.GetFiles()
for (int i=0; i< subdirectories.size(); i++)
{
VisitDirectory(subdirectories(i));
}
for (int i=0; i< files.size(); i++)
{
files(i).HasBeenVisited = true;
}
}
I don't know how you would traverse directories with a loop...
man, i feel so nerdy..having a discussion about recusive data structures...
but thanks 1982...you're helping me review...
* oops i forgot the casting, but oh well... *
i was told that recursion performs a lot better than while loops...
ever heard of scheme? it's all recursion hahaha
all about making lists and stuff like that...interesting...you can do loops with recursion, but you can't the other way around...
actually, the example wasn't about efficiency...
i only made that delete thing to stress that you get a linked list after you delete an element from it, which defines its recursive structure...
better example...
Directory is a recursive data structure. It has to be made recursively because you cannot make a subdirectory before making the actual directory
A Directory contains Files and a Directory contains other Directories. So to traverse through all the files in the Directory, you have to do something like this:
public void VisitDirectory(Directory dir)
{
Vector subdirectories;
Vector files;
dir.HasBeenVisited = true;
subdirectories = dir.GetSubDirectories()
files = dir.GetFiles()
for (int i=0; i< subdirectories.size(); i++)
{
VisitDirectory(subdirectories(i));
}
for (int i=0; i< files.size(); i++)
{
files(i).HasBeenVisited = true;
}
}
I don't know how you would traverse directories with a loop...
man, i feel so nerdy..having a discussion about recusive data structures...
but thanks 1982...you're helping me review...

* oops i forgot the casting, but oh well... *
i learned that in first year!!!.. i hate it...
did u guys do that disc thing where u move 3 disc and it always has to have a bigger disc below the smaller disc or something liek that. lol
Registered!!
Joined: Oct 2002
Posts: 1,267
Likes: 0
From: mr. and mississsauga, Ontario, Canada
Rep Power: 0 
recursion is a good way to make the code neater and easier to understand (since it's shorter but sometime's it's heck hard to trace!)... but problem with recursion is all the memory overhead (because the functions are basically stacked one after another)...
and while/for/do-while loops save most of the memory overhead required when using recursion but at the expense of having longer and less straight-forward code...
and while/for/do-while loops save most of the memory overhead required when using recursion but at the expense of having longer and less straight-forward code...
i want a baby hummer :)
iTrader: (1)
Joined: Dec 2002
Posts: 1,588
Likes: 0
From: Richmond Hill, Ontario, Canada
Rep Power: 0 
Originally posted by txtadik
recursion is a good way to make the code neater and easier to understand (since it's shorter but sometime's it's heck hard to trace!)... but problem with recursion is all the memory overhead (because the functions are basically stacked one after another)...
and while/for/do-while loops save most of the memory overhead required when using recursion but at the expense of having longer and less straight-forward code...
recursion is a good way to make the code neater and easier to understand (since it's shorter but sometime's it's heck hard to trace!)... but problem with recursion is all the memory overhead (because the functions are basically stacked one after another)...
and while/for/do-while loops save most of the memory overhead required when using recursion but at the expense of having longer and less straight-forward code...
for example, a box of smarties, if you think of it using recursion, then "you eat one, and then you eat the rest." if you think of it using loops, then "you eat one, and then you eat the next".
depends on how you look at it...
Registered!!
iTrader: (1)
Joined: Jul 2002
Posts: 2,712
Likes: 0
From: Scarborough, Ontario, Canada
Rep Power: 0 
Recursion is a big part of programming. In fact, my 3rd yr programming language structure course taught some functional-level programming languages, i.e., languages that were used to design C++ and such, are all about recurssion.
I loved that course, only CS course I got A, haha, helped me graduate...
I loved that course, only CS course I got A, haha, helped me graduate...
Registered!!
Joined: Oct 2002
Posts: 1,267
Likes: 0
From: mr. and mississsauga, Ontario, Canada
Rep Power: 0 
Originally posted by MSoft
Recursion is a big part of programming. In fact, my 3rd yr programming language structure course taught some functional-level programming languages, i.e., languages that were used to design C++ and such, are all about recurssion.
I loved that course, only CS course I got A, haha, helped me graduate...
Recursion is a big part of programming. In fact, my 3rd yr programming language structure course taught some functional-level programming languages, i.e., languages that were used to design C++ and such, are all about recurssion.
I loved that course, only CS course I got A, haha, helped me graduate...
btw, did you take "scheme"? i heard it was a wierd-@ss language...
holy crap we are all geeks!
who's the geekiest of us all? we should have a contest lol! Registered!!
Joined: Oct 2002
Posts: 1,267
Likes: 0
From: mr. and mississsauga, Ontario, Canada
Rep Power: 0 
Originally posted by Booohahaha
OMG... a box of smarties.. ur starting to sound like my professor hahhahaha
ok.... txt..ur a geek ... jk jk!!
OMG... a box of smarties.. ur starting to sound like my professor hahhahaha
ok.... txt..ur a geek ... jk jk!!
i want a baby hummer :)
iTrader: (1)
Joined: Dec 2002
Posts: 1,588
Likes: 0
From: Richmond Hill, Ontario, Canada
Rep Power: 0 
Originally posted by txtadik
btw, did you take "scheme"? i heard it was a wierd-@ss language...
btw, did you take "scheme"? i heard it was a wierd-@ss language...
all about recursion and lists...
i loved it...hahaha...
Thread
Thread Starter
Honda Civic Forum
Replies
Last Post
CarStuff
Safety/Security Items - SRS, Keys, Immobilizer, airbags, ABS
6
Dec 6, 2020 12:52 PM
martinsmartin
Mechanical Problems/Vehicle Issues and Fix-it Forum
5
Aug 15, 2015 07:34 PM
01civyv3
Mechanical Problems/Vehicle Issues and Fix-it Forum
14
Jun 2, 2015 05:21 AM



