Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions Binary_Tree
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
A binary tree is a structure comprising nodes, where each node has the following 3 components:
//A binary tree is a structure comprising nodes, where each node has the following 3 components:

Data element: Stores any kind of data in the node
Left pointer: Points to the tree on the left side of node
Right pointer: Points to the tree on the right side of the node
// Data element: Stores any kind of data in the node
// Left pointer: Points to the tree on the left side of node
//// Right pointer: Points to the tree on the right side of the node

As the name suggests, the data element stores any kind of data in the node.
The left and right pointers point to binary trees on the left and right side of the node respectively.
//As the name suggests, the data element stores any kind of data in the node.
//The left and right pointers point to binary trees on the left and right side of the node respectively.

If a tree is empty, it is represented by a null pointer.
//If a tree is empty, it is represented by a null pointer.

The following image explains the various components of a tree.
//The following image explains the various components of a tree.

enter image description here
//enter image description here

Commonly-used terminologies
//Commonly-used terminologies

Root: Top node in a tree
Child: Nodes that are next to each other and connected downwards
Parent: Converse notion of child
Siblings: Nodes with the same parent
Descendant: Node reachable by repeated proceeding from parent to child
Ancestor: Node reachable by repeated proceeding from child to parent.
Leaf: Node with no children
Internal node: Node with at least one child
External node: Node with no children
// Root: Top node in a tree
// Child: Nodes that are next to each other and connected downwards
// Parent: Converse notion of child
// Siblings: Nodes with the same parent
// Descendant: Node reachable by repeated proceeding from parent to child
// Ancestor: Node reachable by repeated proceeding from child to parent.
// Leaf: Node with no children
// Internal node: Node with at least one child
// External node: Node with no children

Structure code of a tree node
//Structure code of a tree node

In programming, trees are declared as follows:
//In programming, trees are declared as follows:

struct node
{
Expand Down
1 change: 1 addition & 0 deletions DFS_Graphs_using_adjacency_list
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//dfs of a graph complexity o(V+E)
//Algorithm
#include<bits/stdc++.h>
using namespace std;
//Adjacency list and visited list
Expand Down
1 change: 1 addition & 0 deletions Island_Using_DFS.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//Imp Algorithm
#include <iostream>
#include <vector>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

IMP Algorithm
Top 10 Algorithms and Data Structures for Competitive Programming

In this post “Important top 10 algorithms and data structures for competitive coding “.
Expand Down
1 change: 1 addition & 0 deletions Tree_DFS_Pre_Post_In_Order_Traversal.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
Algorithm
Time complexity : o(n)
Space complexity : Best,average case -> o(log(n)) & Worst -> o(n)
*/
Expand Down
1 change: 1 addition & 0 deletions Tree_Traversal_levelorder.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
Imp Algorithm
Time complexity : o(n)
Space complexity : Best -> o(1) & Worst -> o(n)
*/
Expand Down