Replace ``js with ``javascript

This commit is contained in:
krahets
2023-02-08 04:27:55 +08:00
parent 0407cc720c
commit 22b7d65d20
27 changed files with 127 additions and 92 deletions
+8 -8
View File
@@ -79,7 +79,7 @@ G. M. Adelson-Velsky 和 E. M. Landis 在其 1962 年发表的论文 "An algorit
=== "JavaScript"
```js title=""
```javascript title=""
class TreeNode {
val; // 结点值
height; //结点高度
@@ -214,7 +214,7 @@ G. M. Adelson-Velsky 和 E. M. Landis 在其 1962 年发表的论文 "An algorit
=== "JavaScript"
```js title="avl_tree.js"
```javascript title="avl_tree.js"
/* 获取结点高度 */
height(node) {
// 空结点高度为 -1 ,叶结点高度为 0
@@ -328,7 +328,7 @@ G. M. Adelson-Velsky 和 E. M. Landis 在其 1962 年发表的论文 "An algorit
=== "JavaScript"
```js title="avl_tree.js"
```javascript title="avl_tree.js"
/* 获取平衡因子 */
balanceFactor(node) {
// 空结点平衡因子为 0
@@ -459,7 +459,7 @@ AVL 树的独特之处在于「旋转 Rotation」的操作,其可 **在不影
=== "JavaScript"
```js title="avl_tree.js"
```javascript title="avl_tree.js"
/* 右旋操作 */
rightRotate(node) {
const child = node.left;
@@ -592,7 +592,7 @@ AVL 树的独特之处在于「旋转 Rotation」的操作,其可 **在不影
=== "JavaScript"
```js title="avl_tree.js"
```javascript title="avl_tree.js"
/* 左旋操作 */
leftRotate(node) {
const child = node.right;
@@ -766,7 +766,7 @@ AVL 树的独特之处在于「旋转 Rotation」的操作,其可 **在不影
=== "JavaScript"
```js title="avl_tree.js"
```javascript title="avl_tree.js"
/* 执行旋转操作,使该子树重新恢复平衡 */
rotate(node) {
// 获取结点 node 的平衡因子
@@ -1003,7 +1003,7 @@ AVL 树的独特之处在于「旋转 Rotation」的操作,其可 **在不影
=== "JavaScript"
```js title="avl_tree.js"
```javascript title="avl_tree.js"
/* 插入结点 */
insert(val) {
this.root = this.insertHelper(this.root, val);
@@ -1245,7 +1245,7 @@ AVL 树的独特之处在于「旋转 Rotation」的操作,其可 **在不影
=== "JavaScript"
```js title="avl_tree.js"
```javascript title="avl_tree.js"
/* 删除结点 */
remove(val) {
this.root = this.removeHelper(this.root, val);
+3 -3
View File
@@ -79,7 +79,7 @@ comments: true
=== "JavaScript"
```js title="binary_search_tree.js"
```javascript title="binary_search_tree.js"
/* 查找结点 */
function search(num) {
let cur = root;
@@ -244,7 +244,7 @@ comments: true
=== "JavaScript"
```js title="binary_search_tree.js"
```javascript title="binary_search_tree.js"
/* 插入结点 */
function insert(num) {
// 若树为空,直接提前返回
@@ -517,7 +517,7 @@ comments: true
=== "JavaScript"
```js title="binary_search_tree.js"
```javascript title="binary_search_tree.js"
/* 删除结点 */
function remove(num) {
// 若树为空,直接提前返回
+4 -4
View File
@@ -62,7 +62,7 @@ comments: true
=== "JavaScript"
```js title=""
```javascript title=""
/* 链表结点类 */
function TreeNode(val, left, right) {
this.val = (val === undefined ? 0 : val); // 结点值
@@ -229,7 +229,7 @@ comments: true
=== "JavaScript"
```js title="binary_tree.js"
```javascript title="binary_tree.js"
/* 初始化二叉树 */
// 初始化结点
let n1 = new TreeNode(1),
@@ -361,7 +361,7 @@ comments: true
=== "JavaScript"
```js title="binary_tree.js"
```javascript title="binary_tree.js"
/* 插入与删除结点 */
let P = new TreeNode(0);
// 在 n1 -> n2 中间插入结点 P
@@ -527,7 +527,7 @@ comments: true
=== "JavaScript"
```js title=""
```javascript title=""
/* 二叉树的数组表示 */
// 直接使用 null 来表示空位
let tree = [1, 2, 3, 4, null, 6, 7, 8, 9, null, null, 12, null, null, 15];
+2 -2
View File
@@ -66,7 +66,7 @@ comments: true
=== "JavaScript"
```js title="binary_tree_bfs.js"
```javascript title="binary_tree_bfs.js"
/* 层序遍历 */
function hierOrder(root) {
// 初始化队列,加入根结点
@@ -257,7 +257,7 @@ comments: true
=== "JavaScript"
```js title="binary_tree_dfs.js"
```javascript title="binary_tree_dfs.js"
/* 前序遍历 */
function preOrder(root){
if (root === null) return;