Showing posts with label cpp program. Show all posts

c++ program to create Database using STL



Database using STL
//Note : This pogram should be run under Linux using g++ or VCC



Database using STL
//Note : This pogram should be run under Linux using g++ or VCC

c++ program for Dequeue using STL



Dequeue using STL
//Note : This pogram should be run under Linux using g++ or VCC



Dequeue using STL
//Note : This pogram should be run under Linux using g++ or VCC

c++ program for Addition of binary Nos. using STL stack




Addition of binary Nos. using STL stack
//Note : This pogram should be run under Linux using g++  or in VCC




Addition of binary Nos. using STL stack
//Note : This pogram should be run under Linux using g++  or in VCC

c++ program for Queue using a linked list



Queue using a linked list



Queue using a linked list

c++ program for Stack Using a linked list



Stack Using a linked list



Stack Using a linked list

c++ program for CLL as a class



CLL as a class



CLL as a class

c++ program for DLL as a class



DLL as a class



DLL as a class

c++ program for Linked list as a class



Linked list as a class



Linked list as a class

c++ program for Direct Access File ,Collision handling throgh linear probing with chaining and with replacement



Direct Access File ,Collision handling throgh linear probing with chaining and with replacement

OUTPUT:
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:2
 
Enter a record to be inserted(roll no,name,marks) : 101 Nisha 98
 
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:2
 
Enter a record to be inserted(roll no,name,marks) : 155 Amit 67
 
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:2
 
Enter a record to be inserted(roll no,name,marks) : 145 Sonal 87
 
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:1
*********Data File*********
 
0) ***** Empty  ********
1) 101   Nisha   98   -1
2) ***** Empty  ********
3) ***** Empty  ********
4) ***** Empty  ********
5) 155   Amit   67   6
6) 145   Sonal   87   -1
7) ***** Empty  ********
8) ***** Empty  ********
9) ***** Empty  ********
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:4
 
Enter a roll no. : 155
 
 Record No.:  5
5) 155   Amit   67   6
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:3
 
Enter the roll no.:101
 
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:1
*********Data File*********
 
0) ***** Empty  ********
1) ***** Empty  ********
2) ***** Empty  ********
3) ***** Empty  ********
4) ***** Empty  ********
5) 155   Amit   67   6
6) 145   Sonal   87   -1
7) ***** Empty  ********
8) ***** Empty  ********
9) ***** Empty  ********
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:5





Direct Access File ,Collision handling throgh linear probing with chaining and with replacement

OUTPUT:
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:2
 
Enter a record to be inserted(roll no,name,marks) : 101 Nisha 98
 
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:2
 
Enter a record to be inserted(roll no,name,marks) : 155 Amit 67
 
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:2
 
Enter a record to be inserted(roll no,name,marks) : 145 Sonal 87
 
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:1
*********Data File*********
 
0) ***** Empty  ********
1) 101   Nisha   98   -1
2) ***** Empty  ********
3) ***** Empty  ********
4) ***** Empty  ********
5) 155   Amit   67   6
6) 145   Sonal   87   -1
7) ***** Empty  ********
8) ***** Empty  ********
9) ***** Empty  ********
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:4
 
Enter a roll no. : 155
 
 Record No.:  5
5) 155   Amit   67   6
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:3
 
Enter the roll no.:101
 
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:1
*********Data File*********
 
0) ***** Empty  ********
1) ***** Empty  ********
2) ***** Empty  ********
3) ***** Empty  ********
4) ***** Empty  ********
5) 155   Amit   67   6
6) 145   Sonal   87   -1
7) ***** Empty  ********
8) ***** Empty  ********
9) ***** Empty  ********
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:5



c++ program for Direct Access File ,Collision handling throgh linear probing with chaining and without replacement



Direct Access File ,Collision handling throgh linear probing with chaining and without replacement

OUTPUT:
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:2
 
Enter a record to be inserted(roll no,name,marks) : 155 Nilesh 76
 
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:2
 
Enter a record to be inserted(roll no,name,marks) : 45 Komal 88
 
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:2
 
Enter a record to be inserted(roll no,name,marks) : 90 Ashish 70
 
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:4
 
Enter a roll no. : 45
 
 Record No.:  6
6) 45  Komal  88 -1
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:1
*********Data File*********
 
0) 90  Ashish  70 -1
1) ***** Empty  ********
2) ***** Empty  ********
3) ***** Empty  ********
4) ***** Empty  ********
5) 155  Nilesh  76 6
6) 45  Komal  88 -1
7) ***** Empty  ********
8) ***** Empty  ********
9) ***** Empty  ********
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:3
 
Enter the roll no.:45
 
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:1
 
*********Data File*********
 
0) 90  Ashish  70 -1
1) ***** Empty  ********
2) ***** Empty  ********
3) ***** Empty  ********
4) ***** Empty  ********
5) 155  Nilesh  76 -1
6) ***** Empty  ********
7) ***** Empty  ********
8) ***** Empty  ********
9) ***** Empty  ********
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:5





Direct Access File ,Collision handling throgh linear probing with chaining and without replacement

OUTPUT:
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:2
 
Enter a record to be inserted(roll no,name,marks) : 155 Nilesh 76
 
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:2
 
Enter a record to be inserted(roll no,name,marks) : 45 Komal 88
 
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:2
 
Enter a record to be inserted(roll no,name,marks) : 90 Ashish 70
 
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:4
 
Enter a roll no. : 45
 
 Record No.:  6
6) 45  Komal  88 -1
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:1
*********Data File*********
 
0) 90  Ashish  70 -1
1) ***** Empty  ********
2) ***** Empty  ********
3) ***** Empty  ********
4) ***** Empty  ********
5) 155  Nilesh  76 6
6) 45  Komal  88 -1
7) ***** Empty  ********
8) ***** Empty  ********
9) ***** Empty  ********
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:3
 
Enter the roll no.:45
 
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:1
 
*********Data File*********
 
0) 90  Ashish  70 -1
1) ***** Empty  ********
2) ***** Empty  ********
3) ***** Empty  ********
4) ***** Empty  ********
5) 155  Nilesh  76 -1
6) ***** Empty  ********
7) ***** Empty  ********
8) ***** Empty  ********
9) ***** Empty  ********
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:5



c++ program to implement Direct Access File ,Linear probing without chaining



Direct Access File ,Linear probing without chaining

OUTPUT:
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:2
 
Enter a record to be inserted(roll no,name,marks) : 101 Mangesh 99
 
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:2
 
Enter a record to be inserted(roll no,name,marks) : 105 Ramnath 78
 
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:2
 
Enter a record to be inserted(roll no,name,marks) : 109 Sahil 66
 
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:1
*********Data File*********
 
0) ***** Empty  ********
1) 101  Mangesh  99
2) ***** Empty  ********
3) ***** Empty  ********
4) ***** Empty  ********
5) 105  Ramnath  78
6) ***** Empty  ********
7) ***** Empty  ********
8) ***** Empty  ********
9) 109  Sahil  66
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:4
 
Enter a roll no. : 105
 
 Record No.:  5
5) 105  Ramnath  78
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:3
 
Enter the roll no.:109
 
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:1
*********Data File*********
 
0) ***** Empty  ********
1) 101  Mangesh  99
2) ***** Empty  ********
3) ***** Empty  ********
4) ***** Empty  ********
5) 105  Ramnath  78
6) ***** Empty  ********
7) ***** Empty  ********
8) ***** Empty  ********
9) ***** Empty  ********
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:5





Direct Access File ,Linear probing without chaining

OUTPUT:
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:2
 
Enter a record to be inserted(roll no,name,marks) : 101 Mangesh 99
 
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:2
 
Enter a record to be inserted(roll no,name,marks) : 105 Ramnath 78
 
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:2
 
Enter a record to be inserted(roll no,name,marks) : 109 Sahil 66
 
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:1
*********Data File*********
 
0) ***** Empty  ********
1) 101  Mangesh  99
2) ***** Empty  ********
3) ***** Empty  ********
4) ***** Empty  ********
5) 105  Ramnath  78
6) ***** Empty  ********
7) ***** Empty  ********
8) ***** Empty  ********
9) 109  Sahil  66
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:4
 
Enter a roll no. : 105
 
 Record No.:  5
5) 105  Ramnath  78
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:3
 
Enter the roll no.:109
 
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:1
*********Data File*********
 
0) ***** Empty  ********
1) 101  Mangesh  99
2) ***** Empty  ********
3) ***** Empty  ********
4) ***** Empty  ********
5) 105  Ramnath  78
6) ***** Empty  ********
7) ***** Empty  ********
8) ***** Empty  ********
9) ***** Empty  ********
 
1)Print
2)Insert
3)Delete
4)Search
5)Quit
Enter Your Choice:5



c++ program to Implementation of an AVL tree



Implementation of an  AVL tree

OUTPUT:
 
1)Create :
2)Insert :
3)Delete :
4)Print  :
5)Quit   :
Enter Your Choice : 1
 
Enter no.of elements :10
 
 Enter tree data :1  2  4  6  8  3  5   9  7  11
 
1)Create :
2)Insert :
3)Delete :
4)Print  :
5)Quit   :
Enter Your Choice : 4
 
Preorder sequence :
 4(Bf=-1) 2(Bf=0) 1(Bf=0) 3(Bf=0) 8(Bf=0) 6(Bf=0) 5(Bf=0) 7(Bf=0) 9(Bf=-1) 11(Bf=0)
Inorder sequence :
 1(Bf=0) 2(Bf=0) 3(Bf=0) 4(Bf=-1) 5(Bf=0) 6(Bf=0) 7(Bf=0) 8(Bf=0) 9(Bf=-1) 11(Bf=0)
 
1)Create :
2)Insert :
3)Delete :
4)Print  :
5)Quit   :
Enter Your Choice : 3
 
Enter a data : 4
 
1)Create :
2)Insert :
3)Delete :
4)Print  :
5)Quit   :
Enter Your Choice : 4
 
Preorder sequence :
 5(Bf=-1) 2(Bf=0) 1(Bf=0) 3(Bf=0) 8(Bf=0) 6(Bf=-1) 7(Bf=0) 9(Bf=-1) 11(Bf=0)
Inorder sequence :
 1(Bf=0) 2(Bf=0) 3(Bf=0) 5(Bf=-1) 6(Bf=-1) 7(Bf=0) 8(Bf=0) 9(Bf=-1) 11(Bf=0)
 
1)Create :
2)Insert :
3)Delete :
4)Print  :
5)Quit   :
Enter Your Choice : 2
 
Enter a data : 4
 
1)Create :
2)Insert :
3)Delete :
4)Print  :
5)Quit   :
Enter Your Choice : 5





Implementation of an  AVL tree

OUTPUT:
 
1)Create :
2)Insert :
3)Delete :
4)Print  :
5)Quit   :
Enter Your Choice : 1
 
Enter no.of elements :10
 
 Enter tree data :1  2  4  6  8  3  5   9  7  11
 
1)Create :
2)Insert :
3)Delete :
4)Print  :
5)Quit   :
Enter Your Choice : 4
 
Preorder sequence :
 4(Bf=-1) 2(Bf=0) 1(Bf=0) 3(Bf=0) 8(Bf=0) 6(Bf=0) 5(Bf=0) 7(Bf=0) 9(Bf=-1) 11(Bf=0)
Inorder sequence :
 1(Bf=0) 2(Bf=0) 3(Bf=0) 4(Bf=-1) 5(Bf=0) 6(Bf=0) 7(Bf=0) 8(Bf=0) 9(Bf=-1) 11(Bf=0)
 
1)Create :
2)Insert :
3)Delete :
4)Print  :
5)Quit   :
Enter Your Choice : 3
 
Enter a data : 4
 
1)Create :
2)Insert :
3)Delete :
4)Print  :
5)Quit   :
Enter Your Choice : 4
 
Preorder sequence :
 5(Bf=-1) 2(Bf=0) 1(Bf=0) 3(Bf=0) 8(Bf=0) 6(Bf=-1) 7(Bf=0) 9(Bf=-1) 11(Bf=0)
Inorder sequence :
 1(Bf=0) 2(Bf=0) 3(Bf=0) 5(Bf=-1) 6(Bf=-1) 7(Bf=0) 8(Bf=0) 9(Bf=-1) 11(Bf=0)
 
1)Create :
2)Insert :
3)Delete :
4)Print  :
5)Quit   :
Enter Your Choice : 2
 
Enter a data : 4
 
1)Create :
2)Insert :
3)Delete :
4)Print  :
5)Quit   :
Enter Your Choice : 5



c++ program to Implementation of a B-Tree



Implementation of a B-Tree

OUTPUT:
 
maximum number of keys in a node ? :4
 
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 1
 
Enter a data : 10
 
Tree after insertion :
(10 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice :  1
 
Enter a data : 20
 
Tree after insertion :
(10 20 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 1
 
Enter a data : 30
 
Tree after insertion :
(10 20 30 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 1
 
Enter a data : 40
Tree after insertion :
(10 20 30 40 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 1
 
Enter a data : 50
 
Tree after insertion :
(30 )
(10 20 )  (40 50 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 1
 
Enter a data : 60
 
Tree after insertion :
(30 )
(10 20 )  (40 50 60 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 1
 
Enter a data : 70
 
Tree after insertion :
(30 )
(10 20 )  (40 50 60 70 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 1
 
Enter a data : 80
Tree after insertion :
(30 60 )
(10 20 )  (40 50 )  (70 80 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 2
 
Enter a data : 10
 
Found in the node : (10 20 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 2
 
Enter a data : 15
 
Not found
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice :3
Enter a data : 10
 
(60 )
(20 30 40 50 )  (70 80 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 3
 
Enter a data : 70
 
(50 )
(20 30 40 )  (60 80 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 3
 
Enter a data : 30
 
(50 )
(20 40 )  (60 80 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 3
 
Enter a data : 60
 
(20 40 50 80 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 5





Implementation of a B-Tree

OUTPUT:
 
maximum number of keys in a node ? :4
 
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 1
 
Enter a data : 10
 
Tree after insertion :
(10 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice :  1
 
Enter a data : 20
 
Tree after insertion :
(10 20 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 1
 
Enter a data : 30
 
Tree after insertion :
(10 20 30 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 1
 
Enter a data : 40
Tree after insertion :
(10 20 30 40 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 1
 
Enter a data : 50
 
Tree after insertion :
(30 )
(10 20 )  (40 50 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 1
 
Enter a data : 60
 
Tree after insertion :
(30 )
(10 20 )  (40 50 60 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 1
 
Enter a data : 70
 
Tree after insertion :
(30 )
(10 20 )  (40 50 60 70 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 1
 
Enter a data : 80
Tree after insertion :
(30 60 )
(10 20 )  (40 50 )  (70 80 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 2
 
Enter a data : 10
 
Found in the node : (10 20 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 2
 
Enter a data : 15
 
Not found
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice :3
Enter a data : 10
 
(60 )
(20 30 40 50 )  (70 80 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 3
 
Enter a data : 70
 
(50 )
(20 30 40 )  (60 80 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 3
 
Enter a data : 30
 
(50 )
(20 40 )  (60 80 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 3
 
Enter a data : 60
 
(20 40 50 80 )
 
1)Insert
2)Search
3)Delete
4)Print
5)Quit
Enter your choice : 5



c++ program for Prim's algorithm



constructing a minimum cost spanning tree of a graph using Prim's algorithm

OUTPUT: 
  
Enter no. of vertices :8 
  
Enter no of edges :10 
  
Enter the list of edges : 
Enter an edge (u,v,wight)  :0 1 2 
  
Enter an edge (u,v,wight)  :0 2 1 
  
Enter an edge (u,v,wight)  :1 3 4 
  
Enter an edge (u,v,wight)  :1 4 2 
  
Enter an edge (u,v,wight)  :2 5 2 
  
Enter an edge (u,v,wight)  :2 6 3 
  
Enter an edge (u,v,wight)  :3 7 4 
  
Enter an edge (u,v,wight)  :4 7 3 
  
Enter an edge (u,v,wight)  :5 7 6 
  
Enter an edge (u,v,wight)  :6 7 2 
  
spanning tree matrix : 
  
List of edges in the spanning tree: 
(u,v,wight)= (0,1,2) 
(u,v,wight)= (0,2,1) 
(u,v,wight)= (1,3,4) 
(u,v,wight)= (1,4,2) 
(u,v,wight)= (2,5,2) 
(u,v,wight)= (2,6,3) 
(u,v,wight)= (6,7,2) 
Total cost of spanning tree= 16 



constructing a minimum cost spanning tree of a graph using Prim's algorithm

OUTPUT: 
  
Enter no. of vertices :8 
  
Enter no of edges :10 
  
Enter the list of edges : 
Enter an edge (u,v,wight)  :0 1 2 
  
Enter an edge (u,v,wight)  :0 2 1 
  
Enter an edge (u,v,wight)  :1 3 4 
  
Enter an edge (u,v,wight)  :1 4 2 
  
Enter an edge (u,v,wight)  :2 5 2 
  
Enter an edge (u,v,wight)  :2 6 3 
  
Enter an edge (u,v,wight)  :3 7 4 
  
Enter an edge (u,v,wight)  :4 7 3 
  
Enter an edge (u,v,wight)  :5 7 6 
  
Enter an edge (u,v,wight)  :6 7 2 
  
spanning tree matrix : 
  
List of edges in the spanning tree: 
(u,v,wight)= (0,1,2) 
(u,v,wight)= (0,2,1) 
(u,v,wight)= (1,3,4) 
(u,v,wight)= (1,4,2) 
(u,v,wight)= (2,5,2) 
(u,v,wight)= (2,6,3) 
(u,v,wight)= (6,7,2) 
Total cost of spanning tree= 16 

C++ program to Represent a graph using adjacency list and perform DFS and BFS



Represent a graph using adjacency list and perform DFS and BFS

OUTPUT:
 
1)Create a graph
2)BFS
3)DFS
4)Quit
Enter Your Choice : 1
 
Enter no. of vertices :8
 
Enter no of edges :10
 
Enter an edge (u,v)  :0 1
 
Enter an edge (u,v)  :0 2
 
Enter an edge (u,v)  :1 3
 
Enter an edge (u,v)  :1 4
 
Enter an edge (u,v)  :2 5
 
Enter an edge (u,v)  :2 6
 
Enter an edge (u,v)  :3 7
 
Enter an edge (u,v)  : 4 7
 
Enter an edge (u,v)  :5 7
 
Enter an edge (u,v)  :6 7
1)Create a graph
2)BFS
3)DFS
4)Quit
Enter Your Choice : 2
 
Enter starting node : 1
 
 Visit  1
visit  0
visit  3
visit  4
visit  2
visit  7
visit  5
visit  6
 
1)Create a graph
2)BFS
3)DFS
4)Quit
Enter Your Choice : 3
 
Enter starting node : 1
 
1
0
2
5
7
3
4
6
 
1)Create a graph
2)BFS
3)DFS
4)Quit
Enter Your Choice : 4





Represent a graph using adjacency list and perform DFS and BFS

OUTPUT:
 
1)Create a graph
2)BFS
3)DFS
4)Quit
Enter Your Choice : 1
 
Enter no. of vertices :8
 
Enter no of edges :10
 
Enter an edge (u,v)  :0 1
 
Enter an edge (u,v)  :0 2
 
Enter an edge (u,v)  :1 3
 
Enter an edge (u,v)  :1 4
 
Enter an edge (u,v)  :2 5
 
Enter an edge (u,v)  :2 6
 
Enter an edge (u,v)  :3 7
 
Enter an edge (u,v)  : 4 7
 
Enter an edge (u,v)  :5 7
 
Enter an edge (u,v)  :6 7
1)Create a graph
2)BFS
3)DFS
4)Quit
Enter Your Choice : 2
 
Enter starting node : 1
 
 Visit  1
visit  0
visit  3
visit  4
visit  2
visit  7
visit  5
visit  6
 
1)Create a graph
2)BFS
3)DFS
4)Quit
Enter Your Choice : 3
 
Enter starting node : 1
 
1
0
2
5
7
3
4
6
 
1)Create a graph
2)BFS
3)DFS
4)Quit
Enter Your Choice : 4



C++ program to Create a TBT and perform traversals


Create a TBT and perform traversals

OUTPUT:

1)Create
2)Preorder
3)Inorder
4)Postorder
5)Quit
Enter your choice : 1

 Enter a data(-1 for no data or NULL child ) : 1

Enter left child of 1
 Enter a data(-1 for no data or NULL child ) : 2

Enter left child of 2
 Enter a data(-1 for no data or NULL child ) : 4

Enter left child of 4
 Enter a data(-1 for no data or NULL child ) : -1

Enter right child of 4
 Enter a data(-1 for no data or NULL child ) : -1

Enter right child of 2
 Enter a data(-1 for no data or NULL child ) : 5

Enter left child of 5
 Enter a data(-1 for no data or NULL child ) : -1

Enter right child of 5
 Enter a data(-1 for no data or NULL child ) : -1

Enter right child of 1
 Enter a data(-1 for no data or NULL child ) : 3

Enter left child of 3
 Enter a data(-1 for no data or NULL child ) : 6

Enter left child of 6
 Enter a data(-1 for no data or NULL child ) : -1

Enter right child of 6
 Enter a data(-1 for no data or NULL child ) : -1

Enter right child of 3
 Enter a data(-1 for no data or NULL child ) : 7

Enter left child of 7
 Enter a data(-1 for no data or NULL child ) : -1
Enter right child of 7
 Enter a data(-1 for no data or NULL child ) : -1


1)Create
2)Preorder
3)Inorder
4)Postorder
5)Quit
Enter your choice : 2

  1  2  4  5  3  6  7

1)Create
2)Preorder
3)Inorder
4)Postorder
5)Quit
Enter your choice : 3

   4   2   5   1   6   3   7

1)Create
2)Preorder
3)Inorder
4)Postorder
5)Quit
Enter your choice : 4
   4   5   2   6   7   3   1

1)Create
2)Preorder
3)Inorder
4)Postorder
5)Quit
Enter your choice : 5




Create a TBT and perform traversals

OUTPUT:

1)Create
2)Preorder
3)Inorder
4)Postorder
5)Quit
Enter your choice : 1

 Enter a data(-1 for no data or NULL child ) : 1

Enter left child of 1
 Enter a data(-1 for no data or NULL child ) : 2

Enter left child of 2
 Enter a data(-1 for no data or NULL child ) : 4

Enter left child of 4
 Enter a data(-1 for no data or NULL child ) : -1

Enter right child of 4
 Enter a data(-1 for no data or NULL child ) : -1

Enter right child of 2
 Enter a data(-1 for no data or NULL child ) : 5

Enter left child of 5
 Enter a data(-1 for no data or NULL child ) : -1

Enter right child of 5
 Enter a data(-1 for no data or NULL child ) : -1

Enter right child of 1
 Enter a data(-1 for no data or NULL child ) : 3

Enter left child of 3
 Enter a data(-1 for no data or NULL child ) : 6

Enter left child of 6
 Enter a data(-1 for no data or NULL child ) : -1

Enter right child of 6
 Enter a data(-1 for no data or NULL child ) : -1

Enter right child of 3
 Enter a data(-1 for no data or NULL child ) : 7

Enter left child of 7
 Enter a data(-1 for no data or NULL child ) : -1
Enter right child of 7
 Enter a data(-1 for no data or NULL child ) : -1


1)Create
2)Preorder
3)Inorder
4)Postorder
5)Quit
Enter your choice : 2

  1  2  4  5  3  6  7

1)Create
2)Preorder
3)Inorder
4)Postorder
5)Quit
Enter your choice : 3

   4   2   5   1   6   3   7

1)Create
2)Preorder
3)Inorder
4)Postorder
5)Quit
Enter your choice : 4
   4   5   2   6   7   3   1

1)Create
2)Preorder
3)Inorder
4)Postorder
5)Quit
Enter your choice : 5



C++ program to Create binary tree.Find height, mirror image,level-wise printing.


Create binary tree.Find height, mirror image,level-wise printing.

OUTPUT:

1)Create
2)Mirror
3)Print leaf nodes
4)Height
5)Quit
Enter Your Choice :1

 Enter a data(-1 for no data or NULL node ) : 1

Enter left child of 1
 Enter a data(-1 for no data or NULL node ) : 2

Enter left child of 2
 Enter a data(-1 for no data or NULL node ) : 4

Enter left child of 4
 Enter a data(-1 for no data or NULL node ) : -1

Enter right child of 4
 Enter a data(-1 for no data or NULL node ) : -1

Enter right child of 2
 Enter a data(-1 for no data or NULL node ) : 5

Enter left child of 5
 Enter a data(-1 for no data or NULL node ) : -1

Enter right child of 5
 Enter a data(-1 for no data or NULL node ) : -1

Enter right child of 1
 Enter a data(-1 for no data or NULL node ) : 3

Enter left child of 3
 Enter a data(-1 for no data or NULL node ) : 6

Enter left child of 6
 Enter a data(-1 for no data or NULL node ) : -1

Enter right child of 6
 Enter a data(-1 for no data or NULL node ) : -1

Enter right child of 3
 Enter a data(-1 for no data or NULL node ) : 7

Enter left child of 7
 Enter a data(-1 for no data or NULL node ) : -1
Enter right child of 7
 Enter a data(-1 for no data or NULL node ) : -1


1)Create
2)Mirror
3)Print leaf nodes
4)Height
5)Quit
Enter Your Choice :2

 level Wise traversal on original tree

   1
  2  3
  4  5  6  7

 level Wise traversal on mirror tree

   1
  3  2
  7  6  5  4


1)Create
2)Mirror
3)Print leaf nodes
4)Height
5)Quit
Enter Your Choice :3
  7  6  5  4
No of leaf nodes= 4

1)Create
2)Mirror
3)Print leaf nodes
4)Height
5)Quit
Enter Your Choice :4

Height = 2

1)Create
2)Mirror
3)Print leaf nodes
4)Height
5)Quit
Enter Your Choice :5




Create binary tree.Find height, mirror image,level-wise printing.

OUTPUT:

1)Create
2)Mirror
3)Print leaf nodes
4)Height
5)Quit
Enter Your Choice :1

 Enter a data(-1 for no data or NULL node ) : 1

Enter left child of 1
 Enter a data(-1 for no data or NULL node ) : 2

Enter left child of 2
 Enter a data(-1 for no data or NULL node ) : 4

Enter left child of 4
 Enter a data(-1 for no data or NULL node ) : -1

Enter right child of 4
 Enter a data(-1 for no data or NULL node ) : -1

Enter right child of 2
 Enter a data(-1 for no data or NULL node ) : 5

Enter left child of 5
 Enter a data(-1 for no data or NULL node ) : -1

Enter right child of 5
 Enter a data(-1 for no data or NULL node ) : -1

Enter right child of 1
 Enter a data(-1 for no data or NULL node ) : 3

Enter left child of 3
 Enter a data(-1 for no data or NULL node ) : 6

Enter left child of 6
 Enter a data(-1 for no data or NULL node ) : -1

Enter right child of 6
 Enter a data(-1 for no data or NULL node ) : -1

Enter right child of 3
 Enter a data(-1 for no data or NULL node ) : 7

Enter left child of 7
 Enter a data(-1 for no data or NULL node ) : -1
Enter right child of 7
 Enter a data(-1 for no data or NULL node ) : -1


1)Create
2)Mirror
3)Print leaf nodes
4)Height
5)Quit
Enter Your Choice :2

 level Wise traversal on original tree

   1
  2  3
  4  5  6  7

 level Wise traversal on mirror tree

   1
  3  2
  7  6  5  4


1)Create
2)Mirror
3)Print leaf nodes
4)Height
5)Quit
Enter Your Choice :3
  7  6  5  4
No of leaf nodes= 4

1)Create
2)Mirror
3)Print leaf nodes
4)Height
5)Quit
Enter Your Choice :4

Height = 2

1)Create
2)Mirror
3)Print leaf nodes
4)Height
5)Quit
Enter Your Choice :5



c++ program Create binary tree and perform recursive and non-recursive traversal



Create binary tree and perform recursive and non-recursive traversal

OUTPUT:
 
 
 
1)Create
2)Preorder(recursive)
3)Inorder(recursive)
4)Postorder(Recursive)
5)Inorder(Non-Recursive)
6)Preorder(Non-REcursive)
7)Postorder(Non-REcursive)
8)Quit
Enter Your Choice :1
 
 Enter a data(-1 for no data or Null node ) : 1
 
Enter left child of 1
 Enter a data(-1 for no data or Null node ) : 2
 
Enter left child of 2
 Enter a data(-1 for no data or Null node ) : 4
 
Enter left child of 4
 Enter a data(-1 for no data or Null node ) : -1
 
Enter right child of 4
 Enter a data(-1 for no data or Null node ) : -1
 
Enter right child of 2
 Enter a data(-1 for no data or Null node ) : 5
 
Enter left child of 5
 Enter a data(-1 for no data or Null node ) : -1
 
Enter right child of 5
 Enter a data(-1 for no data or Null node ) : -1
 
Enter right child of 1
 Enter a data(-1 for no data or Null node ) : 3
 
Enter left child of 3
 Enter a data(-1 for no data or Null node ) : 6
 
Enter left child of 6
 Enter a data(-1 for no data or Null node ) : -1
 
Enter right child of 6
 Enter a data(-1 for no data or Null node ) : -1
 
Enter right child of 3
 Enter a data(-1 for no data or Null node ) : 7
Enter left child of 7
 Enter a data(-1 for no data or Null node ) : -1
 
Enter right child of 7
 Enter a data(-1 for no data or Null node ) : -1
 
 
1)Create
2)Preorder(recursive)
3)Inorder(recursive)
4)Postorder(Recursive)
5)Inorder(Non-Recursive)
6)Preorder(Non-REcursive)
7)Postorder(Non-REcursive)
8)Quit
Enter Your Choice :2
  1  2  4  5  3  6  7
 
1)Create
2)Preorder(recursive)
3)Inorder(recursive)
4)Postorder(Recursive)
5)Inorder(Non-Recursive)
6)Preorder(Non-REcursive)
7)Postorder(Non-REcursive)
8)Quit
Enter Your Choice :3
  4  2  5  1  6  3  7
 
1)Create
2)Preorder(recursive)
3)Inorder(recursive)
4)Postorder(Recursive)
5)Inorder(Non-Recursive)
6)Preorder(Non-REcursive)
7)Postorder(Non-REcursive)
8)Quit
Enter Your Choice :4
  4  5  2  6  7  3  1
 
1)Create
2)Preorder(recursive)
3)Inorder(recursive)
4)Postorder(Recursive)
5)Inorder(Non-Recursive)
6)Preorder(Non-REcursive)
7)Postorder(Non-REcursive)
8)Quit
Enter Your Choice :5
 
  4  2  5  1  6  3  7
 
1)Create
2)Preorder(recursive)
3)Inorder(recursive)
4)Postorder(Recursive)
5)Inorder(Non-Recursive)
6)Preorder(Non-REcursive)
7)Postorder(Non-REcursive)
8)Quit
Enter Your Choice :6
  1  2  4  5  3  6  7
 
1)Create
2)Preorder(recursive)
3)Inorder(recursive)
4)Postorder(Recursive)
5)Inorder(Non-Recursive)
6)Preorder(Non-REcursive)
7)Postorder(Non-REcursive)
8)Quit
Enter Your Choice :7
 
  4  5  2  6  7  3  1
 
1)Create
2)Preorder(recursive)
3)Inorder(recursive)
4)Postorder(Recursive)
5)Inorder(Non-Recursive)
6)Preorder(Non-REcursive)
7)Postorder(Non-REcursive)
8)Quit
Enter Your Choice :8
 





Create binary tree and perform recursive and non-recursive traversal

OUTPUT:
 
 
 
1)Create
2)Preorder(recursive)
3)Inorder(recursive)
4)Postorder(Recursive)
5)Inorder(Non-Recursive)
6)Preorder(Non-REcursive)
7)Postorder(Non-REcursive)
8)Quit
Enter Your Choice :1
 
 Enter a data(-1 for no data or Null node ) : 1
 
Enter left child of 1
 Enter a data(-1 for no data or Null node ) : 2
 
Enter left child of 2
 Enter a data(-1 for no data or Null node ) : 4
 
Enter left child of 4
 Enter a data(-1 for no data or Null node ) : -1
 
Enter right child of 4
 Enter a data(-1 for no data or Null node ) : -1
 
Enter right child of 2
 Enter a data(-1 for no data or Null node ) : 5
 
Enter left child of 5
 Enter a data(-1 for no data or Null node ) : -1
 
Enter right child of 5
 Enter a data(-1 for no data or Null node ) : -1
 
Enter right child of 1
 Enter a data(-1 for no data or Null node ) : 3
 
Enter left child of 3
 Enter a data(-1 for no data or Null node ) : 6
 
Enter left child of 6
 Enter a data(-1 for no data or Null node ) : -1
 
Enter right child of 6
 Enter a data(-1 for no data or Null node ) : -1
 
Enter right child of 3
 Enter a data(-1 for no data or Null node ) : 7
Enter left child of 7
 Enter a data(-1 for no data or Null node ) : -1
 
Enter right child of 7
 Enter a data(-1 for no data or Null node ) : -1
 
 
1)Create
2)Preorder(recursive)
3)Inorder(recursive)
4)Postorder(Recursive)
5)Inorder(Non-Recursive)
6)Preorder(Non-REcursive)
7)Postorder(Non-REcursive)
8)Quit
Enter Your Choice :2
  1  2  4  5  3  6  7
 
1)Create
2)Preorder(recursive)
3)Inorder(recursive)
4)Postorder(Recursive)
5)Inorder(Non-Recursive)
6)Preorder(Non-REcursive)
7)Postorder(Non-REcursive)
8)Quit
Enter Your Choice :3
  4  2  5  1  6  3  7
 
1)Create
2)Preorder(recursive)
3)Inorder(recursive)
4)Postorder(Recursive)
5)Inorder(Non-Recursive)
6)Preorder(Non-REcursive)
7)Postorder(Non-REcursive)
8)Quit
Enter Your Choice :4
  4  5  2  6  7  3  1
 
1)Create
2)Preorder(recursive)
3)Inorder(recursive)
4)Postorder(Recursive)
5)Inorder(Non-Recursive)
6)Preorder(Non-REcursive)
7)Postorder(Non-REcursive)
8)Quit
Enter Your Choice :5
 
  4  2  5  1  6  3  7
 
1)Create
2)Preorder(recursive)
3)Inorder(recursive)
4)Postorder(Recursive)
5)Inorder(Non-Recursive)
6)Preorder(Non-REcursive)
7)Postorder(Non-REcursive)
8)Quit
Enter Your Choice :6
  1  2  4  5  3  6  7
 
1)Create
2)Preorder(recursive)
3)Inorder(recursive)
4)Postorder(Recursive)
5)Inorder(Non-Recursive)
6)Preorder(Non-REcursive)
7)Postorder(Non-REcursive)
8)Quit
Enter Your Choice :7
 
  4  5  2  6  7  3  1
 
1)Create
2)Preorder(recursive)
3)Inorder(recursive)
4)Postorder(Recursive)
5)Inorder(Non-Recursive)
6)Preorder(Non-REcursive)
7)Postorder(Non-REcursive)
8)Quit
Enter Your Choice :8
 



How to run Turbo c full screen in windows 7 without any software



I know u most aware with turbo c language.This compiler is easily full screened with XP.
But we can not use it in full screen in win 7 and win vista.
so we need software having name dosbox for that.but in this trick i will just give instruction how to make Turbo C in Full screen without any software

Steps :
Step 1 : go to c:/tc/bin and find tc.exe
Step 2 : Right click on tc.exe and go to properties
Step 3 : in the properties go to Screen Tab
Step 4 : in Screen tab u got option about Usage in that properties click on windows instead of Full screen.
Step 5 :after that run tc.exe, click ignore if ask (if not then do nothing) it will open it in normal small window.
Step 6 :right click on the border and go to properties.then move to fonts tab.
Step 7 : select lucida console and size 28


Enjoy


I know u most aware with turbo c language.This compiler is easily full screened with XP.
But we can not use it in full screen in win 7 and win vista.
so we need software having name dosbox for that.but in this trick i will just give instruction how to make Turbo C in Full screen without any software

Steps :
Step 1 : go to c:/tc/bin and find tc.exe
Step 2 : Right click on tc.exe and go to properties
Step 3 : in the properties go to Screen Tab
Step 4 : in Screen tab u got option about Usage in that properties click on windows instead of Full screen.
Step 5 :after that run tc.exe, click ignore if ask (if not then do nothing) it will open it in normal small window.
Step 6 :right click on the border and go to properties.then move to fonts tab.
Step 7 : select lucida console and size 28


Enjoy
Blogger Tips and TricksLatest Tips And TricksBlogger Tricks