bsc

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

commit 59c64963e312cc7981b3e7886dd5d0823f6c475a
parent e75c75096a018b55167fc92cd5a90776ba746b2e
Author: Amit Dutta <amitdutta4255@gmail.com>
Date:   Sat, 20 Jun 2026 21:01:31 +0530

fixed `Algorithms` → `algorithms`

Diffstat:
Mdocs/semester_2/index.md | 1+
Msemester_2/README.md | 1+
Asemester_2/algorithms/algo_01.md | 25+++++++++++++++++++++++++
Asemester_2/algorithms/algo_02.md | 21+++++++++++++++++++++
Asemester_2/algorithms/algo_03.md | 22++++++++++++++++++++++
Asemester_2/algorithms/algo_04.md | 24++++++++++++++++++++++++
Asemester_2/algorithms/algo_05.md | 27+++++++++++++++++++++++++++
Asemester_2/algorithms/algo_06.md | 29+++++++++++++++++++++++++++++
Asemester_2/algorithms/algo_07.md | 23+++++++++++++++++++++++
Asemester_2/algorithms/algo_08.md | 26++++++++++++++++++++++++++
10 files changed, 199 insertions(+), 0 deletions(-)

diff --git a/docs/semester_2/index.md b/docs/semester_2/index.md @@ -27,6 +27,7 @@ To keep the repository organized, the C++ and Python programs are divided into s ### C++ Programming (Data Structures) * **`/practice/`**: General, day-to-day CPP programming practice files. * **`/tuition/`**: Programs and problem-solving exercises completed during tuition classes. +* **`/algorithms/`**: Some algorithms. ### Python Programming (SEC) * **`/python/`**: Contains all SEC coursework, split into: * `/code/`: Python script files (`.py`) for practicals. diff --git a/semester_2/README.md b/semester_2/README.md @@ -17,6 +17,7 @@ To keep the repository organized, the C++ and Python programs are divided into s ### C++ Programming (Data Structures) * **`/practice/`**: General, day-to-day CPP programming practice files. * **`/tuition/`**: Programs and problem-solving exercises completed during tuition classes. +* **`/algorithms/`**: Some algorithms. ### Python Programming (SEC) * **`/python/`**: Contains all SEC coursework, split into: * `/code/`: Python script files (`.py`) for practicals. diff --git a/semester_2/algorithms/algo_01.md b/semester_2/algorithms/algo_01.md @@ -0,0 +1,24 @@ +# algo_01 + +### Problem Statement + +> Write an algorithm to insert a node at the beginning. + +## Algorithm +``` +procedure insert_begin(head) +begin + ptr ← get_node(); + print("Enter the value"); + read(val); + info(ptr) ← val; + next(ptr) ← NULL; + if(head = NULL) + head ← ptr; + else + next(ptr) ← head; + head ← ptr; + endif + return(head); +end procedure +```+ \ No newline at end of file diff --git a/semester_2/algorithms/algo_02.md b/semester_2/algorithms/algo_02.md @@ -0,0 +1,20 @@ +# algo_02 + +### Problem Statement + +> Write an algorithm to delete the first node of the list. + +## Algorithm +``` +procedure delete_firstNode(head) +begin + if(head = NULL) + write("List is empty, Deletion is not possible."); + else + p ← head ; + head ← next(p); + delete(p); + endif + return(head); +end procedure +```+ \ No newline at end of file diff --git a/semester_2/algorithms/algo_03.md b/semester_2/algorithms/algo_03.md @@ -0,0 +1,21 @@ +# algo_03 + +### Problem Statement + +> Write an algorithm to traverse a singly linked list. + +## Algorithm +``` +procedure traverce(head) +begin + if(head = NULL) + write("List is empty"); + else + ptr ← head; + while(ptr ≠ NULL) + write(info(ptr)); + ptr ← next(ptr); + end while + end if +end procedure +```+ \ No newline at end of file diff --git a/semester_2/algorithms/algo_04.md b/semester_2/algorithms/algo_04.md @@ -0,0 +1,23 @@ +# algo_04 + +### Problem Statement + +> Write an algorithm to count number of nodes in a singly linked list. + +## Algorithm +``` +procedure count(head) +begin + count = 0; + if(head = NULL) + write(count); + else + ptr ← head; + while(ptr ≠ NULL) + count ← count + 1; + ptr ← next(ptr); + end while + write(count); + endif +end procedure +```+ \ No newline at end of file diff --git a/semester_2/algorithms/algo_05.md b/semester_2/algorithms/algo_05.md @@ -0,0 +1,26 @@ +# algo_05 + +### Problem Statement + +> Write an algorithm to insert a node at the end of the list. + +## Algorithm +``` +procedure insertEnd(head) +begin + nptr ← getnode(); + write("Enter info: "); + read(val); + info(nptr) ← val; + if(head = NULL) + head ← nptr; + else + ptr ← head; + while(next(ptr) ≠ NULL) + ptr ← next(ptr); + end while + next(ptr) ← nptr; + endif + return(head); +end procedure +```+ \ No newline at end of file diff --git a/semester_2/algorithms/algo_06.md b/semester_2/algorithms/algo_06.md @@ -0,0 +1,28 @@ +# algo_06 + +### Problem Statement + +> Write an algorithm to delete the last node of the list. + +## Algorithm +``` +procedure deletelastnode(head) +begin + if(head = NULL) + write("List is empty, deletion not possible."); + else if(next(head) = NULL) + ptr ← head; + head ← next(ptr); + delete(ptr); + else + ptr ← head; + while(next(ptr) ≠ NULL) + prev ← ptr; + ptr ← next(ptr); + end while + delete(ptr); + next(prev) ← NULL; + endif + return(head); +end procedure +```+ \ No newline at end of file diff --git a/semester_2/algorithms/algo_07.md b/semester_2/algorithms/algo_07.md @@ -0,0 +1,22 @@ +# algo_07 + +### Problem Statement + +> Write an algorithm to search an element from a linked list. + +## Algorithm +``` +procedure search(head, key) +begin + isFound ← false; + ptr ← head; + while(ptr ≠ NULL) + if(info(ptr) = key) + isFound ← true; + break; + endif + ptr ← next(ptr); + end while + return(isFound); +end procedure +```+ \ No newline at end of file diff --git a/semester_2/algorithms/algo_08.md b/semester_2/algorithms/algo_08.md @@ -0,0 +1,25 @@ +# algo_08 + +### Problem Statement + +> Write an algorithm to find max element from the list. + +## Algorithm +``` +procedure findMax(head) +begin + if(head = NULL) + write("List is empty."); + else + ptr ← head; + max ← info(ptr); + while(ptr ≠ NULL) + if(max < info(ptr)) + max ← info(ptr); + endif + ptr ← next(ptr); + end while + return(max); + endif +end procedure +```+ \ No newline at end of file
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror