https://aml3.github.io/RustTutorial/html/02.html#Starting_to_Corrode:%3Cbr%3EPointers,_Memory,_Strings,_and_I/O
I am really scared of pointers in C programming itself.. Rust have more features than C for pointers .. :-)
But this really good read the above link on Rust memory management. I believe that there are lot of values for learning these new features .
Friday, June 24, 2016
Rust vs C program speed
I was just going through some of the Rust programs and tutorials...
This is one of the site which benchmark programing language speed. Rust programming language doesn't compromise the speed
http://benchmarksgame.alioth.debian.org/u64q/rust.html
http://benchmarksgame.alioth.debian.org/why-measure-toy-benchmark-programs.html
If you are really looking for some Rust applications , here you can browse.
http://pcwalton.github.io/blog/2013/05/20/safe-manual-memory-management/
This is one good link for those who want to start with Rust - https://aml3.github.io/RustTutorial/
This is one of the site which benchmark programing language speed. Rust programming language doesn't compromise the speed
http://benchmarksgame.alioth.debian.org/u64q/rust.html
http://benchmarksgame.alioth.debian.org/why-measure-toy-benchmark-programs.html
If you are really looking for some Rust applications , here you can browse.
http://pcwalton.github.io/blog/2013/05/20/safe-manual-memory-management/
This is one good link for those who want to start with Rust - https://aml3.github.io/RustTutorial/
Wednesday, June 15, 2016
Search a Tree - C program
Computer is a robot , our program should identify the repetitive task and make computer do that repetitive task with less lines of code.... programmer should be able to identify the repetitive task and apply recursive functions..
Search a value in a Tree - C program
the beauty of this code is that searching the tree (function:searchtree ) is going to be the one function.But we will make the computer to do the same task repetitively just passing the next node.
#include
#include
struct node {
int a;
struct node* left;
struct node* right;
};
struct node* insert_node(int a){
struct node* newnode;
newnode = (struct node*) malloc (sizeof(struct node));
newnode->a = a;
newnode->left = NULL;
newnode->right = NULL;
return newnode;
}
int searchtree(struct node* root,int num){
if(root == NULL)
return 0;
if(root->a == num ||searchtree(root->left,num))
return 1;
if(root->a == num || searchtree(root->right,num)){
return 1;
}
}
int main(){
int num;
struct node* root;
root = insert_node(1);
root->left = insert_node(2);
root->right = insert_node(3);
root->right->right = insert_node(4);
root->right->left = insert_node(5);
root->left->left = insert_node(6);
root->left->right = insert_node(7);
root->left->right->left = insert_node(8);
printf("type a number:");
scanf("%d",&num);
if(searchtree(root,num)){
printf("number found in tree");
}
else{
printf("number not found in tree");
};
return(0);
}
Search a value in a Tree - C program
the beauty of this code is that searching the tree (function:searchtree ) is going to be the one function.But we will make the computer to do the same task repetitively just passing the next node.
#include
#include
struct node {
int a;
struct node* left;
struct node* right;
};
struct node* insert_node(int a){
struct node* newnode;
newnode = (struct node*) malloc (sizeof(struct node));
newnode->a = a;
newnode->left = NULL;
newnode->right = NULL;
return newnode;
}
int searchtree(struct node* root,int num){
if(root == NULL)
return 0;
if(root->a == num ||searchtree(root->left,num))
return 1;
if(root->a == num || searchtree(root->right,num)){
return 1;
}
}
int main(){
int num;
struct node* root;
root = insert_node(1);
root->left = insert_node(2);
root->right = insert_node(3);
root->right->right = insert_node(4);
root->right->left = insert_node(5);
root->left->left = insert_node(6);
root->left->right = insert_node(7);
root->left->right->left = insert_node(8);
printf("type a number:");
scanf("%d",&num);
if(searchtree(root,num)){
printf("number found in tree");
}
else{
printf("number not found in tree");
};
return(0);
}