-
Notifications
You must be signed in to change notification settings - Fork 244
Linking Nodes
Sar Champagne Bielert edited this page Apr 19, 2024
·
2 revisions
Unit 5 Session 1 (Click for link to problem statements)
Understand what the interviewer is asking for by using test cases and questions about the problem.
- How do nodes in a linked list reference each other?
- Each node has a
next
attribute that can be set to point to another node, linking them together in sequence.
- Each node has a
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Set the next
attribute of node_one
to node_two
to link these nodes sequentially.
1) Assign `node_two` as the `next` attribute of `node_one` to create a link between the two nodes.
- Failing to initialize the
next
attribute properly, which might not establish the link. - Confusing the assignment direction, e.g., setting
node_two.next = node_one
instead of the correct order.
node_one.next = node_two