- 博客(29)
- 收藏
- 关注
原创 Day39
1.代码/** ********************* * Critical path. Net validity checks such as loop check not implemented. The * source should be 0 and the destination should be n-1. * * @return The node sequence of the path. ********************* */ public
2022-03-07 22:12:43
252
1
原创 Day30
1.代码:package datastructure.tree;import java.nio.charset.StandardCharsets;import java.nio.file.Files;import java.nio.file.Paths;import java.util.Arrays;import java.util.stream.Collectors;public class Huffman { /** * An inner class for Huffma.
2022-03-02 21:46:46
312
1
原创 Day29
1.代码:/** ********************* * Construct the alphabet. The results are stored in the member variables * charMapping and alphabet. ********************* */ public void constructAlphabet() { // Initialize. Arrays.fill(charMapping, -1);..
2022-03-01 11:03:51
166
原创 Day28
1.代码:今日的主要任务是定义哈夫曼树相关参数,并实现存储字符的文件的读取。package datastructure.tree;import java.nio.charset.StandardCharsets;import java.nio.file.Files;import java.nio.file.Paths;import java.util.Arrays;import java.util.stream.Collectors;public class Huffman { /
2022-02-27 21:43:45
475
1
原创 Day27
1.代码:package datastructure.tree;public class Hanoi { /** ******************* * Move a number of plates. * * @param paraSource The source pole. * @param paraIntermedium The intermediary pole. * @param paraDestination The destinatio
2022-02-26 15:47:39
139
2
原创 Day26
1.代码:利用栈实现先序遍历和后序遍历/** ********************* * Pre-order visit with stack. ********************* */ public void preOrderVisitWithStack() { ObjectStack tempStack = new ObjectStack(); BinaryCharTree tempNode = this; while (!tempStack.isEmpt
2022-02-25 21:16:32
169
1
原创 Day25
1.建立一个具有通用性的栈代码如下:package datastructure.stack;public class ObjectStack { /** * The depth. */ public static final int MAX_DEPTH = 10; /** * The actual depth. */ int depth; /** * The data */ Object[] data; /* * Construct an emp
2022-02-24 16:51:53
111
2
原创 Day24
1.代码:在昨天的代码里加上第二种构造方法,代码如下:/** ********************* * The second constructor. The parameters must be correct since no validity * check is undertaken. * * @param paraDataArray The array for data. * @param paraIndicesArray The array for i
2022-02-23 15:10:18
108
2
原创 Day23
1.代码:在昨天代码的基础上加上此段代码: public void toDataArraysObjectQueue() { // Initialize arrays. int tempLength = getNumNodes(); valuesArray = new char[tempLength]; indicesArray = new int[tempLength]; int i = 0; // Traverse and convert at the same time
2022-02-22 16:31:19
184
3
原创 Day22
1.代码一:包含各种数据类型的队列:package datastructure.queue;public class CircleObjectQueue { /** * The total space. One space can never be used. */ public static final int TOTAL_SPACE = 10; /** * The data. */ Object[] data; /** * The index of the
2022-02-21 22:06:16
168
原创 Day21
1.代码:package yrx;import java.util.Arrays;public class BinaryCharTree { /** * The value in char */ char value; /** * The left child */ BinaryCharTree leftChild; /** * The right child */ BinaryCharTree rightChild; /** ********
2022-02-20 17:00:41
180
原创 Day20
1.面向对象与面向过程相比, 有哪些优势? 注: 第 1 - 10 天的程序, 就是面向过程的.面向对象编程可以将复杂的任务抽象成对象,并且为不同的对象建立方法,进而将复杂的问题进行简化;更人性化,使得我们的代码更容易理解,也更易维护。2.比较线性表和链接的异同.相同之处:都表示数据之间的线性关系;不同之处:线性表是一片连续的存储空间,链表是分散的任意的空间;线性表需要预分配一定的空间,而链表不需要(即长度是不固定的)3.分析线性表和链接的优缺点.线性表中数据的位置就是其绝对位置,方
2022-02-19 15:41:44
223
1
原创 Day19
1.代码:package yrx;public class MyString { /** * The maximal length. */ public static final int MAX_LENGTH = 10; /** * The actual length. */ int length; /** * The data. */ char[] data; /** ****************** * Construct an empt
2022-02-18 16:53:38
224
1
原创 Day18
1.代码:package yrx;public class CircleCharQueue { /** * The total space.One space can never be used */ public static final int TOTAL_SPACE = 10; /** * The data. */ char[] data; /** * The index for calculating the head.The actual head i
2022-02-17 15:45:24
351
1
原创 Day17
1.代码:package yrx;public class LinkedQueue { /** * An inner class. */ class Node { /** * The data */ int data; /** * The reference to the next node. */ Node next; /** **************** * The constructor. * * @p.
2022-02-16 12:06:09
206
原创 Day16
1.代码:package yrx;public class Recursion { /** ********************* * Sum to N. No loop, however a stack is used.(运用了栈) * * @param paraN The given value. * @return The sum. ********************* */ public static int sumToN(int paraN)
2022-02-15 20:32:44
191
1
原创 Day15
1.代码package yrx;public class CharStack { /** * The depth. */ public static final int MAX_DEPTH = 10; /** * The actual depth. */ int depth; /** * The data */ char[] data; /** ********************* * Construct an empty char sta
2022-02-12 21:09:44
142
2
原创 Day14
1.代码package yrx;public class CharStack { /** * The depth. */ public static final int MAX_DEPTH = 10; /** * The actual depth. */ int depth; /** * The data */ char[] data; /** ********************* * Construct an empty char sta
2022-02-12 20:57:18
169
1
原创 Day13
1.代码:package yrx;public class LinkedList { /** * An inner class(内部类) */ class Node { /** * The data. */ int data; /** * The reference to the next node. */ Node next; /** * The constructor * * @param paraValue T.
2022-02-12 19:55:56
190
1
原创 Day12
1.代码:package yrx;public class SequentialList { /** * The maximal length of the list. It is a constant. */ public static final int MAX_LENGTH = 10; /** * The actual length not exceeding MAX_LENGTH. Attention: length is not only the * membe
2022-02-11 18:38:12
189
1
原创 Day11
1.final:定义常量,以后对该常量进行更改,只需要在定义处更改。2.类名必须和构造方法名相同。3.问题:a.这段代码可以改成这样吗?b.length=0,是将data里面的数据删除了吗?4.代码:package yrx;public class SequentialList { /** * The maximal length of the list. It is a constant. */ public static final int MAX_L
2022-02-10 18:02:13
176
2
原创 Day10
1.借助java.util.Random类来生成随机数Random类包含两个构造方法:a、public Random()该构造方法使用一个和当前系统时间对应的相对时间有关的数字作为种子数,然后使用这个种子数构造Random对象。b、public Random(long seed)该构造方法可以通过制定一个种子数进行创建。再次强调:种子数只是随机算法的起源数字,和生成的随机数字的区间无关。2.问题:a.该句代码是指生成upperBound到lowerBound区间类的整数吗?
2022-02-09 13:37:30
95
1
原创 Day9
package yrx;public class WhileStatemen { public static void main(String arg[]) { whileStatementTest(); }// of main /** ********************* * The sum not exceeding a given value. ********************* */ public static void whileStat...
2022-02-08 16:20:50
236
2
原创 Day8
JAVA中的注释: 单行注释:注释的内容从 // 开始 多行注释:匹配规则就是 /* 与之对应的最近的 */ 结束符 文档注释:使用文档注释的方式 以 /** 开头 */ 结尾。包含在这之内的内容就是文档注释的内容。 常用标记 @author 代表的是作者是谁,如果有多个,可以写多个标记 @since 从哪个版本开始支持该类的功能 @version 当前类的版本信息 @see 该标记可用在类与方法上,表示参考的类或方法。 @para
2022-02-07 15:55:16
195
2
原创 Day7
java.util的Arrays类:常见方法:1.填充数组:fillArrays.fill(arr, 2);(全部赋值为2)Arrays.fill(arr, 1,3,8);(给第一位到第三位赋值为8)2.截取数组:copeOf和copeOfRangeint []arr1 = Arrays.copyOf(arr, 3);(截取前三个数)int []arr1 = Arrays.copyOfRange(arr,1,3);(从第一个截取到第三个)*不包括第一个元素3.数组排序:sort
2022-02-06 16:13:54
102
2
原创 Day4
闰年判断:代码及运行结果截图: print:直接输出,并且停留在最后一个字符之后;println:直接输出,但是会停留在下一行(相当于print中加'\n')&&符...
2022-02-04 11:10:05
272
原创 DAY1-DAY3
Day1package、import、printlnJava中的一个包就是一个类库单元,包内包含有一组类,它们在单一的名称空间之下被组织在了一起。这个名称空间就是包名。可以使用import关键字来导入一个包。在import声明某个包名以后,在接下来的程序中可以直接使用该包中的类。代码及运行结果:Day2熟悉加、减、乘、除、整除、取余操作对于println当括号里的内容是你已经声明并赋值的变量时,就不用引号。代码及其运算结果:Day3if语句以及函数的运用...
2022-02-03 13:25:52
480
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人