Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Computer Science

Jae Long
Jae Long
640 Points

Why check if size is 1?

If size is calculated using index which starts at 0 doesn't that mean if we had a linked list with two nodes size would equal one? But if those two nodes weren't in order we'd still return the linked list?

1 Answer

Hi Jae Long While I'm a newbie to the program, I might try a hand at your question. I think I understand the direction that you are coming from. Perhaps, the logic is that zero counts as a number, but zero is the absence of a number. Think of it this way. As 0 x 0 is 0.... and 1 x 1 is 1... and 0 + 1 is 1, then two nodes still = 2. Zero is void and would only be conceptual if there are no nodes. Does that make sense? It's great to challenge the data. It helps you learn and advance, so it's good that you ask. Others may have wondered too.