Canada East Manitoba, Ontario, Quebec, New Brunswick, PEI, Nova Scotia, Newfoundland

programming exam

Old Apr 16, 2003
  #1  
Swift's Avatar
Thread Starter
Registered!!
 
Joined: Apr 2003
Posts: 252
Likes: 0
From: Toronto
Rep Power: 0
Swift is an unknown quantity at this point
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.
Reply
Old Apr 16, 2003
  #2  
Booohahaha's Avatar
BAD MON
iTrader: (1)
 
Joined: Apr 2001
Posts: 16,559
Likes: 0
From: GTA
Rep Power: 0
Booohahaha is an unknown quantity at this point
i just took mine... OOP first year.. man it was brutal i got stumped at the beginning and but finally finished it!!
Reply
Old Apr 16, 2003
  #3  
babychai's Avatar
i want a baby hummer :)
iTrader: (1)
 
Joined: Dec 2002
Posts: 1,588
Likes: 0
From: Richmond Hill, Ontario, Canada
Rep Power: 0
babychai is an unknown quantity at this point
g'luck with ur exam...

I'm at Waterloo for Computer Science w/ Bioinformatics option...
Going into 3rd year (b/c of co-op)
Reply
Old Apr 16, 2003
  #4  
txtadik's Avatar
Registered!!
 
Joined: Oct 2002
Posts: 1,267
Likes: 0
From: mr. and mississsauga, Ontario, Canada
Rep Power: 0
txtadik is an unknown quantity at this point
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
Reply
Old Apr 16, 2003
  #5  
MSoft's Avatar
Registered!!
iTrader: (1)
 
Joined: Jul 2002
Posts: 2,712
Likes: 0
From: Scarborough, Ontario, Canada
Rep Power: 0
MSoft is an unknown quantity at this point
Programming eh... Been there, done that. Glad I'm graduated, Hor hor
Reply
Old Apr 16, 2003
  #6  
Booohahaha's Avatar
BAD MON
iTrader: (1)
 
Joined: Apr 2001
Posts: 16,559
Likes: 0
From: GTA
Rep Power: 0
Booohahaha is an unknown quantity at this point
hahaha i finally got into the groove my head is filled up with that stuff now.. hahaha i feel GREAT now that its over!!
hopefully i did well...
Reply
Old Apr 16, 2003
  #7  
Swift's Avatar
Thread Starter
Registered!!
 
Joined: Apr 2003
Posts: 252
Likes: 0
From: Toronto
Rep Power: 0
Swift is an unknown quantity at this point
Man, I did my exam today... the multiple choice was good!
But, f*ck, the coding part was whack... time to drop out j/K! HEHEHHehehEH
Reply
Old Apr 16, 2003
  #8  
1982's Avatar
Registered!!
 
Joined: Apr 2003
Posts: 74
Likes: 0
Rep Power: 0
1982 is an unknown quantity at this point
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
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.
Reply
Old Apr 16, 2003
  #9  
MMILX's Avatar
Registered!!
 
Joined: Jan 2003
Posts: 307
Likes: 0
From: Oregon
Rep Power: 0
MMILX is an unknown quantity at this point
Done some C++...

Its funny how OOP is so common... C++, Java, and even ASP uses some objects.

IS major at Portland State University...
Reply
Old Apr 16, 2003
  #10  
babychai's Avatar
i want a baby hummer :)
iTrader: (1)
 
Joined: Dec 2002
Posts: 1,588
Likes: 0
From: Richmond Hill, Ontario, Canada
Rep Power: 0
babychai is an unknown quantity at this point
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.
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.
Reply
Old Apr 16, 2003
  #11  
1982's Avatar
Registered!!
 
Joined: Apr 2003
Posts: 74
Likes: 0
Rep Power: 0
1982 is an unknown quantity at this point
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.
recursion = calling the same fuction within the function. will cause infinate loop unless a break out condition is set.
Reply
Old Apr 16, 2003
  #12  
babychai's Avatar
i want a baby hummer :)
iTrader: (1)
 
Joined: Dec 2002
Posts: 1,588
Likes: 0
From: Richmond Hill, Ontario, Canada
Rep Power: 0
babychai is an unknown quantity at this point
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!

Last edited by babychai; Apr 16, 2003 at 09:26 PM.
Reply
Old Apr 16, 2003
  #13  
1982's Avatar
Registered!!
 
Joined: Apr 2003
Posts: 74
Likes: 0
Rep Power: 0
1982 is an unknown quantity at this point
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.
Reply
Old Apr 16, 2003
  #14  
babychai's Avatar
i want a baby hummer :)
iTrader: (1)
 
Joined: Dec 2002
Posts: 1,588
Likes: 0
From: Richmond Hill, Ontario, Canada
Rep Power: 0
babychai is an unknown quantity at this point
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... *

Last edited by babychai; Apr 16, 2003 at 10:47 PM.
Reply
Old Apr 16, 2003
  #15  
1982's Avatar
Registered!!
 
Joined: Apr 2003
Posts: 74
Likes: 0
Rep Power: 0
1982 is an unknown quantity at this point
youre welcome
Reply
Old Apr 16, 2003
  #16  
scsGrumPyDriveR's Avatar
Registered!!
 
Joined: Jun 2002
Posts: 1,063
Likes: 0
From: , Other, ZEBRA
Rep Power: 0
scsGrumPyDriveR is an unknown quantity at this point
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.

know a guy named nick?.. he's in 3rd year comp sci coop too.
Reply
Old Apr 16, 2003
  #17  
scsGrumPyDriveR's Avatar
Registered!!
 
Joined: Jun 2002
Posts: 1,063
Likes: 0
From: , Other, ZEBRA
Rep Power: 0
scsGrumPyDriveR is an unknown quantity at this point
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.
which year? my gf takes IT
Reply
Old Apr 16, 2003
  #18  
babychai's Avatar
i want a baby hummer :)
iTrader: (1)
 
Joined: Dec 2002
Posts: 1,588
Likes: 0
From: Richmond Hill, Ontario, Canada
Rep Power: 0
babychai is an unknown quantity at this point
nick..er...i dunno...
nick who?
is he on sku term or work term right now?
Reply
Old Apr 16, 2003
  #19  
scsGrumPyDriveR's Avatar
Registered!!
 
Joined: Jun 2002
Posts: 1,063
Likes: 0
From: , Other, ZEBRA
Rep Power: 0
scsGrumPyDriveR is an unknown quantity at this point
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 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
Reply
Old Apr 17, 2003
  #20  
txtadik's Avatar
Registered!!
 
Joined: Oct 2002
Posts: 1,267
Likes: 0
From: mr. and mississsauga, Ontario, Canada
Rep Power: 0
txtadik is an unknown quantity at this point
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...

Reply
Old Apr 17, 2003
  #21  
Booohahaha's Avatar
BAD MON
iTrader: (1)
 
Joined: Apr 2001
Posts: 16,559
Likes: 0
From: GTA
Rep Power: 0
Booohahaha is an unknown quantity at this point
wooo... woot woot.. i actually know what that means now.. hahaha
wtf.. OMG .. im turning into a geek!!
Reply
Old Apr 17, 2003
  #22  
txtadik's Avatar
Registered!!
 
Joined: Oct 2002
Posts: 1,267
Likes: 0
From: mr. and mississsauga, Ontario, Canada
Rep Power: 0
txtadik is an unknown quantity at this point
now i want to put a computer in my dash to experiment with different C/Java code fragments while driving to school! woohoo! geek heaven man! woot!
Reply
Old Apr 17, 2003
  #23  
Swift's Avatar
Thread Starter
Registered!!
 
Joined: Apr 2003
Posts: 252
Likes: 0
From: Toronto
Rep Power: 0
Swift is an unknown quantity at this point
Whoa, I never knew there were so many ppl who are so computer nerdy on this board. It makes me feel like I'm part of the group hahaha
Reply
Old Apr 17, 2003
  #24  
babychai's Avatar
i want a baby hummer :)
iTrader: (1)
 
Joined: Dec 2002
Posts: 1,588
Likes: 0
From: Richmond Hill, Ontario, Canada
Rep Power: 0
babychai is an unknown quantity at this point
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 also breaks down your problem into smaller problems.

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...
Reply
Old Apr 17, 2003
  #25  
Booohahaha's Avatar
BAD MON
iTrader: (1)
 
Joined: Apr 2001
Posts: 16,559
Likes: 0
From: GTA
Rep Power: 0
Booohahaha is an unknown quantity at this point
OMG... a box of smarties.. ur starting to sound like my professor hahhahaha
ok.... txt..ur a geek ... jk jk!!
Reply
Old Apr 17, 2003
  #26  
MSoft's Avatar
Registered!!
iTrader: (1)
 
Joined: Jul 2002
Posts: 2,712
Likes: 0
From: Scarborough, Ontario, Canada
Rep Power: 0
MSoft is an unknown quantity at this point
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...
Reply
Old Apr 17, 2003
  #27  
txtadik's Avatar
Registered!!
 
Joined: Oct 2002
Posts: 1,267
Likes: 0
From: mr. and mississsauga, Ontario, Canada
Rep Power: 0
txtadik is an unknown quantity at this point
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...
arghhhhh u lucky bum! can't wait till i grad!

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!
Reply
Old Apr 17, 2003
  #28  
txtadik's Avatar
Registered!!
 
Joined: Oct 2002
Posts: 1,267
Likes: 0
From: mr. and mississsauga, Ontario, Canada
Rep Power: 0
txtadik is an unknown quantity at this point
Originally posted by Booohahaha
OMG... a box of smarties.. ur starting to sound like my professor hahhahaha
ok.... txt..ur a geek ... jk jk!!
my cool@ss instructor pretty much shocked us with the "Box of durex condoms" analogy hahahaha! woke everyone up in class!
Reply
Old Apr 17, 2003
  #29  
babychai's Avatar
i want a baby hummer :)
iTrader: (1)
 
Joined: Dec 2002
Posts: 1,588
Likes: 0
From: Richmond Hill, Ontario, Canada
Rep Power: 0
babychai is an unknown quantity at this point
Originally posted by txtadik
btw, did you take "scheme"? i heard it was a wierd-@ss language...
me, sunapollo and spidey did scheme...

all about recursion and lists...

i loved it...hahaha...
Reply
Related Topics
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
Stock 99
General Automotive Discussion
6
Sep 5, 2015 06:06 AM
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
SurrealCivic
Canada East
8
Apr 20, 2002 11:17 AM


Thread Tools
Search this Thread

All times are GMT -5. The time now is 05:15 PM.