bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

commit b30384b98d7058086ffa0cce893aa81225ec1902
parent b63a3e78f8ed01846d83e55ac6c3f21ec1fe8b15
Author: Amit Dutta <mail@amit.is-a.dev>
Date:   Tue,  1 Sep 2026 20:12:09 +0530

Merge pull request #115 from notamitgamer/edit-20260901-201133

Changes from edit-20260901-201133
Diffstat:
Asemester_2/algorithms/algo_053.md | 17+++++++++++++++++
Asemester_2/algorithms/algo_054.md | 21+++++++++++++++++++++
Asemester_2/algorithms/algo_055.md | 17+++++++++++++++++
Asemester_2/algorithms/algo_056.md | 21+++++++++++++++++++++
Asemester_2/algorithms/algo_057.md | 19+++++++++++++++++++
Asemester_2/algorithms/algo_058.md | 22++++++++++++++++++++++
Asemester_2/algorithms/algo_059.md | 18++++++++++++++++++
Asemester_2/algorithms/algo_060.md | 21+++++++++++++++++++++
Asemester_2/algorithms/algo_061.md | 17+++++++++++++++++
Asemester_2/algorithms/algo_062.md | 33+++++++++++++++++++++++++++++++++
10 files changed, 206 insertions(+), 0 deletions(-)

diff --git a/semester_2/algorithms/algo_053.md b/semester_2/algorithms/algo_053.md @@ -0,0 +1,17 @@ +# algo_053 + +### Problem Statement + +> Write a recursive algorithm to find the minimum element from a Binary Search Tree (BST). + +## Algorithm +``` +procedure findMinBST(T) +begin + if (T = NULL or LC(T) = NULL) then + return T; + else + return findMinBST(LC(T)); + endif +end procedure +``` diff --git a/semester_2/algorithms/algo_054.md b/semester_2/algorithms/algo_054.md @@ -0,0 +1,21 @@ +# algo_054 + +### Problem Statement + +> Write a non-recursive algorithm to find the minimum element from a Binary Search Tree (BST). + +## Algorithm +``` +procedure findMin(T) +begin + ptr ← T; + if (ptr = NULL) then + return -1; + else + while (LC(ptr) ≠ NULL) do + ptr ← LC(ptr); + endwhile + return INFO(ptr); + endif +end procedure +``` diff --git a/semester_2/algorithms/algo_055.md b/semester_2/algorithms/algo_055.md @@ -0,0 +1,17 @@ +# algo_055 + +### Problem Statement + +> Write a recursive algorithm to find the maximum element from a Binary Search Tree (BST). + +## Algorithm +``` +procedure findMax(T) +begin + if (T = NULL or RC(T) = NULL) then + return T; + else + return findMax(RC(T)); + endif +end procedure +``` diff --git a/semester_2/algorithms/algo_056.md b/semester_2/algorithms/algo_056.md @@ -0,0 +1,21 @@ +# algo_056 + +### Problem Statement + +> Write a non-recursive algorithm to find the maximum element from a Binary Search Tree (BST). + +## Algorithm +``` +procedure findMax(T) +begin + ptr ← T; + if (ptr = NULL) then + return -1; + else + while (RC(ptr) ≠ NULL) do + ptr ← RC(ptr); + endwhile + return INFO(ptr); + endif +end procedure +``` diff --git a/semester_2/algorithms/algo_057.md b/semester_2/algorithms/algo_057.md @@ -0,0 +1,19 @@ +# algo_057 + +### Problem Statement + +> Write a recursive algorithm to search an element in a Binary Search Tree (BST). + +## Algorithm +``` +procedure search(T, key) +begin + if (T = NULL or INFO(T) = key) then + return T; + else if (key < INFO(T)) then + return search(LC(T), key); + else + return search(RC(T), key); + endif +end procedure +``` diff --git a/semester_2/algorithms/algo_058.md b/semester_2/algorithms/algo_058.md @@ -0,0 +1,22 @@ +# algo_058 + +### Problem Statement + +> Write a non-recursive algorithm to search an element in a Binary Search Tree (BST). + +## Algorithm +``` +procedure search(T, key) +begin + while (T ≠ NULL) do + if (INFO(T) = key) then + return T; + else if (key < INFO(T)) then + T ← LC(T); + else + T ← RC(T); + endif + endwhile + return NULL; +end procedure +``` diff --git a/semester_2/algorithms/algo_059.md b/semester_2/algorithms/algo_059.md @@ -0,0 +1,18 @@ +# algo_059 + +### Problem Statement + +> Write an algorithm to find the inorder successor of a node in a Binary Search Tree (BST). + +## Algorithm +``` +procedure inorderSuccessor(ptr) +begin + /* Finds the leftmost node of the right subtree */ + p ← RC(ptr); + while (LC(p) ≠ NULL) do + p ← LC(p); + endwhile + return p; +end procedure +``` diff --git a/semester_2/algorithms/algo_060.md b/semester_2/algorithms/algo_060.md @@ -0,0 +1,21 @@ +# algo_060 + +### Problem Statement + +> Write an algorithm to check whether two given binary trees are identical or not. + +## Algorithm +``` +procedure identicalTree(T1, T2) +begin + /* T1 and T2 hold the base addresses of the trees */ + if (T1 = NULL and T2 = NULL) then + return true; + endif + if (T1 = NULL or T2 = NULL) then + return false; + else + return ((INFO(T1) = INFO(T2)) and identicalTree(LC(T1), LC(T2)) and identicalTree(RC(T1), RC(T2))); + endif +end procedure +``` diff --git a/semester_2/algorithms/algo_061.md b/semester_2/algorithms/algo_061.md @@ -0,0 +1,17 @@ +# algo_061 + +### Problem Statement + +> Write an algorithm for finding the inorder successor helper node (`ins`) used in BST node deletion. + +## Algorithm +``` +procedure ins(root) +begin + ptr ← RC(root); + while (LC(ptr) ≠ NULL) do + ptr ← LC(ptr); + endwhile + return ptr; +end procedure +``` diff --git a/semester_2/algorithms/algo_062.md b/semester_2/algorithms/algo_062.md @@ -0,0 +1,33 @@ +# algo_062 + +### Problem Statement + +> Write an algorithm to delete a node from a Binary Search Tree (BST). + +## Algorithm +``` +procedure deleteNode(root, key) +begin + if (root = NULL) then + return root; + else if (key < INFO(root)) then + LC(root) ← deleteNode(LC(root), key); + else if (key > INFO(root)) then + RC(root) ← deleteNode(RC(root), key); + else + if (LC(root) = NULL) then + temp ← RC(root); + free(root); + return temp; + else if (RC(root) = NULL) then + temp ← LC(root); + free(root); + return temp; + endif + temp ← ins(root); + INFO(root) ← INFO(temp); + RC(root) ← deleteNode(RC(root), INFO(temp)); + endif + return root; +end procedure +```
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror