Skip to content

Commit

Permalink
First Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ishmeet1995 committed Mar 3, 2018
1 parent b64c5a1 commit 1b98e2f
Show file tree
Hide file tree
Showing 148 changed files with 2,593 additions and 0 deletions.
66 changes: 66 additions & 0 deletions C programs/.vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"configurations": [
{
"name": "Mac",
"includePath": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"defines": [],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"macFrameworkPath": [
"/System/Library/Frameworks",
"/Library/Frameworks"
]
},
{
"name": "Linux",
"includePath": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"defines": [],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
},
{
"name": "Win32",
"includePath": [
"${workspaceRoot}"
],
"defines": [
"_DEBUG",
"UNICODE"
],
"intelliSenseMode": "msvc-x64",
"browse": {
"path": [
"${workspaceFolder}",
"C:\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include\\c++"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 3
}
44 changes: 44 additions & 0 deletions C programs/C programs.cbp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="C programs" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/C programs" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/C programs" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
</Compiler>
<Unit filename="main.c">
<Option compilerVar="CC" />
</Unit>
<Extensions>
<code_completion />
<envvars />
<debugger />
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>
10 changes: 10 additions & 0 deletions C programs/C programs.layout
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" />
<File name="main.c" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="107" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>
48 changes: 48 additions & 0 deletions C programs/C programs/C programs.cbp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="C programs" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/C programs" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/C programs" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
</Compiler>
<Unit filename="main.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="new.c">
<Option compilerVar="CC" />
<Option target="&lt;{~None~}&gt;" />
</Unit>
<Extensions>
<code_completion />
<envvars />
<debugger />
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>
5 changes: 5 additions & 0 deletions C programs/C programs/C programs.depend
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# depslib dependency file v1.0
1446667744 source:d:\programs\c\c programs\c programs\main.c
<stdio.h>
<stdlib.h>

10 changes: 10 additions & 0 deletions C programs/C programs/C programs.layout
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" />
<File name="main.c" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="20" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>
8 changes: 8 additions & 0 deletions C programs/C programs/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <stdio.h>
#include <stdlib.h>

int main()
{
printf("Hello world!\n");
return 0;
}
8 changes: 8 additions & 0 deletions C programs/C programs/new.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <stdio.h>
#include <stdlib.h>

int main()
{
printf("Hello world!\n");
return 0;
}
Binary file added C programs/C programs/obj/Debug/main.o
Binary file not shown.
68 changes: 68 additions & 0 deletions C programs/cprog/BST find height of tree.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#include<stdio.h>
#include<stdlib.h>
typedef struct node ///////////iterative method
{
struct node *left,*right;
int data;
}node;

int height(node *root)
{
node *temp=root;

int left_height=0;
int right_height=0;
if(root==NULL)
{
return(0);
}
left_height=height(temp->left);

right_height=height(temp->right);

if(left_height>right_height)
{
return(left_height+1);

}
else {return(right_height+1);}
}

int bst_enter(node *root,int x)
{
node *temp=(node *)malloc(sizeof(node));
temp->data=x;
temp->left=NULL;
temp->right=NULL;

if(root==NULL)
{
root=temp;
}
else if(x<root->data)
{
root->left=bst_enter(root->left,x);
}
else
{
root->right=bst_enter(root->right,x);
}
return(root);
}

int main()
{
node *root=NULL;
root=bst_enter(root,15);
root=bst_enter(root,30);
root=bst_enter(root,25);
root=bst_enter(root,20);
root=bst_enter(root,10);
root=bst_enter(root,4);



int x=height(root);
printf("%d",x);
}

Binary file added C programs/cprog/BST find height of tree.exe
Binary file not shown.
Binary file added C programs/cprog/BST find height of tree.o
Binary file not shown.
55 changes: 55 additions & 0 deletions C programs/cprog/BST find min and max(recursive method).c
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include<stdio.h>
#include<stdlib.h>
typedef struct node ///////////iterative method
{
struct node *left,*right;
int data;
}node;

int find_min(node *root)
{
node *current=root;
if(root==NULL)
{
return(0);
}
else if(current->left==NULL)
{
return(current->data);
}

return(find_min(current->left));
}

int bst_enter(node *root,int x)
{
node *temp=(node *)malloc(sizeof(node));
temp->data=x;
temp->left=NULL;
temp->right=NULL;

if(root==NULL)
{
root=temp;
}
else if(x<root->data)
{
root->left=bst_enter(root->left,x);
}
else
{
root->right=bst_enter(root->right,x);
}
return(root);
}

int main()
{
node *root=NULL;
root=bst_enter(root,15);
root=bst_enter(root,5);
root=bst_enter(root,10);

int x=find_min(root);
printf("%d",x);
}
Binary file not shown.
Binary file not shown.
55 changes: 55 additions & 0 deletions C programs/cprog/BST find min and max.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include<stdio.h>
#include<stdlib.h>
typedef struct node ///////////iterative method
{
struct node *left,*right;
int data;
}node;

int find_min(node *root)
{
node *current=root;
if(root==NULL)
{
return(0);
}
while(current->left!=NULL)
{
current=current->left;
}
return(current->data);

}

int bst_enter(node *root,int x)
{
node *temp=(node *)malloc(sizeof(node));
temp->data=x;
temp->left=NULL;
temp->right=NULL;

if(root==NULL)
{
root=temp;
}
else if(x<root->data)
{
root->left=bst_enter(root->left,x);
}
else
{
root->right=bst_enter(root->right,x);
}
return(root);
}

int main()
{
node *root=NULL;
root=bst_enter(root,15);
root=bst_enter(root,5);
root=bst_enter(root,10);

int x=find_min(root);
printf("%d",x);
}
Binary file added C programs/cprog/BST find min and max.exe
Binary file not shown.
Binary file added C programs/cprog/BST find min and max.o
Binary file not shown.
Loading

0 comments on commit 1b98e2f

Please sign in to comment.