Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Introduction to Data Structures!
You have completed Introduction to Data Structures!
Preview
Let's continue adding operations to our data structure to make it useful. In this video we'll implement an insert operation that takes an index as an insertion point.
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
all elements after the particular
index need to be shifted.
0:00
Within linked lists,
0:01
we just need to change the references to
next on a few nodes, and we're good to go.
0:03
Since each node points to the next one,
by swapping out these references,
0:08
we can insert a node at any point
in the list in constant time.
0:12
Much like binary search,
though, there's a catch.
0:16
To find the node at that
position we want to insert,
0:19
we need to traverse the list and
get to that point.
0:22
We just implemented our search
algorithm for the linked list type.
0:26
And we know that his runs in linear time.
0:29
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up