⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 breadth.c

📁 C和指针非常好的一本书.里面的有许多代码可以借鉴.
💻 C
字号:
/*
** Do a breadth_first_traversal of an arrayed binary search tree.
*/
void
breadth_first_traversal( void (*callback)( TREE_TYPE value ) )
{
	int	current;
	int	child;

	/*
	** Insert the root node into the queue.
	*/
	queue_insert( 1 );

	/*
	** While the queue is not empty...
	*/
	while( !is_queue_empty() ){
		/*
		** Take the first value off the queue and process it
		*/
		current = queue_first();
		queue_delete();
		callback( tree[ current ] );

		/*
		** Add the children of the node to the queue.
		*/
		child = left_child( current );
		if( child < ARRAY_SIZE && tree[ child ] != 0 )
			queue_insert( child );
		child = left_child( current );
		if( child < ARRAY_SIZE && tree[ child ] != 0 )
			queue_insert( child );
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -