热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

java树插入root_[Java]AVL树插入:单旋、双旋

目录代码出处各种实现概念说明算法说明测试运行代码修改完整源码代码出处各种实现Java实现C11DataStructuresandAlgorithmAnalysisinC(Fourt

目录

代码出处

各种实现

概念说明

算法说明

测试运行

代码修改

完整源码

代码出处

各种实现

Java实现

C++11

Data Structures and Algorithm Analysis in C++ (Fourth Edition)

CS-7 Text

https://users.cs.fiu.edu/~weiss/dsaa_c++4/code/

g++ -std=c++0x TestAvlTree.cpp

g++ -std=c++0x TestIntCell.cpp IntCell.cpp

C

概念说明

AVL树

https://en.wikipedia.org/wiki/AVL_tree

In an AVL tree, the heights of the two child subtrees of any node differ by at most one

在AVL树种,任意两棵子树的高度不能超过1;

路径 path 、长度 length、 高度height 与 深度depth

The root node has depth zero, leaf nodes have height zero.

根结点的深度是0,叶子结点的高度是0;

t.insert( nodes[i] );

t.preorder();

}

}

新增preorder()相关:前序序列输出AVL树,带空格表示层次结构

/**

* Print the tree contents in preorder.

*/

public void preorder()

{

if( isEmpty() )

System.out.println( "Empty tree" );

else

preorder( root , 0 );

System.out.println();

}

/**

* Internal method to print a subtree in preorder.

* @param t the node that roots the tree.

*/

private void preorder( AvlNode t, int blanks)

{

if( t != null )

{

System.out.println();

for(int i = 0 ;i

System.out.print(" ");

System.out.print( t.element );

preorder( t.left, blanks+1 );

preorder( t.right, blanks+1 );

}

}

完整源码 AvlTree.java

// AvlTree class

//

// CONSTRUCTION: with no initializer

//

// ******************PUBLIC OPERATIONS*********************

// void insert( x ) --> Insert x

// void remove( x ) --> Remove x (unimplemented)

// boolean contains( x ) --> Return true if x is present

// boolean remove( x ) --> Return true if x was present

// Comparable findMin( ) --> Return smallest item

// Comparable findMax( ) --> Return largest item

// boolean isEmpty( ) --> Return true if empty; else false

// void makeEmpty( ) --> Remove all items

// void printTree( ) --> Print tree in sorted order

// ******************ERRORS********************************

// Throws UnderflowException as appropriate

/**

* Implements an AVL tree.

* Note that all "matching" is based on the compareTo method.

* @author Mark Allen Weiss

*/

public class AvlTree>

{

/**

* Construct the tree.

*/

public AvlTree( )

{

root = null;

}

/**

* Insert into the tree; duplicates are ignored.

* @param x the item to insert.

*/

public void insert( AnyType x )

{

root = insert( x, root );

}

/**

* Remove from the tree. Nothing is done if x is not found.

* @param x the item to remove.

*/

public void remove( AnyType x )

{

root = remove( x, root );

}

/**

* Internal method to remove from a subtree.

* @param x the item to remove.

* @param t the node that roots the subtree.

* @return the new root of the subtree.

*/

private AvlNode remove( AnyType x, AvlNode t )

{

if( t == null )

return t; // Item not found; do nothing

int compareResult = x.compareTo( t.element );

if( compareResult <0 )

t.left &#61; remove( x, t.left );

else if( compareResult > 0 )

t.right &#61; remove( x, t.right );

else if( t.left !&#61; null && t.right !&#61; null ) // Two children

{

t.element &#61; findMin( t.right ).element;

t.right &#61; remove( t.element, t.right );

}

else

t &#61; ( t.left !&#61; null ) ? t.left : t.right;

return balance( t );

}

/**

* Find the smallest item in the tree.

* &#64;return smallest item or null if empty.

*/

public AnyType findMin( )

{

if( isEmpty( ) )

throw new UnderflowException( );

return findMin( root ).element;

}

/**

* Find the largest item in the tree.

* &#64;return the largest item of null if empty.

*/

public AnyType findMax( )

{

if( isEmpty( ) )

throw new UnderflowException( );

return findMax( root ).element;

}

/**

* Find an item in the tree.

* &#64;param x the item to search for.

* &#64;return true if x is found.

*/

public boolean contains( AnyType x )

{

return contains( x, root );

}

/**

* Make the tree logically empty.

*/

public void makeEmpty( )

{

root &#61; null;

}

/**

* Test if the tree is logically empty.

* &#64;return true if empty, false otherwise.

*/

public boolean isEmpty( )

{

return root &#61;&#61; null;

}

/**

* Print the tree contents in sorted order.

*/

public void printTree( )

{

if( isEmpty( ) )

System.out.println( "Empty tree" );

else

printTree( root );

}

/**

* Print the tree contents in preorder.

*/

public void preorder()

{

if( isEmpty() )

System.out.println( "Empty tree" );

else

preorder( root , 0 );

System.out.println();

}

private static final int ALLOWED_IMBALANCE &#61; 1;

// Assume t is either balanced or within one of being balanced

private AvlNode balance( AvlNode t )

{

if( t &#61;&#61; null )

return t;

if( height( t.left ) - height( t.right ) > ALLOWED_IMBALANCE )

if( height( t.left.left ) >&#61; height( t.left.right ) )

t &#61; rotateWithLeftChild( t );

else

t &#61; doubleWithLeftChild( t );

else

if( height( t.right ) - height( t.left ) > ALLOWED_IMBALANCE )

if( height( t.right.right ) >&#61; height( t.right.left ) )

t &#61; rotateWithRightChild( t );

else

t &#61; doubleWithRightChild( t );

t.height &#61; Math.max( height( t.left ), height( t.right ) ) &#43; 1;

return t;

}

public void checkBalance( )

{

checkBalance( root );

}

private int checkBalance( AvlNode t )

{

if( t &#61;&#61; null )

return -1;

if( t !&#61; null )

{

int hl &#61; checkBalance( t.left );

int hr &#61; checkBalance( t.right );

if( Math.abs( height( t.left ) - height( t.right ) ) > 1 ||

height( t.left ) !&#61; hl || height( t.right ) !&#61; hr )

System.out.println( "OOPS!!" );

}

return height( t );

}

/**

* Internal method to insert into a subtree.

* &#64;param x the item to insert.

* &#64;param t the node that roots the subtree.

* &#64;return the new root of the subtree.

*/

private AvlNode insert( AnyType x, AvlNode t )

{

if( t &#61;&#61; null )

return new AvlNode<>( x, null, null );

int compareResult &#61; x.compareTo( t.element );

if( compareResult <0 )

t.left &#61; insert( x, t.left );

else if( compareResult > 0 )

t.right &#61; insert( x, t.right );

else

; // Duplicate; do nothing

return balance( t );

}

/**

* Internal method to find the smallest item in a subtree.

* &#64;param t the node that roots the tree.

* &#64;return node containing the smallest item.

*/

private AvlNode findMin( AvlNode t )

{

if( t &#61;&#61; null )

return t;

while( t.left !&#61; null )

t &#61; t.left;

return t;

}

/**

* Internal method to find the largest item in a subtree.

* &#64;param t the node that roots the tree.

* &#64;return node containing the largest item.

*/

private AvlNode findMax( AvlNode t )

{

if( t &#61;&#61; null )

return t;

while( t.right !&#61; null )

t &#61; t.right;

return t;

}

/**

* Internal method to find an item in a subtree.

* &#64;param x is item to search for.

* &#64;param t the node that roots the tree.

* &#64;return true if x is found in subtree.

*/

private boolean contains( AnyType x, AvlNode t )

{

while( t !&#61; null )

{

int compareResult &#61; x.compareTo( t.element );

if( compareResult <0 )

t &#61; t.left;

else if( compareResult > 0 )

t &#61; t.right;

else

return true; // Match

}

return false; // No match

}

/**

* Internal method to print a subtree in sorted order.

* &#64;param t the node that roots the tree.

*/

private void printTree( AvlNode t )

{

if( t !&#61; null )

{

printTree( t.left );

System.out.println( t.element );

printTree( t.right );

}

}

/**

* Internal method to print a subtree in preorder.

* &#64;param t the node that roots the tree.

*/

private void preorder( AvlNode t, int blanks)

{

if( t !&#61; null )

{

System.out.println();

for(int i &#61; 0 ;i

System.out.print(" ");

System.out.print( t.element );

preorder( t.left, blanks&#43;1 );

preorder( t.right, blanks&#43;1 );

}

}

/**

* Return the height of node t, or -1, if null.

*/

private int height( AvlNode t )

{

return t &#61;&#61; null ? -1 : t.height;

}

/**

* Rotate binary tree node with left child.

* For AVL trees, this is a single rotation for case 1.

* Update heights, then return new root.

*/

private AvlNode rotateWithLeftChild( AvlNode k2 )

{

AvlNode k1 &#61; k2.left;

k2.left &#61; k1.right;

k1.right &#61; k2;

k2.height &#61; Math.max( height( k2.left ), height( k2.right ) ) &#43; 1;

k1.height &#61; Math.max( height( k1.left ), k2.height ) &#43; 1;

return k1;

}

/**

* Rotate binary tree node with right child.

* For AVL trees, this is a single rotation for case 4.

* Update heights, then return new root.

*/

private AvlNode rotateWithRightChild( AvlNode k1 )

{

AvlNode k2 &#61; k1.right;

k1.right &#61; k2.left;

k2.left &#61; k1;

k1.height &#61; Math.max( height( k1.left ), height( k1.right ) ) &#43; 1;

k2.height &#61; Math.max( height( k2.right ), k1.height ) &#43; 1;

return k2;

}

/**

* Double rotate binary tree node: first left child

* with its right child; then node k3 with new left child.

* For AVL trees, this is a double rotation for case 2.

* Update heights, then return new root.

*/

private AvlNode doubleWithLeftChild( AvlNode k3 )

{

k3.left &#61; rotateWithRightChild( k3.left );

return rotateWithLeftChild( k3 );

}

/**

* Double rotate binary tree node: first right child

* with its left child; then node k1 with new right child.

* For AVL trees, this is a double rotation for case 3.

* Update heights, then return new root.

*/

private AvlNode doubleWithRightChild( AvlNode k1 )

{

k1.right &#61; rotateWithLeftChild( k1.right );

return rotateWithRightChild( k1 );

}

private static class AvlNode

{

// Constructors

AvlNode( AnyType theElement )

{

this( theElement, null, null );

}

AvlNode( AnyType theElement, AvlNode lt, AvlNode rt )

{

element &#61; theElement;

left &#61; lt;

right &#61; rt;

height &#61; 0;

}

AnyType element; // The data in the node

AvlNode left; // Left child

AvlNode right; // Right child

int height; // Height

}

/** The tree root. */

private AvlNode root;

// Test program

public static void main( String [ ] args )

{

AvlTree t &#61; new AvlTree<>( );

int[] nodes &#61; {3,2,1,4,5,6,7,16,15,14,13,12,11,10,8,9};

for( int i &#61; 0; i

{

System.out.println( "INSERT: " &#43; nodes[i] );

t.insert( nodes[i] );

t.preorder();

}

}

}

完整源码 TestAvlTree.cpp

#ifndef AVL_TREE_H

#define AVL_TREE_H

#include "dsexceptions.h"

#include

#include

using namespace std;

// AvlTree class

//

// CONSTRUCTION: zero parameter

//

// ******************PUBLIC OPERATIONS*********************

// void insert( x ) --> Insert x

// void remove( x ) --> Remove x (unimplemented)

// bool contains( x ) --> Return true if x is present

// Comparable findMin( ) --> Return smallest item

// Comparable findMax( ) --> Return largest item

// boolean isEmpty( ) --> Return true if empty; else false

// void makeEmpty( ) --> Remove all items

// void printTree( ) --> Print tree in sorted order

// ******************ERRORS********************************

// Throws UnderflowException as warranted

template

class AvlTree

{

public:

AvlTree( ) : root{ nullptr }

{ }

AvlTree( const AvlTree & rhs ) : root{ nullptr }

{

root &#61; clone( rhs.root );

}

AvlTree( AvlTree && rhs ) : root{ rhs.root }

{

rhs.root &#61; nullptr;

}

~AvlTree( )

{

makeEmpty( );

}

/**

* Deep copy.

*/

AvlTree & operator&#61;( const AvlTree & rhs )

{

AvlTree copy &#61; rhs;

std::swap( *this, copy );

return *this;

}

/**

* Move.

*/

AvlTree & operator&#61;( AvlTree && rhs )

{

std::swap( root, rhs.root );

return *this;

}

/**

* Find the smallest item in the tree.

* Throw UnderflowException if empty.

*/

const Comparable & findMin( ) const

{

if( isEmpty( ) )

throw UnderflowException{ };

return findMin( root )->element;

}

/**

* Find the largest item in the tree.

* Throw UnderflowException if empty.

*/

const Comparable & findMax( ) const

{

if( isEmpty( ) )

throw UnderflowException{ };

return findMax( root )->element;

}

/**

* Returns true if x is found in the tree.

*/

bool contains( const Comparable & x ) const

{

return contains( x, root );

}

/**

* Test if the tree is logically empty.

* Return true if empty, false otherwise.

*/

bool isEmpty( ) const

{

return root &#61;&#61; nullptr;

}

/**

* Print the tree contents in sorted order.

*/

void printTree( ) const

{

if( isEmpty( ) )

cout <<"Empty tree" <

else

printTree( root );

}

/**

* Make the tree logically empty.

*/

void makeEmpty( )

{

makeEmpty( root );

}

/**

* Insert x into the tree; duplicates are ignored.

*/

void insert( const Comparable & x )

{

insert( x, root );

}

/**

* Insert x into the tree; duplicates are ignored.

*/

void insert( Comparable && x )

{

insert( std::move( x ), root );

}

/**

* Remove x from the tree. Nothing is done if x is not found.

*/

void remove( const Comparable & x )

{

remove( x, root );

}

private:

struct AvlNode

{

Comparable element;

AvlNode *left;

AvlNode *right;

int height;

AvlNode( const Comparable & ele, AvlNode *lt, AvlNode *rt, int h &#61; 0 )

: element{ ele }, left{ lt }, right{ rt }, height{ h } { }

AvlNode( Comparable && ele, AvlNode *lt, AvlNode *rt, int h &#61; 0 )

: element{ std::move( ele ) }, left{ lt }, right{ rt }, height{ h } { }

};

AvlNode *root;

/**

* Internal method to insert into a subtree.

* x is the item to insert.

* t is the node that roots the subtree.

* Set the new root of the subtree.

*/

void insert( const Comparable & x, AvlNode * & t )

{

if( t &#61;&#61; nullptr )

t &#61; new AvlNode{ x, nullptr, nullptr };

else if( x element )

insert( x, t->left );

else if( t->element

insert( x, t->right );

balance( t );

}

/**

* Internal method to insert into a subtree.

* x is the item to insert.

* t is the node that roots the subtree.

* Set the new root of the subtree.

*/

void insert( Comparable && x, AvlNode * & t )

{

if( t &#61;&#61; nullptr )

t &#61; new AvlNode{ std::move( x ), nullptr, nullptr };

else if( x element )

insert( std::move( x ), t->left );

else if( t->element

insert( std::move( x ), t->right );

balance( t );

}

/**

* Internal method to remove from a subtree.

* x is the item to remove.

* t is the node that roots the subtree.

* Set the new root of the subtree.

*/

void remove( const Comparable & x, AvlNode * & t )

{

if( t &#61;&#61; nullptr )

return; // Item not found; do nothing

if( x element )

remove( x, t->left );

else if( t->element

remove( x, t->right );

else if( t->left !&#61; nullptr && t->right !&#61; nullptr ) // Two children

{

t->element &#61; findMin( t->right )->element;

remove( t->element, t->right );

}

else

{

AvlNode *oldNode &#61; t;

t &#61; ( t->left !&#61; nullptr ) ? t->left : t->right;

delete oldNode;

}

balance( t );

}

static const int ALLOWED_IMBALANCE &#61; 1;

// Assume t is balanced or within one of being balanced

void balance( AvlNode * & t )

{

if( t &#61;&#61; nullptr )

return;

if( height( t->left ) - height( t->right ) > ALLOWED_IMBALANCE )

if( height( t->left->left ) >&#61; height( t->left->right ) )

rotateWithLeftChild( t );

else

doubleWithLeftChild( t );

else

if( height( t->right ) - height( t->left ) > ALLOWED_IMBALANCE )

if( height( t->right->right ) >&#61; height( t->right->left ) )

rotateWithRightChild( t );

else

doubleWithRightChild( t );

t->height &#61; max( height( t->left ), height( t->right ) ) &#43; 1;

}

/**

* Internal method to find the smallest item in a subtree t.

* Return node containing the smallest item.

*/

AvlNode * findMin( AvlNode *t ) const

{

if( t &#61;&#61; nullptr )

return nullptr;

if( t->left &#61;&#61; nullptr )

return t;

return findMin( t->left );

}

/**

* Internal method to find the largest item in a subtree t.

* Return node containing the largest item.

*/

AvlNode * findMax( AvlNode *t ) const

{

if( t !&#61; nullptr )

while( t->right !&#61; nullptr )

t &#61; t->right;

return t;

}

/**

* Internal method to test if an item is in a subtree.

* x is item to search for.

* t is the node that roots the tree.

*/

bool contains( const Comparable & x, AvlNode *t ) const

{

if( t &#61;&#61; nullptr )

return false;

else if( x element )

return contains( x, t->left );

else if( t->element

return contains( x, t->right );

else

return true; // Match

}

/****** NONRECURSIVE VERSION*************************

bool contains( const Comparable & x, AvlNode *t ) const

{

while( t !&#61; nullptr )

if( x element )

t &#61; t->left;

else if( t->element

t &#61; t->right;

else

return true; // Match

return false; // No match

}

*****************************************************/

/**

* Internal method to make subtree empty.

*/

void makeEmpty( AvlNode * & t )

{

if( t !&#61; nullptr )

{

makeEmpty( t->left );

makeEmpty( t->right );

delete t;

}

t &#61; nullptr;

}

/**

* Internal method to print a subtree rooted at t in sorted order.

*/

void printTree( AvlNode *t ) const

{

if( t !&#61; nullptr )

{

printTree( t->left );

cout <element <

printTree( t->right );

}

}

/**

* Internal method to clone subtree.

*/

AvlNode * clone( AvlNode *t ) const

{

if( t &#61;&#61; nullptr )

return nullptr;

else

return new AvlNode{ t->element, clone( t->left ), clone( t->right ), t->height };

}

// Avl manipulations

/**

* Return the height of node t or -1 if nullptr.

*/

int height( AvlNode *t ) const

{

return t &#61;&#61; nullptr ? -1 : t->height;

}

int max( int lhs, int rhs ) const

{

return lhs > rhs ? lhs : rhs;

}

/**

* Rotate binary tree node with left child.

* For AVL trees, this is a single rotation for case 1.

* Update heights, then set new root.

*/

void rotateWithLeftChild( AvlNode * & k2 )

{

AvlNode *k1 &#61; k2->left;

k2->left &#61; k1->right;

k1->right &#61; k2;

k2->height &#61; max( height( k2->left ), height( k2->right ) ) &#43; 1;

k1->height &#61; max( height( k1->left ), k2->height ) &#43; 1;

k2 &#61; k1;

}

/**

* Rotate binary tree node with right child.

* For AVL trees, this is a single rotation for case 4.

* Update heights, then set new root.

*/

void rotateWithRightChild( AvlNode * & k1 )

{

AvlNode *k2 &#61; k1->right;

k1->right &#61; k2->left;

k2->left &#61; k1;

k1->height &#61; max( height( k1->left ), height( k1->right ) ) &#43; 1;

k2->height &#61; max( height( k2->right ), k1->height ) &#43; 1;

k1 &#61; k2;

}

/**

* Double rotate binary tree node: first left child.

* with its right child; then node k3 with new left child.

* For AVL trees, this is a double rotation for case 2.

* Update heights, then set new root.

*/

void doubleWithLeftChild( AvlNode * & k3 )

{

rotateWithRightChild( k3->left );

rotateWithLeftChild( k3 );

}

/**

* Double rotate binary tree node: first right child.

* with its left child; then node k1 with new right child.

* For AVL trees, this is a double rotation for case 3.

* Update heights, then set new root.

*/

void doubleWithRightChild( AvlNode * & k1 )

{

rotateWithLeftChild( k1->right );

rotateWithRightChild( k1 );

}

};

#endif



推荐阅读
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 云原生边缘计算之KubeEdge简介及功能特点
    本文介绍了云原生边缘计算中的KubeEdge系统,该系统是一个开源系统,用于将容器化应用程序编排功能扩展到Edge的主机。它基于Kubernetes构建,并为网络应用程序提供基础架构支持。同时,KubeEdge具有离线模式、基于Kubernetes的节点、群集、应用程序和设备管理、资源优化等特点。此外,KubeEdge还支持跨平台工作,在私有、公共和混合云中都可以运行。同时,KubeEdge还提供数据管理和数据分析管道引擎的支持。最后,本文还介绍了KubeEdge系统生成证书的方法。 ... [详细]
  • 本文主要解析了Open judge C16H问题中涉及到的Magical Balls的快速幂和逆元算法,并给出了问题的解析和解决方法。详细介绍了问题的背景和规则,并给出了相应的算法解析和实现步骤。通过本文的解析,读者可以更好地理解和解决Open judge C16H问题中的Magical Balls部分。 ... [详细]
  • XML介绍与使用的概述及标签规则
    本文介绍了XML的基本概念和用途,包括XML的可扩展性和标签的自定义特性。同时还详细解释了XML标签的规则,包括标签的尖括号和合法标识符的组成,标签必须成对出现的原则以及特殊标签的使用方法。通过本文的阅读,读者可以对XML的基本知识有一个全面的了解。 ... [详细]
  • 本文介绍了一个在线急等问题解决方法,即如何统计数据库中某个字段下的所有数据,并将结果显示在文本框里。作者提到了自己是一个菜鸟,希望能够得到帮助。作者使用的是ACCESS数据库,并且给出了一个例子,希望得到的结果是560。作者还提到自己已经尝试了使用"select sum(字段2) from 表名"的语句,得到的结果是650,但不知道如何得到560。希望能够得到解决方案。 ... [详细]
  • Go GUIlxn/walk 学习3.菜单栏和工具栏的具体实现
    本文介绍了使用Go语言的GUI库lxn/walk实现菜单栏和工具栏的具体方法,包括消息窗口的产生、文件放置动作响应和提示框的应用。部分代码来自上一篇博客和lxn/walk官方示例。文章提供了学习GUI开发的实际案例和代码示例。 ... [详细]
  • 本文介绍了Codeforces Round #321 (Div. 2)比赛中的问题Kefa and Dishes,通过状压和spfa算法解决了这个问题。给定一个有向图,求在不超过m步的情况下,能获得的最大权值和。点不能重复走。文章详细介绍了问题的题意、解题思路和代码实现。 ... [详细]
  • 微软头条实习生分享深度学习自学指南
    本文介绍了一位微软头条实习生自学深度学习的经验分享,包括学习资源推荐、重要基础知识的学习要点等。作者强调了学好Python和数学基础的重要性,并提供了一些建议。 ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • 李逍遥寻找仙药的迷阵之旅
    本文讲述了少年李逍遥为了救治婶婶的病情,前往仙灵岛寻找仙药的故事。他需要穿越一个由M×N个方格组成的迷阵,有些方格内有怪物,有些方格是安全的。李逍遥需要避开有怪物的方格,并经过最少的方格,找到仙药。在寻找的过程中,他还会遇到神秘人物。本文提供了一个迷阵样例及李逍遥找到仙药的路线。 ... [详细]
  • 先看官方文档TheJavaTutorialshavebeenwrittenforJDK8.Examplesandpracticesdescribedinthispagedontta ... [详细]
  • JDK源码学习之HashTable(附带面试题)的学习笔记
    本文介绍了JDK源码学习之HashTable(附带面试题)的学习笔记,包括HashTable的定义、数据类型、与HashMap的关系和区别。文章提供了干货,并附带了其他相关主题的学习笔记。 ... [详细]
  • 海马s5近光灯能否直接更换为H7?
    本文主要介绍了海马s5车型的近光灯是否可以直接更换为H7灯泡,并提供了完整的教程下载地址。此外,还详细讲解了DSP功能函数中的数据拷贝、数据填充和浮点数转换为定点数的相关内容。 ... [详细]
  • 设计模式——模板方法模式的应用和优缺点
    本文介绍了设计模式中的模板方法模式,包括其定义、应用、优点、缺点和使用场景。模板方法模式是一种基于继承的代码复用技术,通过将复杂流程的实现步骤封装在基本方法中,并在抽象父类中定义模板方法的执行次序,子类可以覆盖某些步骤,实现相同的算法框架的不同功能。该模式在软件开发中具有广泛的应用价值。 ... [详细]
  • 本文介绍了Python语言程序设计中文件和数据格式化的操作,包括使用np.savetext保存文本文件,对文本文件和二进制文件进行统一的操作步骤,以及使用Numpy模块进行数据可视化编程的指南。同时还提供了一些关于Python的测试题。 ... [详细]
author-avatar
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有