Example #1
0
int main()
{
    tree *T = NULL, *t;
    pair p;
    T = tinsert(T, 4); T = tinsert(T, 2); T = tinsert(T, 8);
    T = tinsert(T, 1); T = tinsert(T, 5); 
    //T = tinsert(T, 7);
    //tlevel(T);
    //tshow(T);
    //tdelete(T, 4);
    //tshow(T);
    tshow(T, mydump);
    p = is_balanced_binary_tree(T);
    printf("check balanced: %d, height: %d\n", p.balanced, p.height);
    return 0;
}
Example #2
0
int main()
{
    tree *T = NULL, *t;
    int p;
    T = tinsert(T, 4); T = tinsert(T, 2); T = tinsert(T, 8);
    T = tinsert(T, 1); T = tinsert(T, 5); 
    //T = tinsert(T, 7);
    //tlevel(T);
    //tshow(T);
    //tdelete(T, 4);
    //tshow(T);
    tshow(T, mydump);
    p = is_bst2(T);
    printf("is bst? %d\n", p);
    return 0;
}
Example #3
0
void	irctext::insert(const cstring &prompt, const cstring &msg, 
		        const int promptlen, const cstring &tagname)
/*
 * Insert the text nicely formatted
 */
{
	int	mode = 0;			// attribute mode

	enable();

	tinsert(mode, "\t" + prompt + "\t", tagname);
	tinsert(mode, msg, tagname + " " + "uitlijn");
	disable();
	if(scroll)
		evaluate("see end");
	tk->update();
}
Example #4
0
void	irctext::insert(const cstring &msg, const cstring &tagname)
{
	int	mode = 0;

	enable();
	tinsert(mode, msg, tagname);
	disable();
	if(scroll)
        	evaluate("see end");
        tk->update();
}
Example #5
0
void changraph(void)
{
#ifdef notdef
char filename[1024] ;
FILE *fp ;
#endif
int i , index1 , index2 , hiend , loend , length ;

vChanBeginRoot = (TNODEPTR) NULL ;
vChanEndRoot   = (TNODEPTR) NULL ;
hChanBeginRoot = (TNODEPTR) NULL ;
hChanEndRoot   = (TNODEPTR) NULL ;
eNum = 0 ;
eArray = (EBOXPTR) malloc( 100 * sizeof(EBOX) ) ;

/* XXX Ahh, Sechen code, lint torture testing */
/* exploreUp( HRlist , 0 , -1000000 ) ; */
exploreUp();

edgeTransition = eNum ;

/* exploreRite( VRlist , 0 , -1000000 ) ; */
exploreRite();

eIndexArray = (int **) malloc( (1 + numRects) * sizeof( int * ) ) ;
for( i = 1 ; i <= numRects ; i++ ) {
    eIndexArray[i] = (int *) malloc( (1 + numRects) * sizeof( int ) ) ;
}

#ifdef notdef
sprintf( filename, "%s.gph", cktName ) ;
fp = fopen( filename , "w" ) ;
#endif

for( i = 1 ; i <= eNum ; i++ ) {
    index1 = eArray[i].index1 ;
    index2 = eArray[i].index2 ;
    eIndexArray[index1][index2] = i ;
    eIndexArray[index2][index1] = i ;
    if( i <= edgeTransition ) {
	hiend = rectArray[index2].b ;
	loend = rectArray[index1].t ;
	length = rectArray[index2].yc - rectArray[index1].yc  ;
	tinsert( &vChanBeginRoot , eArray[i].lbside , i ) ;
	tinsert( &vChanEndRoot , eArray[i].rtside , i ) ;
    } else {
	hiend = rectArray[index2].l ;
	loend = rectArray[index1].r ;
	length = rectArray[index2].xc - rectArray[index1].xc  ;
	tinsert( &hChanBeginRoot , eArray[i].lbside , i ) ;
	tinsert( &hChanEndRoot , eArray[i].rtside , i ) ;
    }
    eArray[i].length = length ;
    eArray[i].hiend = hiend ;
    eArray[i].loend = loend ;
#ifdef notdef
    fprintf( fp, "edge %5d %5d   length %8d  capacity %8d\n",
		    index1 , index2 , length , eArray[i].width ) ;
#endif
}
#ifdef notdef
fclose(fp);
#endif

#ifdef DEBUG
fprintf(fpdebug,"CHANNEL-GRAPH NODES:\n");
for( i = 1 ; i <= numRects ; i++ ) {
    fprintf(fpdebug,"rect Node: %d  at: %d %d  width:%d  height:%d\n",
		i , rectArray[i].xc , rectArray[i].yc ,
		rectArray[i].r - rectArray[i].l ,
				rectArray[i].t - rectArray[i].b ) ;
}
#endif

return ;
}
Example #6
0
vprobes()
{

DLINK1PTR ritePtr , left1ptr , left2ptr , checkPtr , ptr ;
int ry , rx1 , rx2 , redge , dx1 , dx2 , ledge , edge , check ;
int l1x2 , l1x1 , l1y , l2x2 , l2x1 , l2y ;

ritePtr = hFixedListG ;
for( ; ritePtr != (DLINK1PTR) NULL ; ritePtr = ritePtr->next ) {
    redge = ritePtr->edge ;
    if( edgeListG[redge].UorR < 0 ) {
	continue ;
    }
    ry  = edgeListG[redge].loc   ;
    rx1 = edgeListG[redge].start ;
    rx2 = edgeListG[redge].end   ;
    
    left1ptr = HptrsG[ tprop( HrootG , ry ) ] ;
    for(; left1ptr != (DLINK1PTR)NULL; left1ptr = left1ptr->next){
	ledge = left1ptr->edge ;
	if( edgeListG[ledge].UorR > 0 ) {
	    continue ;
	}
	l1y  = edgeListG[ledge].loc   ;
	l1x1 = edgeListG[ledge].start ;
	l1x2 = edgeListG[ledge].end   ;
	if( l1x2 <= rx1 || l1x1 > rx1 ) {
	    continue ;
	}
	break ;
    }
    
    left2ptr = HptrsG[ tprop( HrootG , ry ) ] ;
    for(; left2ptr != (DLINK1PTR) NULL ; left2ptr = left2ptr->next){
	ledge = left2ptr->edge ;
	if( edgeListG[ledge].UorR > 0 ) {
	    continue ;
	}
	l2y  = edgeListG[ledge].loc   ;
	l2x1 = edgeListG[ledge].start ;
	l2x2 = edgeListG[ledge].end   ;
	if( l2x2 < rx2 || l2x1 >= rx2 ) {
	    continue ;
	}
	break ;
    }

    if( left1ptr != (DLINK1PTR) NULL && left1ptr == left2ptr ) {
	check = 1 ;
	checkPtr = HptrsG[ tprop( HrootG , ry ) ] ;
	for(; checkPtr != (DLINK1PTR)NULL; checkPtr = checkPtr->next){
	    if( edgeListG[ checkPtr->edge ].UorR > 0 ) {
		continue ;
	    }
	    if( edgeListG[ checkPtr->edge ].loc >= l2y ) {
		break ;
	    }
	    if( edgeListG[ checkPtr->edge ].start >= rx2 ||
			edgeListG[ checkPtr->edge ].end <= rx1 ) {
		continue ;
	    }
	    check = 0 ;
	    break ;
	}
	if( check ) {
	    edgeListG[++numProbesG + edgeCountG].start  = ry ;
	    edgeListG[numProbesG + edgeCountG].end      = l2y  ;
	    edgeListG[numProbesG + edgeCountG].loc      = rx1 ;
	    edgeListG[numProbesG + edgeCountG].length   = l2y - ry ;
	    edgeListG[numProbesG + edgeCountG].fixed    = 0 ;
	    edgeListG[numProbesG + edgeCountG].cell     = 0 ;
	    edgeListG[numProbesG + edgeCountG].UorR     = 1 ;
	    tinsert( &vEdgeRootG, rx1 , numProbesG + edgeCountG ) ;
#ifdef DEBUG
	    fprintf(fpdebugG,"vprobe:%d  ", numProbesG ) ;
	    fprintf(fpdebugG,"start:%d  end:%d  loc:%d  UorR:%d\n",
					ry , l2y , rx1 , 1 ) ;
#endif
	    edgeListG[++numProbesG + edgeCountG].start  = ry ;
	    edgeListG[numProbesG + edgeCountG].end      = l2y  ;
	    edgeListG[numProbesG + edgeCountG].loc      = rx2 ;
	    edgeListG[numProbesG + edgeCountG].length   = l2y - ry ;
	    edgeListG[numProbesG + edgeCountG].fixed    = 0 ;
	    edgeListG[numProbesG + edgeCountG].cell     = 0 ;
	    edgeListG[numProbesG + edgeCountG].UorR     = -1 ;
	    tinsert( &vEdgeRootG, rx2 , numProbesG + edgeCountG ) ;
#ifdef DEBUG
	    fprintf(fpdebugG,"vprobe:%d  ", numProbesG ) ;
	    fprintf(fpdebugG,"start:%d  end:%d  loc:%d  UorR:%d\n",
					ry , l2y , rx2 , -1 ) ;
#endif
	} else {
	    doubleDown( ritePtr ) ;	
	}
	continue ;
    }

    if( left1ptr != (DLINK1PTR) NULL ) {
	ptr = HptrsG[ tprop( HrootG , l1y ) ] ;
	for( ptr = ptr->next; ptr != (DLINK1PTR) NULL; ptr = ptr->next){
	    if( edgeListG[ptr->edge].loc > l1y ) {
		break ;
	    }
	}
	if( ptr == (DLINK1PTR) NULL ) {
	    ptr = hFixedEndG ;
	} else {
	    ptr = ptr->prev ;
	}
	for( ; ptr != (DLINK1PTR) NULL; ptr = ptr->prev){
	    edge = ptr->edge ;
	    if( edgeListG[edge].UorR < 0 ) {
		continue ;
	    }
	    dx1 = edgeListG[edge].start ;
	    dx2 = edgeListG[edge].end   ;
	    if( dx2 < l1x2 || dx1 >= l1x2 ) {
		continue ;
	    }
	    break ;
	}
	if( ritePtr == ptr ) {
	    check = 1 ;
	    checkPtr = HptrsG[ tprop( HrootG , ry ) ] ;
	    for(; checkPtr != (DLINK1PTR) NULL ;
				checkPtr = checkPtr->next ) {
		if( edgeListG[ checkPtr->edge ].UorR > 0 ) {
		    continue ;
		}
		if( edgeListG[ checkPtr->edge ].loc >= l1y ) {
		    break ;
		}
		if( edgeListG[ checkPtr->edge ].start >= l1x2 ||
			edgeListG[ checkPtr->edge ].end <= rx1 ) {
		    continue ;
		}
		check = 0 ;
		break ;
	    }
	    if( check ) {
		edgeListG[++numProbesG + edgeCountG].start  = ry ;
		edgeListG[numProbesG + edgeCountG].end      = l1y ;
		edgeListG[numProbesG + edgeCountG].loc      = rx1 ;
		edgeListG[numProbesG + edgeCountG].length   = l1y - ry ;
		edgeListG[numProbesG + edgeCountG].fixed    = 0 ;
		edgeListG[numProbesG + edgeCountG].cell     = 0 ;
		edgeListG[numProbesG + edgeCountG].UorR     = 1 ;
		tinsert( &vEdgeRootG, rx1 , numProbesG + edgeCountG ) ;
#ifdef DEBUG
		fprintf(fpdebugG,"vprobe:%d  ", numProbesG ) ;
		fprintf(fpdebugG,"start:%d  end:%d  loc:%d  UorR:%d\n",
					ry , l1y , rx1 , 1 ) ;
#endif
		edgeListG[++numProbesG + edgeCountG].start  = ry ;
		edgeListG[numProbesG + edgeCountG].end      = l1y  ;
		edgeListG[numProbesG + edgeCountG].loc      = l1x2 ;
		edgeListG[numProbesG + edgeCountG].length   = l1y - ry ;
		edgeListG[numProbesG + edgeCountG].fixed    = 0 ;
		edgeListG[numProbesG + edgeCountG].cell     = 0 ;
		edgeListG[numProbesG + edgeCountG].UorR     = -1 ;
		tinsert( &vEdgeRootG, l1x2 , numProbesG + edgeCountG ) ;
#ifdef DEBUG
		fprintf(fpdebugG,"vprobe:%d  ", numProbesG ) ;
		fprintf(fpdebugG,"start:%d  end:%d  loc:%d  UorR:%d\n",
					ry , l1y , l1x2 , -1 ) ;
#endif
	    }
	}
    }

    if( left2ptr != (DLINK1PTR) NULL ) {
	ptr = HptrsG[ tprop( HrootG , l2y ) ] ;
	for( ptr = ptr->next; ptr != (DLINK1PTR) NULL; ptr = ptr->next){
	    if( edgeListG[ptr->edge].loc > l2y ) {
		break ;
	    }
	}
	if( ptr == (DLINK1PTR) NULL ) {
	    ptr = hFixedEndG ;
	} else {
	    ptr = ptr->prev ;
	}
	for( ; ptr != (DLINK1PTR) NULL; ptr = ptr->prev){
	    edge = ptr->edge ;
	    if( edgeListG[edge].UorR < 0 ) {
		continue ;
	    }
	    dx1 = edgeListG[edge].start ;
	    dx2 = edgeListG[edge].end   ;
	    if( dx2 <= l2x1 || dx1 > l2x1 ) {
		continue ;
	    }
	    break ;
	}
	if( ritePtr == ptr ) {
	    check = 1 ;
	    checkPtr = HptrsG[ tprop( HrootG , ry ) ] ;
	    for(; checkPtr != (DLINK1PTR) NULL ;
				    checkPtr = checkPtr->next ) {
		if( edgeListG[ checkPtr->edge ].UorR > 0 ) {
		    continue ;
		}
		if( edgeListG[ checkPtr->edge ].loc >= l2y ) {
		    break ;
		}
		if( edgeListG[ checkPtr->edge ].start >= rx2 ||
			edgeListG[ checkPtr->edge ].end <= l2x1 ) {
		    continue ;
		}
		check = 0 ;
		break ;
	    }
	    if( check ) {
		edgeListG[++numProbesG + edgeCountG].start  = ry ;
		edgeListG[numProbesG + edgeCountG].end      = l2y ;
		edgeListG[numProbesG + edgeCountG].loc      = l2x1 ;
		edgeListG[numProbesG + edgeCountG].length   = l2y - ry ;
		edgeListG[numProbesG + edgeCountG].fixed    = 0 ;
		edgeListG[numProbesG + edgeCountG].cell     = 0 ;
		edgeListG[numProbesG + edgeCountG].UorR     = 1 ;
		tinsert( &vEdgeRootG, l2x1 , numProbesG + edgeCountG ) ;
#ifdef DEBUG
		fprintf(fpdebugG,"vprobe:%d  ", numProbesG ) ;
		fprintf(fpdebugG,"start:%d  end:%d  loc:%d  UorR:%d\n",
					ry , l2y , l2x1 , 1 ) ;
#endif
		edgeListG[++numProbesG + edgeCountG].start  = ry ;
		edgeListG[numProbesG + edgeCountG].end      = l2y  ;
		edgeListG[numProbesG + edgeCountG].loc      = rx2 ;
		edgeListG[numProbesG + edgeCountG].length   = l2y - ry ;
		edgeListG[numProbesG + edgeCountG].fixed    = 0 ;
		edgeListG[numProbesG + edgeCountG].cell     = 0 ;
		edgeListG[numProbesG + edgeCountG].UorR     = -1 ;
		tinsert( &vEdgeRootG, rx2 , numProbesG + edgeCountG ) ;
#ifdef DEBUG
		fprintf(fpdebugG,"vprobe:%d  ", numProbesG ) ;
		fprintf(fpdebugG,"start:%d  end:%d  loc:%d  UorR:%d\n",
					ry , l2y , rx2 , -1 ) ;
#endif
	    }
	}
    }
    doubleDown( ritePtr ) ;
}
return ;
}