课程: Java Algorithms
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Create a custom data structure for linked list algorithms - Java教程
课程: Java Algorithms
Create a custom data structure for linked list algorithms
- [Instructor] Although there's a linked list data structure available in Java, not every algorithm you'll ever need will be built into the standard library. Instead, you may need to create your own data structure with your own algorithms to manipulate your data more effectively. In fact, we can create our own linked list in Java using classes, specifically a LinkedList class and a node class. Here we have a custom LinkedList class that has a Node attribute called head. This represents the first item or the head of the list. We also have a class called Node, which is used by the LinkedList. Each node has an int data and a reference to the next node in the list. Let's create a LinkedList from the CustomLinkedList class. We'll use the built-in constructor. Then we can create some nodes to put in the list. To put the firstNode in the list, we can set the head node equal to the firstNode. We'll access the list, .head and we'll give it the firstNode. To add the rest of the nodes, we'll…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
What is a linked list?2 分钟 18 秒
-
(已锁定)
Using the built-in linked list data structure in Java4 分钟 16 秒
-
(已锁定)
Create a custom data structure for linked list algorithms3 分钟 32 秒
-
(已锁定)
Linked list algorithms: Delete back half of a linked list4 分钟
-
(已锁定)
Solution: Sum contents of a linked list1 分钟 36 秒
-
-
-
-
-