commit bd0c8e9468bcd83e0ab6dab4fc29fe90e9b752f4 parent 02c08bf9443ae9e45836971a64255c52cd2e7032 Author: Amit Dutta <mail@amit.is-a.dev> Date: Wed, 24 Jun 2026 06:23:19 +0530 Merge pull request #10 from notamitgamer/edit added more algo Diffstat:
| A | semester_2/algorithms/algo_12.md | | | 37 | +++++++++++++++++++++++++++++++++++++ |
| A | semester_2/algorithms/algo_13.md | | | 26 | ++++++++++++++++++++++++++ |
2 files changed, 63 insertions(+), 0 deletions(-)
diff --git a/semester_2/algorithms/algo_12.md b/semester_2/algorithms/algo_12.md @@ -0,0 +1,36 @@ +# algo_12 + +### Problem Statement + +> Write an algorithm which remores the first element of a list and adds it to the end of the list without changing any values in INFO part. + +## Algorithm +``` +procedure ding(head) +begin + ptr ← head; + ptr2 ← head; + head ← next(head); + next(ptr) ← NULL; + while(next(ptr2) ≠ NULL) + ptr2 ← next(ptr2); + end while + next(ptr2) ← ptr; + return(head); +end procedure + +---------------------------- + +procedure dong(head) +begin + ptr ← head; + while(next(ptr) ≠ NULL) + ptr ← next(ptr); + end while + next(ptr) ← head; + p ← next(head); + next(head) ← NULL; + head ← p; + return(head); +end procedure +```+ \ No newline at end of file diff --git a/semester_2/algorithms/algo_13.md b/semester_2/algorithms/algo_13.md @@ -0,0 +1,25 @@ +# algo_13 + +### Problem Statement + +> Write an algorithm to print the elements of a singly linked list in reverse order. + +## Algorithm +``` +procedure reversePrint(head) +begin + ptr ← head; + stack ← createArray(10); + i ← 0; + while(ptr ≠ NULL) + stack[i] ← info(ptr); + i ← i + 1; + ptr ← next(ptr); + end while + write("Elements in reverse order: "); + while(i ≥ 0) + write(stack[i]); + i ← i - 1; + end while +end procedure +```+ \ No newline at end of file