code logs -> 2010 -> Thu, 11 Mar 2010< code.20100310.log - code.20100312.log >
--- Log opened Thu Mar 11 00:00:25 2010
00:01 MyCatVerbs is now known as RichardBarrell
00:45 You're now known as TheWatcher[T-2]
00:48 You're now known as TheWatcher[zZzZ]
01:09 Reiv [NSwebIRC@Nightstar-1055e8af.waikato.ac.nz] has joined #code
01:09 * Reiv >.<
01:09
< Reiv>
That did not quite go to plan.
01:12 * Reiv pokes ToxicFrog. Hiiiii. That did not go well. Blegh.
01:14 Reiv [NSwebIRC@Nightstar-1055e8af.waikato.ac.nz] has quit [Client closed the connection]
01:16 Reiv [NSwebIRC@Nightstar-1055e8af.waikato.ac.nz] has joined #code
01:18
<@ToxicFrog>
Reiv: what happened?
01:18
< Reiv>
ToxicFrog: Woe, spiders, and misery.
01:18
<@ToxicFrog>
Oh?
01:18
< Reiv>
Nothing to do with computers excepting it wasted vastly more time than I would have liked.
01:18
<@ToxicFrog>
Aah.
01:18 * Reiv mumbles. His unicash account had run out, so they wouldn't let him onto the internets.
01:18
<@ToxicFrog>
o.O
01:19
<@ToxicFrog>
Your univ charges money for net access?
01:19
<@ToxicFrog>
I mean, as you access it, not as part of your student fees?
01:19
< Reiv>
And the EFTPOS was down, so I couldn't top it up at the handy kiosks, and had to instead trek to the ITS building to put money on manually. Which required going via an ATM.
01:19
< Reiv>
Right. Thank the aforementioned cockup of outsourcing.
01:20
< Reiv>
(Do note, internet in NZ sucks balls to begin with; we don't get automatic fat pipage like in the US to start with.)
01:21
<@ToxicFrog>
(Right. But I figured that access to the university network would be part of your per-semester fees, not a pay-as-you-go thing like food is here.)
01:21
< Reiv>
It costs us $0.015 per megabyte.
01:22
< Tarinaky>
Wow.
01:22
<@ToxicFrog>
That's daylight robbery!
01:22
< Reiv>
(1.5 cents)
01:22
< Reiv>
Yep, it sure is.
01:22
< Tarinaky>
How much would a phoneline+ADSL cost?
01:22
< Tarinaky>
:/
01:22
<@ToxicFrog>
And I'm betting they charge you for this even if you're accessing other systems in NZ rather than going off-island?
01:23
< Reiv>
Tarinaky: 256k, 5GB/month is NZ$27/month. The phoneline to run it on is $45/month.
01:23
< Tarinaky>
Woah!
01:23
< Reiv>
TF: Used to be national traffic was free, now it's Google traffic is free.
01:23
< Tarinaky>
My phoneline is only £1 a month.
01:23
< Reiv>
Tarinaky: that including line rental?
01:23
< Tarinaky>
That is the line rental.
01:23
< Reiv>
(Which is, hah, $43/month of that)
01:24
< Tarinaky>
Aside from the line rental there was an installation fee.
01:24
< Reiv>
Tarinaky: That's pretty impressive. So you can pay one quid per month and have a phone line, no extras needed?
01:24
< Tarinaky>
The ADSL itself costs £30 a month for unmetered braodband.
01:24
< Reiv>
Yeah, see, unmetered broadband in NZ is 2-3x the price of my piddlespeed plan.
01:24
<@ToxicFrog>
Here it's $25/mo line rental, and I pay another $25/mo for 5M/1M ADSL with no metering.
01:25
< Tarinaky>
Reiv: I got it as part of the package for my ADSL. I don't know how much it'd cost on its own.
01:25
< Tarinaky>
I get whatever speed I can get.
01:25
< Tarinaky>
Which varies quite widely by time of day.
01:25
<@ToxicFrog>
I could pay another $10/mo for even faster ADSL (or accept a monthly transfer limit at the same price).
01:25
< Tarinaky>
Somewhere between 256Kbps and 1Mbps. I dunno.
01:26
< Reiv>
Welcome to the wonders of privatising the national telecommunications monopoly. It's only recently (AKA last few years) really had that monopoly broken, and the compeditors are not doing much better in the deals just yet.
01:26
<@ToxicFrog>
(I could also switch to cable and pay twice as much for inferior service~)
01:26
< Reiv>
Or rather, they ARE - but the 'awesome deals' are one of two kinds: Naked DSL wherein your phoneline is VoIP, or Crazy Good Deals On National Phonecalls.
01:27
< Reiv>
The naked DSL would, I admit, grant me rather faster service for a grand total of ~$70/month. So no real savings, but better internet
01:27
< Reiv>
But at the cost that if you have a problem with your internet, you'd better hope their helpdesk has an 0800 number that accepts cellphones. ??
01:28
< Tarinaky>
No ISP I know of has an 0800 number.
01:28
< Tarinaky>
Nobody I know of has an 0800 helpdesk. Any companu.
01:28
< Reiv>
All our ISPs have 0800 numbers.
01:28
< Tarinaky>
*company
01:28
< Reiv>
er
01:28
< Reiv>
0800 = free call
01:28
< Tarinaky>
I wondered why New Zealand websites were so spartan.
01:28
< Tarinaky>
Reiv: Same here.
01:28
< Reiv>
It is standard practice in NZ.
01:29
< Reiv>
In fact if you do not have an 0800 number, people look at you funny. If you're in the services industry, people will /not report faults/ unless it's an 0800 number.
01:30
<@ToxicFrog>
800s are common practice here as well.
01:30
<@ToxicFrog>
Alhough it's 1-800 on this continent.
01:30
< Tarinaky>
*Calls cost 50p per minute. There is a 10p connection cost from Virgin Media landlines. Charges from mobiles and other networks may vary.
01:30
< Tarinaky>
That's if I have a fault with my DSL/ADSL
01:30
< Tarinaky>
:/
01:31
< Tarinaky>
To be quite honest - I live in the city so I'd just walk to the shop I bought the contract in/point of purchase and complain at them until they called for me.
01:32
<@ToxicFrog>
Anyways. Reiv. Linked lists?
01:35
< Reiv>
ToxicFrog: Indeed!
01:36
< Reiv>
I think I kind of get the idea. Each node holds the next nodes addres, and a spot of data.
01:36
< Reiv>
Right?
01:36
<@ToxicFrog>
Yes.
01:37
<@ToxicFrog>
The end of the list is typically handled by having this address be null; when you hit a node for which node.next == null, you're at the end of the list.
01:38
<@ToxicFrog>
So: given the first node in the list, you can reach all of the others by following these addresses; and you can also easily insert and remove nodes from the front or middle of the list.
01:38
<@ToxicFrog>
The drawback, of course, is that to access node N, you need to access nodes 1..N-1 first.
01:39
<@RichardBarrell>
And if you run links both ways then you get sued for patent infringement. ^_^
01:39
<@ToxicFrog>
Er, what?
01:40
<@RichardBarrell>
ToxicFrog: the USPTO granted a patent in (IIRC) 2006 whose claims encompass doubly-linked lists.
01:40
<@ToxicFrog>
Holy shit, so they did
01:40
<@RichardBarrell>
Blatantly invalid of course, but still hilarious nonetheless.
01:41
<@ToxicFrog>
It actually seems to patent all forms of n-tuply linked lists for n > 1
01:42
<@ToxicFrog>
1955 called, they want their data structures back~
01:43
<@RichardBarrell>
Orthia ~= Reiver, right?
01:43
<@ToxicFrog>
Orthia sometimes == Reiver and sometimes not.
01:43
<@ToxicFrog>
And vice versa.
01:43
<@ToxicFrog>
That is to say, Orthia ~= Reiver, but each of them has been known to use the other name.
01:45
<@RichardBarrell>
Oh I appreciate that it covers all n-tuply linked lists, it's just the fact that it covers doubly-linked-lists too as a special case is extra-specially-stupid.
01:45
<@ToxicFrog>
Reiv: what we're discussing here is a generalization of linked lists, where a node may hold the addresses of more than just the next node.
01:45
<@RichardBarrell>
I mean we're talking what, two hours into any entry-level data structures course? Maybe three if the instructor spent the first hour explaining the concept of pointers very, very laboriously first?
01:45
<@ToxicFrog>
The simplest form of this is the doubly linked list, where each node has 'next' and 'prev' rather than just 'next', allowing you to traverse the list in either direction.
01:46 Attilla [Attilla@FBC920.174237.E2DF5D.3AFA0A] has quit [[NS] Quit: ]
01:46
<@ToxicFrog>
You can also do more complicated things with this, such as having a list of on-screen objects that's sorted by X coordinate or by Y coordinate depending on which links you follow.
01:46
<@ToxicFrog>
Makes sense so far?
01:46
< Reiv>
RichardBarrell: Orthia would be the nickname for my lovely young lady. Oddly enough, I tend to visit her place a lot, and in channels where she has no interest, I do not bother to change nicks. ;)
01:47
<@ToxicFrog>
RichardBarrell: hell, I independently invented doubly linked lists and rings in high school
01:47
<@ToxicFrog>
Me and thousands of others
01:47
< Namegduf>
I read about them before I implemented even a normal list. :(
01:47
< Tarinaky>
Rings is another word for cyclic linked lists isn't it?
01:47
< Reiv>
ToxicFrog: So a tree is a linked list with k nodes?
01:48
< Namegduf>
Tarinaky: In this context, I believe so.
01:48
< Tarinaky>
Hehe. If you liked it you should'a put a cyclic linked list on it.
01:49
< Namegduf>
XD
01:49
<@ToxicFrog>
Tarinaky: yes, it is
01:49
<@ToxicFrog>
Reiv: no, but you're approaching the right idea
01:50
<@ToxicFrog>
A tree isn't a single list with multiple orderings, like a multiply linked list is; instead, it branches.
01:50
<@ToxicFrog>
Hang on while I whip together some art.
01:50
< Tarinaky>
A tree is built from the same nodes. They're just connected in different ways.
01:51
< Tarinaky>
Or rather a tree can be built from the same nodes.
01:51
< Tarinaky>
The data and two pointers. :x
01:51
<@ToxicFrog>
Same in terms of internal data, different in terms of concept
01:51
< Tarinaky>
Rather than pointing forwards and backwards you point at it children.
01:51
<@ToxicFrog>
And concept is more important than in-memory representation
01:51
<@ToxicFrog>
Please don't jump ahead.
01:51
< Tarinaky>
Sorry.
01:51
< Tarinaky>
:x
01:51
<@ToxicFrog>
Reiv: so, with a linked list, you might have:
01:52
<@ToxicFrog>
A->B->C->D->E
01:52
<@ToxicFrog>
List head is A, list tail is E.
01:52
<@ToxicFrog>
If it's doubly-linked, each node with a next and a prev pointer, you could also follow the prev pointers and it would look like this:
01:52
<@ToxicFrog>
E->D->C->B->A
01:53
<@ToxicFrog>
In a tree, however, rather than a node pointing to "the next entry in the list", it instead points to children.
01:54
< Reiv>
hrn
01:54
<@ToxicFrog>
A node in a tree has a value, and possibly a bunch of "child nodes". A typical arrangement for this has two children for each node, 'left' and 'right', arranged so that all the left children are < this node and all the right children are >.
01:54
<@ToxicFrog>
So you get something like this:
01:54
<@ToxicFrog>
A
01:54
<@ToxicFrog>
/ \
01:54
<@ToxicFrog>
B C
01:54
<@ToxicFrog>
/ \
01:54
<@ToxicFrog>
D E
01:54
< Reiv>
Does this mean that each node needs to autosort its children?
01:55
<@ToxicFrog>
I'm not sure what you mean by "needs to autosort", but that depends on the tree.
01:55
<@ToxicFrog>
Most trees are structured such that as you add stuff to the tree, it's added in the right place to keep the tree sorted.
01:58
< Reiv>
hrn.
01:58
<@ToxicFrog>
Trees don't need to be sorted, although they usually are; the defining feature of a tree is just this heirarchical structure.
01:59
< Reiv>
So then, when you want to add F to the tree above, you start at A and work your way down somehow?
01:59
<@ToxicFrog>
Yes. If we assume the tree is sorted, we follow rules something like this:
01:59
<@ToxicFrog>
- compare the new value to the current node
01:59
<@ToxicFrog>
- if it's ==, that value is already in the tree
02:00
<@ToxicFrog>
- if it's < and this.left is null, attach a new node there and store the value in it
02:00
<@ToxicFrog>
- if this.left is not null, repeat this process on that node
02:00
<@ToxicFrog>
- if it's > and this.right is null, attach a new node there and store the value in it
02:00
<@ToxicFrog>
- if this.right is not null, repeat this process on that node
02:01
<@ToxicFrog>
This way, you work your way down the tree until you either find a duplicate of the value you're inserting, or you find a free space to insert it at.
02:01
<@ToxicFrog>
Of course, not all trees need to be ordered.
02:01
<@ToxicFrog>
Consider, say, an AI that plays tic-tac-toe.
02:02
<@ToxicFrog>
It might use a tree of possible board layouts; the value stored at a given node is the current contents of the board, and each child is the result of a different possible move.
02:02
< Reiv>
hn.
02:05
<@ToxicFrog>
Is any of this making sense?
02:11
<@Vornicus>
Except that it's not what TF said but
02:11
<@Vornicus>
B
02:11
<@Vornicus>
/ \
02:11
<@Vornicus>
A D
02:11
<@Vornicus>
/ \
02:11
<@Vornicus>
C E
02:12 * Reiv eyes Vorn, sets him on fire
02:12
< Reiv>
what the shit happened there, It just stopped making sense again~
02:12
<@ToxicFrog>
He re-ordered the contents of the tree on the assumption that A < B < C < D < E
02:12
<@ToxicFrog>
(I just slapped the stuff in in random order)
02:13
< Tarinaky>
Reiv: If it's sorted, and A < B. Then A is left of B.
02:13
<@ToxicFrog>
Consider: B is at the top. A < B, so A goes to the left.
02:13
<@ToxicFrog>
Everything else is > B, so they go to the right.
02:13
<@ToxicFrog>
Repeat this on a smaller scale for D (C < D, E > D)
02:13
<@Vornicus>
hang on, I've got something in here...
02:14
<@ToxicFrog>
(incidentally, terminology: the top node is the root node. (in computer science trees grow downwards from the ceiling.) Nodes with children are branch nodes or interior nodes. Nodes without children are leaf nodes. A leaf node can turn into a branch by adding children to it, and a branch node into a leaf by deleting children.)
02:15
<@Vornicus>
Ah, I do in fact.
02:15
<@Vornicus>
I wrote a naive binary tree implementation for my data structures class.
02:15
<@Vornicus>
It's in Javascript, has an HTML interface.
02:16
<@Vornicus>
Who wants it?
02:16
<@Vornicus>
(I don't have a place i can drop files right now)
02:16 Rhamphoryncus [rhamph@Nightstar-8931f88f.abhsia.telus.net] has quit [Client exited]
02:17 * Reiv thinks.
02:17
< Reiv>
Vorn: I'd love to see it!
02:17
<@Vornicus>
mail?
02:17
< Reiv>
Also, uh, pastie?
02:17
< Reiv>
Or is that a bad idea. OK
02:17
< Reiv>
reiver@nightstar
02:18
<@ToxicFrog>
Why not pastebin it?
02:18
<@Vornicus>
Cuz then you have to save it and so forth
02:18
<@Vornicus>
But I guess.
02:19
<@ToxicFrog>
...yes, but you have to do that with email as well
02:21
<@Vornicus>
http://pastebin.starforge.co.uk/143 also here.
02:23
<@Vornicus>
Try b, a, d, c, e
02:24
<@Vornicus>
(then, to see the /problem/, refresh and try a, b, c, d, e)
02:25
<@Vornicus>
(there isn't a rebalancer in there.)
02:26 * gnolam reads the backscroll, boggles at NZ internets.
02:42
< Reiv>
Vorn: How does I read it?
02:42 * Reiv has been poking, hasn't figured it out.
02:42
< Reiv>
gnolam: Yeah, it's a bit of a political stinkball here. We were among the first in the world to get the internet; we've since dropped waaaaay behind.
02:46
<@Vornicus>
It's an html file?
02:46
<@Vornicus>
With javascript?
02:46
<@ToxicFrog>
Save it somewhere and open it in a browser
02:50
< Reiv>
Yeah, but then what am I meant to stick where?
02:52
< Reiv>
Unless I am misunderstanding the purpose of this device.
02:53
<@Vornicus>
Type text into the box, press "insert". This inserts it into the binary tree.
02:53 celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has joined #code
03:00 gnolam [lenin@Nightstar-38637aa0.priv.bahnhof.se] has quit [[NS] Quit: Z?]
03:00
< Reiv>
Or rather, how is the output being made?
03:00
< Reiv>
hm. And what am I looking at with the output?
03:03
<@Vornicus>
The pre-order, in-order, and post-order buttons give you the values in various orders - preorder gives a node before its children, inorder between its children, and postorder after.
03:03 * celticminstrel is still annoyed that this professor taught the class about malloc(), but never even mentioned free().
03:03
<@ToxicFrog>
celticminstrel: er what
03:03
<@ToxicFrog>
Escalate that shit, yo
03:03
< celticminstrel>
Hm?
03:04
<@ToxicFrog>
"bring this up as either an inherent flaw in the curriculum or a flaw in the way this professor teaches it, to whoever is responsible for such things"
03:04
<@ToxicFrog>
Depending on where the fault actually lies.
03:05
< celticminstrel>
I'm not really sure. It could be a fault in the textbook, since the professor seems to be following it fairly closely. (Though I haven't actually read the textbook, so I could be mistaken about that.) But the lab instructor did the exact same thing, so I dunno...
03:05
< celticminstrel>
I don't think it could be curriculum. Do universities even have a curriculum?
03:07
< celticminstrel>
(And then one of the example codes had "char* malloc()" at the top of a function. o.O )
03:08
< Reiv>
Vorn: ... I see no pre-order, in-order and post-order buttons.
03:08
< Reiv>
I may be looking in the wrong place.
03:24
<@Vornicus>
See a textbox and 7 buttons?
03:28
< Reiv>
Two textboxes, four buttons.
03:29
< Reiv>
Key [texbox] Search Delete
03:29
<@Vornicus>
what
03:29
< Reiv>
value [textbox] Write
03:29
< Reiv>
Dump
03:29
< Reiv>
Title: B Tree!
03:29
<@Vornicus>
That's Very Strange...
03:29
<@Vornicus>
...oh.
03:30
<@Vornicus>
sorry, I pasted the B tree, not the binary tree.
03:30 * Reiv rofls
03:30
< Reiv>
That would explain the confusion, yes ^.^
03:30
<@Vornicus>
http://pastebin.starforge.co.uk/144
03:30
< Reiv>
It is, btw, a pretty cool little thing.
03:30
<@Vornicus>
(I attached the binary tree)
03:32
< Reiv>
hm, ok
03:32
< Reiv>
What is 'post order' doing?
03:34
<@ToxicFrog>
postorder: all the children of a node before the node itself
03:35
<@ToxicFrog>
preorder: the node, then all of its children
03:35
<@ToxicFrog>
inorder: all of the children < this node, then this node, then all of the children > this node
03:37
< celticminstrel>
Um, < is left and > is right, correct?
03:37
< celticminstrel>
Because normally < is less than and > is more than.
03:42
< Reiv>
"Less than this node" would presumably placed on the left hand node, I guess
03:44
<@ToxicFrog>
Yes.
03:45
<@ToxicFrog>
Basically, in-order is, if you display the tree, start with the leftmost node and work left to right, ignoring height
03:47
< Reiv>
Aaah
03:47
< Reiv>
post-order?
03:50
<@ToxicFrog>
Start at the root. To display a node: first display all of the children of that node; then display the node's value.
03:51
<@ToxicFrog>
Pre-order is the converse: to display a node: first display the node's value; then display all of the children of that node.
03:55
< Reiv>
So it's going, hm
03:55
< Reiv>
e d c b a
03:55
< Reiv>
... ok, you suck mister webchat
03:55
<@ToxicFrog>
um
03:55
< Reiv>
Those were different lines~
03:56
<@ToxicFrog>
Aah.
03:56
<@ToxicFrog>
Using this tree:
03:56
<@ToxicFrog>
<Vornicus> B
03:56
<@ToxicFrog>
<Vornicus> / \
03:56
<@ToxicFrog>
<Vornicus> A D
03:56
<@ToxicFrog>
<Vornicus> / \
03:56
<@ToxicFrog>
<Vornicus> C E
03:56
<@ToxicFrog>
Pre-order: B A D E C
03:56
<@ToxicFrog>
Post-order: A C E D B
03:56
<@ToxicFrog>
In-order: A B C D E
03:58
<@ToxicFrog>
...sorry, pre-order should be B A D C E
03:58
<@ToxicFrog>
The keys are right next to each other~
04:07
< Reiv>
snrk~
05:21 Reiv [NSwebIRC@Nightstar-1055e8af.waikato.ac.nz] has quit [Ping timeout: 121 seconds]
05:32 celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has quit [[NS] Quit: *hums* Can't stay now!]
05:43 Serah [Z@26ECB6.A4B64C.298B52.D80DA0] has quit [Ping timeout: 121 seconds]
05:48 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has joined #code
06:05
< Orthia>
So, for this, I want: A Tree class, and a TreeNode class, right?
06:08
<@ToxicFrog>
You _can_ do it that way; you can often just use a single class, though.
06:08
<@ToxicFrog>
Tree {
06:08
<@ToxicFrog>
Tree left;
06:08
<@ToxicFrog>
Tree right;
06:08
<@ToxicFrog>
Object data;
06:08
<@ToxicFrog>
/* methods go here */
06:08
<@ToxicFrog>
}
06:11
< Orthia>
Huh.
06:11 Serah [Z@3A600C.A966FF.5BF32D.8E7ABA] has joined #code
06:11
< Orthia>
... actually, that works better
06:12
<@ToxicFrog>
I sleep soon
06:13
< Orthia>
No worries, and thank you for the help
06:13
< Orthia>
I think I almost understand the concept behind the trees now,
06:13
< Orthia>
the trick is getting my head around how you /do stuff/ with them.
06:13
< Orthia>
hn
06:13
< Orthia>
For a starter, if you would - what does each bit of the tree need to be able to do?
06:15
<@Vornicus>
The methods I have on my binary tree are simply the private "seek", and the ordered traversals.
06:16
< Orthia>
OK, and in Luddite?
06:16
< Orthia>
;)
06:17
<@ToxicFrog>
Methods for pre/post/in-order traversal
06:17
<@Vornicus>
Seek checks to see if the current node is the node you're looking for.
06:17
< Tarinaky>
Any situation where you have things owned by another thing recursively you -essentially- have a tree :x
06:17
<@ToxicFrog>
Personally I would expect insert as well, and find
06:17
< Tarinaky>
Even if you implement it in some bizarre way.
06:17
<@Vornicus>
TF: I do insert and delete and that sort of thing in the top-level object, from the result of seek.
06:17
<@ToxicFrog>
Tarinaky: really, trees and lists are just special cases of graphs
06:18 * Orthia tries to get his head around how the LZW alograthm even checks.
06:18 * Orthia decides to take a step back, make The Worlds Simplest Node.
06:18
<@Vornicus>
If this node isn't the node you're looking for, seek will call seek on the appropriate child node.
06:18
< Tarinaky>
ToxicFrog: Ooo. I don't know Graphs. What're they?
06:18
< Orthia>
So it needs to be able to create a new node off its point, right?
06:18
<@Vornicus>
a Graph is a set of Nodes connected by a set of Edges.
06:18
< Orthia>
Vorn: I presume seek is depth-first, then?
06:19
< Tarinaky>
Vornicus: Aaaah. 'Compilers: ...' mentions that.
06:19 * Tarinaky makes a note to look up graphs in detail.
06:19
<@Vornicus>
Not really--depth-first suggests I'm looking everywhere, seek just walks to the appropriate location, ignoring anything that can't have it.
06:19
<@Vornicus>
Graphs are really, really useful tools.
06:19
< Tarinaky>
Yes. I know.
06:20
<@Vornicus>
I used one to simulate herd immunity.
06:20
< Tarinaky>
Whenever I've needed them I've basically been working backwards from trees :/
06:20
< Tarinaky>
Needless to say this results in code that is too clever.
06:20
<@ToxicFrog>
Orthia: as far as LZW use of trees specifically goes, I suspect that the words are stored in a binary search tree, with the data being a (word, code) pair.
06:21
<@ToxicFrog>
This allows it to efficiently search the tree to see if the word it's seeing already has a code, and if not it can generate a new code and insert the word into the tree.
06:21 * Orthia frowns.
06:21
< Orthia>
Trees are recursive, y/n?
06:21
<@ToxicFrog>
y.
06:21
<@Vornicus>
y
06:22
< Orthia>
That helps.
06:22
<@Vornicus>
Though like most recursive algorithms it can also be done iteratively. You just don't want to.
06:22
<@Vornicus>
Well, don't usually want to.
06:22
<@Vornicus>
Er, don't... uh.
06:22
<@Vornicus>
Recursion is often nicer to look at.
06:23
<@Vornicus>
Not always though.
06:23
< Namegduf>
This reminds me of the time I saw someone use a recursive file format in parsing and proceeded to write a file in under a minute that segfaulted their program.
06:23
<@ToxicFrog>
Iteration is usually more efficient the algorithm is recursive but not tail-recursive. Recursion is usually easier to understand and reason about. Neither of these are universal truths.
06:23
< Namegduf>
Yeah.
06:23
<@ToxicFrog>
(for a trivial example of this, write recursive and iterative versions of fib)
06:24
< Namegduf>
With the note that it's NEVER tail recursive in languages that don't support it, and there's a lot of them.
06:24
<@ToxicFrog>
s/efficient the/efficient if the/
06:24
< Namegduf>
(The particular bit I was looking at WAS tail recursive... but Java doesn't implement it)
06:24
<@ToxicFrog>
;.;
06:24
< Tarinaky>
Tail recursion?
06:25
< Namegduf>
Tarinaky: If a function calls itself at the end of itself, with no additional instructions, instead of truly recursing, it can just reset the parameters and jump to the top.
06:25
<@ToxicFrog>
Tail recursion is when you have a function f() where the recursions are all of the form: return f(...)
06:25
< Namegduf>
Poor explanation, but-ah, that's better.
06:26
<@ToxicFrog>
This allows it to re-use the same stack slot and recurse infinitely, since it doesn't need to do anything with the return value after getting it.
06:26
< Tarinaky>
Ah. There;re compilers that can do that?
06:26
< Namegduf>
There's languages that do that, generally.
06:26
< Namegduf>
But I wouldn't be surprised if there's some compilers for languages where the common ones do not, which do.
06:26
<@ToxicFrog>
Scheme and Lua both implement proper tail recursion.
06:27
< Namegduf>
Python does not, either.
06:27
<@ToxicFrog>
IIRC in both of those languages it's part of the spec.
06:27
<@ToxicFrog>
There are other languages where it's not part of the spec but compilers/interpreters exist that add it.
06:27
< Orthia>
Vorn: Was your seek depth-first, perchance?
06:27
< Namegduf>
There's some justification for this, but I think it boils down to "recursion is unpythonic and simple tail recursion is easy to turn to iteration".
06:27
<@ToxicFrog>
Note that not all tail calls _have_ to be recursive:
06:27
<@ToxicFrog>
function f() return g() end
06:28
<@ToxicFrog>
function g() return 2 end
06:28
< Namegduf>
Yeah, you can optimise tail calls in general that way, not just tail recursion.
06:28
<@ToxicFrog>
This uses up only one stack slot (in a language with proper tail calls), since the call from f to g is a tail call even though it's not recursive.
06:28
< Orthia>
So, things my tree needs to be able to do: Make new nodes, decide which side a node /goes/ on... um.
06:29
<@Vornicus>
Remove a node.
06:29
< Orthia>
Find a value within the nodes, keep looking if no luck
06:29
< Orthia>
Delete nodes - oh, ew
06:29
< Namegduf>
Ah, trees.
06:30
< Orthia>
Trees, my nemesis.
06:30
< Namegduf>
I made the mistake of going along to a programming tutorial which was teaching them, they decided to demonstrate extreme programming at the same time, so I got to explain stuff.
06:30
<@Vornicus>
Deleting is the hardest one in here.
06:31
< Namegduf>
Yeah.
06:31
< Orthia>
Man, I don't even really /get/ them.
06:31
< Orthia>
Something about them just does my head in, yet I can draw them on paper.
06:31
<@Vornicus>
WHat you're going to want to do is find the node you want to delete, then walk further down the tree to find one to replace it with.
06:31
< Namegduf>
Orthia: Think of it like a forking list?
06:31
< Namegduf>
Deletion is a bit of a PITA
06:31
< Namegduf>
Relative to the others, I mean.
06:31
<@Vornicus>
Easy way is to step down and then keep searching for the /same thing/
06:31
< Orthia>
guf: Lists are not a strength of mine either, tbh
06:31
<@ToxicFrog>
Orthia: try writing a simple stand-alone tree to play with?
06:31
<@ToxicFrog>
Or start with a list, and then a tree
06:31
< Orthia>
TF: Hn. OK.
06:32
<@ToxicFrog>
(also, you don't need deletion for LZW)
06:32
<@ToxicFrog>
and now sleep
06:32
< Namegduf>
Hmm, not sure what I can suggest, aside that if you're at deletion, you're not doing too badly.
06:32
< Orthia>
ni, TF!
06:32
<@Vornicus>
in BinaryTree.html, remove is 33 lines, about half of which is just updating directions in various cases.
06:35
< Orthia>
Quick question: Constructor syntax in Java is what, again?
06:36
<@Vornicus>
<visibility options> <classname>(<arguments>) <throws> {<yadda>} <--- pretty sure that's it
06:41 * Orthia tries to remember how you compare strings in Java, for it's one of those annoying things where == does not cut it.
06:42
< Namegduf>
string1.equals(string2), IIRC
06:45 * Vornicus shoots Java for not stealing is/==
06:46
< Namegduf>
Java does == the worst possible way.
06:46
< Namegduf>
Yes, blocking operator override is fine.
06:47
< Namegduf>
But making == be byte-by-byte comparison or simply undefined is better than what they've done.
06:48
< Tarinaky>
How -does- Java compare strings? By address?
06:48
< Orthia>
By address, yes.
06:48
< Orthia>
So it checks if your string is the actual string they have stored elsewhere.
06:48
<@Vornicus>
== is object identity/address.
06:48
< Orthia>
Which is painful.
06:48
<@Vornicus>
But only for Objects
06:49
< Tarinaky>
This is why I hate Java :/
06:49
< Namegduf>
Which is most everything but constants in Java.
06:49
<@Vornicus>
for Primitives, it's equality comparison.
06:49
< Namegduf>
So 'someString == "blah"' works
06:49
<@Vornicus>
No it doesn't.
06:49
< Namegduf>
Doesn't it?
06:49
< Tarinaky>
No.
06:50
< Namegduf>
Then what about comparisons between Integet and int?
06:50
< Orthia>
But "someInt == 7" does.
06:50
< Namegduf>
*Integer
06:50
< Tarinaky>
Ints are primitives.
06:50
< Tarinaky>
Namegduf: Java is inconsistent.
06:50
<@Vornicus>
I think it automatically unboxes there.
06:50
< Tarinaky>
It passes some things by value and some things by type.
06:50
< Tarinaky>
:/
06:50 * Vornicus needs bed.
06:52
< Orthia>
ni, Vorn
06:52
< Orthia>
Do you have long enough to tell me what I did wrong though
06:52
<@Vornicus>
No, brains gone
06:52
<@Vornicus>
Have the dumb
06:52 Vornicus is now known as Vornicus-Latens
06:53
< Orthia>
no worries, ni Vorn!
06:53
< Orthia>
thankyou for the help.
06:53
< Orthia>
It took me all afternoon to start writing code, but that's because it took all afternoon and half a dozen tutorials to get the concept in my brain ¬¬
06:55
< Orthia>
http://pastebin.starforge.co.uk/145 - Something Isn't Right here.
06:56
< Orthia>
First off, in the constructor. :/
07:34 Orthia [orthianz@Nightstar-d7e9f968.xnet.co.nz] has quit [[NS] Quit: ]
07:35 Orthia [orthianz@Nightstar-c5e7ec93.xnet.co.nz] has joined #code
08:05 Serah [Z@3A600C.A966FF.5BF32D.8E7ABA] has quit [Ping timeout: 121 seconds]
08:14 Zed_ [Zed@Nightstar-d0088b95.or.comcast.net] has quit [Client closed the connection]
08:14 Zed_ [Zed@Nightstar-d0088b95.or.comcast.net] has joined #code
09:42 Zed [Zed@Nightstar-d0088b95.or.comcast.net] has joined #code
09:42 Zed [Zed@Nightstar-d0088b95.or.comcast.net] has quit [[NS] Quit: Leaving]
09:48 You're now known as TheWatcher
09:50 RichardBarrell [mycatverbs@Nightstar-58acb782.cable.virginmedia.com] has quit [Operation timed out]
09:52
< Tarinaky>
Open question: If you have a program that can recurse an arbitrarily large number of times - when does this become erroneous, what's the likely result and what is this called?
09:52
< Tarinaky>
Somewhat related to tail-recursion, in the case where it's not optimised.
09:52<~Reiver> stack overflow.
09:53<~Reiver> If you want more information, I suggest encoding the Ackermann Function.
09:53<~Reiver> You'll learn aaaaaaaall about recursion being a Bad Thing.
09:53 Rhamphoryncus [rhamph@Nightstar-8931f88f.abhsia.telus.net] has joined #code
09:54
< Tarinaky>
I had a quick look on wikipedia and it seemed to imply a stack overflow was a bad thing ;x
09:54
< Tarinaky>
Reiver: I don't want to kill this computer atm. :p
09:57<~Reiver> Oh, the computer won't die.
09:57<~Reiver> Assuming you do it in Java, or some other language that has enough sense to halt a program that memory overflows.
09:59
< Tarinaky>
Yeah. I only know C/C++.
09:59
< Tarinaky>
I don't want to take that chance.
09:59
< Tarinaky>
Plus I don't really have time,.
10:00
< Tarinaky>
I was just hoping I could quickly cite something in passing as I mention this is bad.
10:00 * TheWatcher eyes
10:00
<@TheWatcher>
It won't kill the computer anyway
10:01
<@TheWatcher>
The OS will kill the process once it overflows its stack, in general
10:04
< Tarinaky>
This specific case involves a finite automata simulated by recursive function calls :x
10:06
< Tarinaky>
I figure it'd have to be a pretty damn big automata though.
10:31 Attilla [Attilla@FBC920.174237.E2DF5D.3AFA0A] has joined #code
10:31 mode/#code [+o Attilla] by Reiver
12:01 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has quit [Connection closed]
12:28
< Tarinaky>
Nothing like looking at an essay you're going to hand in for physics and seeing you've referenced absolutely no physics.
12:28
< Tarinaky>
Good-o.
12:28
< Tarinaky>
Clearly I did the wrong major >.> whoops.
12:30
< Tarinaky>
On a related note: I'd like to cite my communications with you guys since you did help me a lot - any objections or particular pseudonyms you'd like me to cite you under?
12:34 * TheWatcher should be referred to as Shadowy Associate Number 5. ¬¬
12:34
< Tarinaky>
I'll just keep you as Anon. then.
12:35
<@TheWatcher>
Blast >.>
12:35
<@TheWatcher>
'Chris Page' if you want to use a name
12:35
< Tarinaky>
TBH I don't really mind either way :x
12:36<~Reiver> Shadowy Associate Number 7, here
12:36
< Tarinaky>
Page C et al, 2010. \emph{The Nightstar Network's \#{}Code} [Internet Chat] (Personal communication, 2010)
12:37
< Tarinaky>
Although I will query that 'Paige' is normally spelt with an 'i' :x
12:37
< Tarinaky>
Not that I want to suggest you can't spell your own name or anything >.>
12:37 * TheWatcher is vaguely surprised they aren... stares at Tarinaky
12:37
< Tarinaky>
Vaguely surprised what?
12:38
< Tarinaky>
q.q
12:38
<@TheWatcher>
you're not using the IEEE citation system
12:38
< Tarinaky>
I've not been told to use the IEEE citation system.
12:39<~Reiver> Dear lordie.
12:39
< Tarinaky>
I'm trying to use Harvard atm.
12:39
< Tarinaky>
TheWatcher: What is the IEEE citation system?
12:41
<@TheWatcher>
In-text references are numberes thus [1] then the references page lists each entry as C. Page, /title: subtitle/, Edition, Volume. Place of publication: publisher, year, page numbers(s)
12:41
< Tarinaky>
'Meh'.
12:42
< Tarinaky>
The requirement in the marking guides says it just has to be consistent.
12:42
< Tarinaky>
Since there's no style guide.
12:43
<@TheWatcher>
Amusingly, IEEE explicitly states that only published works (and websites) may be cited - emails, chats, phone conversations, etc
12:43
<@TheWatcher>
are excluded
12:43
< Tarinaky>
The guide I'm looking at for IEEE says they still need to be cited in the body of the text.
12:43
< Tarinaky>
At least, in terms of authorship.
12:43
<@TheWatcher>
yeah, just not on the reference list, or with the [N] format
12:44
< Tarinaky>
My Tutor said I could (and should) reference private comms.
12:44
< Tarinaky>
So I have.
12:44
< Tarinaky>
Or rather cite.
12:44
< Tarinaky>
W/e.
12:45
< Tarinaky>
You're up there with the likes of the Dragon book.
12:45
< Tarinaky>
When I got that out the library I had no idea I'd actually be able to -use- it >.<
12:45
< Tarinaky>
Sadly you're also up there with the likes of Microsoft so swings and roundabouts.
12:47 * TheWatcher just knows far more about citation systems than is healthy for anyone -_-
12:49
<@TheWatcher>
Side effect of trying to write the reference handler for my course processor software - in that, people specify a reference in a special tag format, and it generates the appropriate gubbins based on the citation system the select
12:49
<@TheWatcher>
It is Vaguely Hellish >.>
12:49
< Tarinaky>
I can only imagine.
12:50
< Tarinaky>
Why was me not using IEEE particularly odd though?
12:50
< Tarinaky>
I don't do comp sci :/
12:50
< Tarinaky>
Or electronics.
12:50
< Tarinaky>
Or even engineering.
12:50
< Tarinaky>
:x
12:52
<@TheWatcher>
lots of science folks I know use it too, not just cs/EE people
12:52
<@TheWatcher>
Might be a manchester thing
12:52
< Tarinaky>
Oh.
12:53
< Tarinaky>
Our instruction on the subject was: "Pick one you like and stick with it. If you ever get published every journal has its own style guide so you'll end up rewriting it to fit anyway."
12:53
<@TheWatcher>
(besides, not particularly odd, I was just vaguely surprised.)
12:54
< Tarinaky>
Ah. What was the "vaguely surprised thay aren..."?
12:55
<@TheWatcher>
That was be starting to say that I was "vaguely surprised they aren't having you use IEEE", before you started on my name ;P
12:55
<@TheWatcher>
*me
12:56
< Tarinaky>
Oooo.
12:56 * Tarinaky wasn't sure if you were giving him a real name or a pseudonym.
12:56
<@TheWatcher>
No, that's my name.
12:56
< Tarinaky>
Ah.
12:56
< Tarinaky>
Fair enough.
12:57
< Tarinaky>
Inform your parents to inform whatever ancestor they inherited it off that they can't spell.
12:57
< Tarinaky>
:p
12:58
< Tarinaky>
Ooo! I have 2 infected files :x
12:59 * Tarinaky facepalms.
12:59
< Tarinaky>
And now I lose the list of infecte files.
12:59
< Tarinaky>
Have to scan again :/
13:00
< Tarinaky>
-Probably- just something sitting idle in a webcache though. I'm on linux and I don't see anything suspicious in ps aux.
13:07 Tarinaky [Tarinaky@Nightstar-18f9e938.adsl.virginmedia.net] has quit [Ping timeout: 121 seconds]
13:16 Orthia [orthianz@Nightstar-c5e7ec93.xnet.co.nz] has quit [Client closed the connection]
13:21 Tarinaky [Tarinaky@Nightstar-95fa4ffc.adsl.virginmedia.net] has joined #code
13:31 Orthia [orthianz@Nightstar-c5e7ec93.xnet.co.nz] has joined #code
14:46 Orthia [orthianz@Nightstar-c5e7ec93.xnet.co.nz] has quit [Client closed the connection]
14:50 gnolam [lenin@Nightstar-38637aa0.priv.bahnhof.se] has joined #code
14:52 Orthia [orthianz@Nightstar-c5e7ec93.xnet.co.nz] has joined #code
15:04 Tarinaky [Tarinaky@Nightstar-95fa4ffc.adsl.virginmedia.net] has quit [Ping timeout: 121 seconds]
15:11 Serah [Z@3A600C.A966FF.5BF32D.8E7ABA] has joined #code
15:18 Tarinaky [Tarinaky@Nightstar-3a16986c.adsl.virginmedia.net] has joined #code
15:18 Vornicus-Latens [vorn@ServerAdministrator.Nightstar.Net] has quit [Ping timeout: 121 seconds]
15:21
< Tarinaky>
Ah! Apparently they aren't infected as such. They're just phishing emails in my thunderbird cache.
15:22 Vornicus-Latens [vorn@ServerAdministrator.Nightstar.Net] has joined #code
15:22 mode/#code [+o Vornicus-Latens] by Reiver
15:27 celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has joined #code
16:07 Orthia [orthianz@Nightstar-c5e7ec93.xnet.co.nz] has quit [Ping timeout: 121 seconds]
16:14 Serah [Z@3A600C.A966FF.5BF32D.8E7ABA] has quit [Ping timeout: 121 seconds]
16:28 ToxicFrog [ToxicFrog@ServerAdministrator.Nightstar.Net] has quit [Ping timeout: 121 seconds]
16:43 ToxicFrog [ToxicFrog@ServerAdministrator.Nightstar.Net] has joined #code
16:43 mode/#code [+o ToxicFrog] by Reiver
16:54 Serah [Z@26ECB6.A4B64C.298B52.D80DA0] has joined #code
18:25 Vornicus-Latens is now known as Vornicus
19:01 Serah [Z@26ECB6.A4B64C.298B52.D80DA0] has quit [Ping timeout: 121 seconds]
19:04 ToxicFrog [ToxicFrog@ServerAdministrator.Nightstar.Net] has quit [Ping timeout: 121 seconds]
19:05 ToxicFrog [ToxicFrog@ServerAdministrator.Nightstar.Net] has joined #code
19:05 mode/#code [+o ToxicFrog] by Reiver
19:20 Serah [Z@26ECB6.A4B64C.298B52.D80DA0] has joined #code
19:22 Taki^ [Meh@Nightstar-39d785ef.consolidated.net] has quit [Client closed the connection]
19:23 AnnoDomini [annodomini@Nightstar-26c37296.adsl.tpnet.pl] has joined #code
19:23 mode/#code [+o AnnoDomini] by Reiver
19:30 Taki^ [Meh@Nightstar-39d785ef.consolidated.net] has joined #code
19:36 Taki^ [Meh@Nightstar-39d785ef.consolidated.net] has quit [Client closed the connection]
19:43 Taki^ [Meh@Nightstar-39d785ef.consolidated.net] has joined #code
20:08 Vornicus [vorn@ServerAdministrator.Nightstar.Net] has quit [[NS] Quit: Leaving]
20:11 Vornicus [vorn@ServerAdministrator.Nightstar.Net] has joined #code
20:11 mode/#code [+o Vornicus] by Reiver
20:12 Taki^ [Meh@Nightstar-39d785ef.consolidated.net] has quit [Connection reset by peer]
20:20 Taki^ [Meh@Nightstar-39d785ef.consolidated.net] has joined #code
20:24 Taki^ [Meh@Nightstar-39d785ef.consolidated.net] has quit [Client closed the connection]
20:30 Taki^ [Meh@Nightstar-39d785ef.consolidated.net] has joined #code
20:32 Taki^ [Meh@Nightstar-39d785ef.consolidated.net] has quit [Connection reset by peer]
20:38 Taki^ [Meh@Nightstar-39d785ef.consolidated.net] has joined #code
20:38 Taki^ [Meh@Nightstar-39d785ef.consolidated.net] has quit [[NS] Quit: ]
21:06 Netsplit *.net <-> *.split quits: @Attilla, Tarinaky, Zed_, PinkFreud
21:06 Netsplit over, joins: Zed_, Tarinaky
21:06 Netsplit over, joins: Attilla
21:06 mode/#code [+o Attilla] by Reiver
21:11 PinkFreud [WhyNot@NetworkAdministrator.Nightstar.Net] has joined #code
21:28 AnnoDomini [annodomini@Nightstar-26c37296.adsl.tpnet.pl] has quit [[NS] Quit: Slep.]
22:15
<@McMartin>
http://reprog.wordpress.com/2010/03/09/where-dijkstra-went-wrong-the-value-of-ba sic-as-a-first-programming-language/
22:58 Netsplit *.net <-> *.split quits: PinkFreud
23:03 PinkFreud [WhyNot@NetworkAdministrator.Nightstar.Net] has joined #code
23:32 You're now known as TheWatcher[T-2]
23:34 You're now known as TheWatcher[zZzZ]
23:43 ToxicFrog [ToxicFrog@ServerAdministrator.Nightstar.Net] has quit [Client closed the connection]
23:51 RichardBarrell [mycatverbs@Nightstar-58acb782.cable.virginmedia.com] has joined #code
23:54 Taki^ [Meh@Nightstar-39d785ef.consolidated.net] has joined #code
23:56 Taki^ [Meh@Nightstar-39d785ef.consolidated.net] has quit [Connection reset by peer]
23:58 SmithKurosaki [Smith@Nightstar-1a7d4505.dsl.teksavvy.com] has quit [Connection closed]
--- Log closed Fri Mar 12 00:00:26 2010
code logs -> 2010 -> Thu, 11 Mar 2010< code.20100310.log - code.20100312.log >