- 博客(12)
- 收藏
- 关注
原创 rod cutting problem(Java)
Solve the rod cutting problem using the brutal force approach, top-down dp with memory, and bottom-up dp, respectively.package hw12;public class ROD_CUT {//递归方法 public static int cut_rod(int[] p,int n){ if (n==0){ return 0;
2020-07-15 10:25:24 206
原创 Q70, Q63 on leetcode.com
Q70, Q63 on leetcode.comQ70/*You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will be a positive integer.Example 1:
2020-07-15 10:23:57 142
原创 Dijkstra‘s shortest algorithm&maximum subarray problem(Java)
1. Implement the Dijkstra’s shortest algorithm.2. Solve the maximum subarray problem using the divide and conquer approach, can compare its efficiency with the DP approach.import java.util.ArrayList;import java.util.Collections;import java.util.Compara
2020-07-15 10:14:42 192
原创 Kruskal and Prim‘s MST algorithms(Java)
Implement Kruskal and Prim’s MST algorithms.import java.util.*;public class hw9 { public static void main(String[] args) { new hw9().testMST(); } void testMST() { Vertex aV = new Vertex('A'); Vertex bV = new Vertex('
2020-07-15 10:12:02 290 1
原创 Build graph(Java)
Build the graph as shown in the above figure using the adjacency list.Implement the BFS & DFS algorithm and traverse the graph starting from Vertex A.1 procedure DFS-iterative(G,v):2 let S be a stack3 S.push(v)4 while S is not emp.
2020-07-15 10:09:47 643
原创 BST student类 java
1. Implement a BST of students using Insert function. The information of a student includes id, name, and major.2. Search the BST given the name of a student.3. Find the successor/predecessor of a given student node.public class BTS { public static v.
2020-07-15 10:06:34 184
原创 BST(Java)
如上图构建BST。为BST实现以下功能:Height,PreOrder,PostOrder,InOrder,Tree_MinimumRecursive,Tree_MaximumIterativepublic class MainTest { public static void main(String[] args) { TreeNode root = new MainTest().buildTree(); new MainTest().preOrder(root); //new.
2020-07-15 10:03:44 187
原创 queue&stack&linkedlist(Java)
1. Implement a Queue on the basis of an array with consideration of overflow and underflow.2. Implement a stack using two queues to match the complexity O(1) for pop operation.3. Implement a Linkedlist with a sentinel, which includes insert, delete, and
2020-07-15 10:01:02 245
原创 Counting Sort&Radix Sort
1.Implement and test the Counting Sort.2.Implement and test the Radix Sort using Binary code.3.Implement a stack on the basis of an array with consideration of overflow and underflow.package homework4;import java.util.ArrayList;import java.util.Array
2020-07-15 09:58:40 167
原创 Implement the HeapSort using a Min-Heap(堆排序) Java
1.Implement the HeapSort using a Min-Heap.2.Design a heap to maintain the largest 5 numbers given an unlimited data flow.package homework3;import java.util.Arrays;public class MainTest { public static void main(String[] args) { double[] a = new
2020-07-15 09:56:48 137
原创 实施QuickSort并使用0和99之间的100个元素组成的数组测试排序算法
package homework2;import java.util.Arrays;public class TestMain { public static void main(String[] args) { int[] array = new int[100]; for(int i = 0 ; i < array.length ; i++) array[i] = (int) (Math.random() * 100); System.out.println(
2020-07-15 09:54:52 136
原创 merge/insertion sort(Java)
1. Implement the Insertion sort algorithm using Java or C.2. Implement the Merge sort algorithm using Java or C.3. Compare the performance of Insertion sort and Merge sort using a randomly generated array.4. Implement a recursive program to
2020-07-15 09:51:13 269
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人