IT. Expert System.

C

tree


Tree is collection of node also called disjoint graph in which there is a single root node.

Syntax:
Syntax doesn't exist.


Example:

#include
#include
#include
struct tree
{
int data;
struct tree *left,*right;
};

void init(struct tree *node)
{
node = malloc(sizeof node);
if(!node)
{
printf("mem error\n");
exit(EXIT_FAILURE);
}
}

struct tree *assign(int data,struct tree *node)
{
struct tree *temp;
memmove(temp,node,sizeof node);
init(temp);
temp->data = data;
if(data < temp->data)
{
temp = temp->left;
temp->data = data;
}
else if(data > temp->data)
{
temp = temp->right;
temp->data = data;
}
else
temp->right = temp->left = NULL;
memmove(node,temp,sizeof node);
return node;
}

int print_tree(struct tree *node)
{
printf("%d\n",node->data);
while(node != NULL)
{
struct tree *temp;
memmove(temp,node,sizeof node);
temp = temp -> right;
print_tree(temp);
temp = temp-> left;
memmove(node,temp,sizeof node);
}
return 0;
}

int main(void)
{
struct tree *node;
node = assign(1 , node);
node = assign(2 , node);
node = assign(8 , node);
print_tree(node);
return 0;
}


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 7 / 158748719. Delta: 0.00323 с