if i know what numbers i want to put in the tree what should i think for succeeding my goal? or i have to randomly try combinations?
Type: Posts; User: cable
if i know what numbers i want to put in the tree what should i think for succeeding my goal? or i have to randomly try combinations?
lets say i have some int values
for example 1;2;4;7;8
which one is the best way to determine in what order should i insert the int numbers in the 2-3 tree for having the fewer possible nodes
int Depth(NODE *base)
{
if (base==NULL) {
return(0);
}
else {
int ltree = Depth(base->left);
int rtree= Depth(base->right);
if (ltree > rtree) return(ltree+1);
else...
so if i still want to keep the pointer of string how can i solve the problem
i mean with minimum changes
fopen is succeed even if i put fclose still the same problem
also c is a pointer of string so like i know it can still point to string even if i do not malloc
#include <stdio.h>
#include <stdlib.h>
int getsize(void){
int counter=0;
FILE *testa;
testa=fopen("error.txt","r");
char *c;
while(fscanf(testa,"%s",c)!=EOF) counter++;
printf("%s",c);
thanks for the replies but i still have not find how to solve this problem
any other please?
hello i have to make one program which fscanf info from a txt file
each line has this type of info which i have to save the 3 int numbers
3=3,3
so i get the numbers with this example...
thanks for the reply
i have written the function which always saves the current numbers which are not the same but i cannot find how can i save the first numbers which are not the same as the...
lets say you keep reading two int numbers every round
you save the first int numbers which they are not same and the last two numbers which they are not
so if you read this
2, 3
4,5
5,6
7,7...
whats the best way for comparing 2 string to check if they are equal
i know that 1 ways is with strcmp(string1,string2) but i want to compare them, first with upper and lower letters make them...
hello i have two strings in each line always the second is number ,and first is a word (both of them in a file)
for example
tri 123
t 352
vf 333
the important is that spaces have not always...
hello i have this function
void learn_size(int *size,char *point)
which finds the *size from a txt file
then im declaring a function like this
void read(int xarray[*size][*size])
as im not...
compile this and tell me if its correct
what i changed is listed at my previous post
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
using...
what error appears , compile error or logical
i have compiled the next code and i think it works
if the problem does not have to do with compile then please tell us what make you think its wrong...
what is the meaning of PRIVATE members
i think one of their purpose is to protect us from wrongly changing them, am i right?
what i know until now is that we can overload << >> + - ++ ..
but i cannot understand when we declare the operator we put this & before the variable also sometimes we write 2 variables in operator...
can you please give an code example of how to not define the struct constructor in source file ?
if the define its the problem can you give me an exampe of how to not define the constructor and only...
im sorry but im not allowed to change the header file
comes with this homework and am not allowed to change it
is there any other way which i can do in cpp file?
sorry if i did not make a question
what im trying to do is to make a constructor in cpp file for struct node in header file
and the error is redefinition at the line which i write the struct...
header file
struct node {
int x;
node *next;
node(y, node *next)
: x(y), next(next) {}
};
lets say i have a linked list with only one value at head
if i say
node *head=(first input)
*pointerb=head;
pointer->next=(new input)
then if i say
lets say i have a long type variable
for example
long x =43343539839853583;
im looking for the best algorithm to put 111 for example at the left of the number(
final result...
#include <stdlib.h>
#include <stdio.h>
int main(){
long x;
scanf("%ld",&x);
if(!isdigit(x))
printf("error");
return 0;
}
start_node its the node which search should be start for deleting nodes(if you don't find meaning with it, me either but i have to use it
node_t * locate_node(list_t * l, node_t *start_node, int...