摘要: ##1.反转链表 1 ← 3 ← 5 ← 7 ← 9 转换为 1 ← 3 ← 5 ← 7 ← 9 现在有一个单链表,尝试将其所有节点倒序排列 public class Main { public static void main(String[] args) { Node head = new No 阅读全文
posted @ 2022-05-12 22:31 学不会啊学不会 阅读(30) 评论(0) 推荐(0)
摘要: 给定 n 件物品,每一个物品的重量为 w[n],每个物品的价值为 v[n]。现挑选物品放入背包中,假定背包能承受的最大重量为 capacity,求装入物品的最大价值是多少? #1.递归 public class Main { static int[] w = {2, 3, 4, 5}; static 阅读全文
posted @ 2022-05-05 17:27 学不会啊学不会 阅读(22) 评论(0) 推荐(0)
摘要: 通过一趟排序将待排记录分隔成独立的两部分,其中的一部分比关键字小,后面一部分比关键字大,然后再对这前后的两部分分别采用这种方式进行排序,通过递归的运算最终达到整个序列有序。 public class Main { public static void main(String[] args) { in 阅读全文
posted @ 2022-05-05 16:25 学不会啊学不会 阅读(21) 评论(0) 推荐(0)