my_obsidian

git clone https://github.com/notamitgamer/my_obsidian.git
· rebuilt hourlyOpen on GitHub
commit 02a4b5cf9cc097fc38cf7a7ff0f6b880a113b9b7
parent e6f2bad6c1545f97a8c14eab6ec7539f7032ae42
Author: Amit Dutta <mail@amit.is-a.dev>
Date:   Wed, 23 Sep 2026 21:13:30 +0530

updated

Diffstat:
M.obsidian/plugins/advanced-pdf-export/data.json | 171++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
M.obsidian/workspace.json | 3++-
APasted image 20260923205641.png | 0
APasted image 20260923205948.png | 0
Massignment.md | 343+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
5 files changed, 491 insertions(+), 26 deletions(-)

diff --git a/.obsidian/plugins/advanced-pdf-export/data.json b/.obsidian/plugins/advanced-pdf-export/data.json @@ -74,5 +74,174 @@ "backgroundImageScope": "full-page", "backgroundImageOpacity": 1, "includeOutline": true, - "presetSnapshots": {} + "presetSnapshots": { + "default": { + "name": "Default", + "fontFamily": "Georgia, serif", + "fontSize": 14, + "lineHeight": 1.4, + "paragraphSpacing": 0.65, + "headingScale": 1, + "accentColor": "#000000", + "bodyColor": "#1a1a2e", + "boldColor": "#1a1a2e", + "headingColor": "#0d0d1a", + "h1BorderBottom": false, + "h2BorderBottom": true, + "centerH1": false, + "blockquoteBg": "transparent", + "blockquoteBorderColor": "#000000", + "codeBackground": "#f0f0f8", + "codeFontSize": 0.85, + "codeFontFamily": "'JetBrains Mono', monospace", + "codeTheme": "github-light", + "tableHeaderBg": "#f0f0f8", + "tableStriped": true, + "pageBackground": "#ffffff", + "marginTop": 15, + "marginBottom": 15, + "marginLeft": 18, + "marginRight": 15 + }, + "minimal": { + "name": "Minimal", + "fontFamily": "'Helvetica Neue', Helvetica, sans-serif", + "fontSize": 12, + "lineHeight": 1.6, + "paragraphSpacing": 0.45, + "headingScale": 0.88, + "accentColor": "#333", + "bodyColor": "#222", + "boldColor": "#222", + "headingColor": "#111", + "h1BorderBottom": false, + "h2BorderBottom": false, + "centerH1": false, + "blockquoteBg": "#f8f8f8", + "blockquoteBorderColor": "#ccc", + "codeBackground": "#f4f4f4", + "codeFontSize": 0.82, + "codeFontFamily": "'Courier New', monospace", + "codeTheme": "none", + "tableHeaderBg": "#efefef", + "tableStriped": false, + "pageBackground": "#ffffff", + "marginTop": 16, + "marginBottom": 16, + "marginLeft": 20, + "marginRight": 20 + }, + "academic": { + "name": "Academic", + "fontFamily": "'Times New Roman', Times, serif", + "fontSize": 12, + "lineHeight": 2, + "paragraphSpacing": 0, + "headingScale": 0.95, + "accentColor": "#1a3a6b", + "bodyColor": "#000", + "boldColor": "#000", + "headingColor": "#000", + "h1BorderBottom": true, + "h2BorderBottom": true, + "centerH1": true, + "blockquoteBg": "transparent", + "blockquoteBorderColor": "#999", + "codeBackground": "#f9f9f9", + "codeFontSize": 0.88, + "codeFontFamily": "'Courier New', monospace", + "codeTheme": "solarized-light", + "tableHeaderBg": "#e8e8e8", + "tableStriped": false, + "pageBackground": "#ffffff", + "marginTop": 25, + "marginBottom": 25, + "marginLeft": 30, + "marginRight": 30 + }, + "modern": { + "name": "Modern", + "fontFamily": "Arial, sans-serif", + "fontSize": 13, + "lineHeight": 1.75, + "paragraphSpacing": 0.6, + "headingScale": 1, + "accentColor": "#0070f3", + "bodyColor": "#111", + "boldColor": "#111", + "headingColor": "#000", + "h1BorderBottom": false, + "h2BorderBottom": false, + "centerH1": false, + "blockquoteBg": "#f0f7ff", + "blockquoteBorderColor": "#0070f3", + "codeBackground": "#f1f5f9", + "codeFontSize": 0.85, + "codeFontFamily": "'Courier New', monospace", + "codeTheme": "github-dark", + "tableHeaderBg": "#0070f3", + "tableStriped": true, + "pageBackground": "#ffffff", + "marginTop": 20, + "marginBottom": 20, + "marginLeft": 25, + "marginRight": 25 + }, + "newspaper": { + "name": "Newspaper", + "fontFamily": "Georgia, serif", + "fontSize": 12, + "lineHeight": 1.7, + "paragraphSpacing": 0.4, + "headingScale": 1.1, + "accentColor": "#111", + "bodyColor": "#111", + "boldColor": "#111", + "headingColor": "#000", + "h1BorderBottom": true, + "h2BorderBottom": true, + "centerH1": true, + "blockquoteBg": "transparent", + "blockquoteBorderColor": "#111", + "codeBackground": "#f4f4f4", + "codeFontSize": 0.82, + "codeFontFamily": "'Courier New', monospace", + "codeTheme": "none", + "tableHeaderBg": "#111", + "tableStriped": false, + "pageBackground": "#ffffff", + "marginTop": 18, + "marginBottom": 18, + "marginLeft": 20, + "marginRight": 20 + }, + "dark": { + "name": "Dark", + "fontFamily": "Georgia, serif", + "fontSize": 13, + "lineHeight": 1.85, + "paragraphSpacing": 0.65, + "headingScale": 1, + "accentColor": "#818cf8", + "bodyColor": "#d1d5db", + "boldColor": "#d1d5db", + "headingColor": "#f1f5f9", + "h1BorderBottom": false, + "h2BorderBottom": true, + "centerH1": false, + "blockquoteBg": "#1e293b", + "blockquoteBorderColor": "#818cf8", + "codeBackground": "#0f172a", + "codeFontSize": 0.85, + "codeFontFamily": "'Courier New', monospace", + "codeTheme": "tokyo-night", + "tableHeaderBg": "#1e293b", + "tableStriped": true, + "pageBackground": "#111827", + "marginTop": 20, + "marginBottom": 20, + "marginLeft": 25, + "marginRight": 25 + } + } } \ No newline at end of file diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json @@ -190,6 +190,8 @@ }, "active": "97517fce08066ce5", "lastOpenFiles": [ + "Pasted image 20260923205948.png", + "Pasted image 20260923205641.png", "main", "Pasted image 20260923203343.png", "Pasted image 20260923203309.png", @@ -200,7 +202,6 @@ "Pasted image 20260923195210.png", "Pasted image 20260923194003.png", "Pasted image 20260923193206.png", - "Pasted image 20260923192749.png", "assignment.md", "create a link.md", "Welcome.md", diff --git a/Pasted image 20260923205641.png b/Pasted image 20260923205641.png Binary files differ. diff --git a/Pasted image 20260923205948.png b/Pasted image 20260923205948.png Binary files differ. diff --git a/assignment.md b/assignment.md @@ -2,25 +2,25 @@ | Serial No. | Problem Statement | Page No. | Teacher's Signature | | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------- | -| 1 | Write a program to implement a Diagonal Matrix, a Lower Triangular Matrix, an Upper Triangular Matrix, and a Symmetric Matrix using a one-dimensional array. | | | -| 2 | Write a program to search an element from a list. Give user the option to perform Linear or Binary search. | | | -| 3 | WAP to sort a list of elements. Give user the option to perform sorting using Insertion sort, Bubble sort or Selection sort. | | | -| 4 | Implement Linked List. Include functions for insertion, deletion and search of a number, reverse the list and concatenate two linked lists (include a function and also overload operator +). | | | -| 5 | Implement Doubly Linked List. Include functions for insertion, deletion and search of a number, reverse the list. | | | -| 6 | Implement Circular Linked List. Include functions for insertion, deletion and search of a number, reverse the list. | | | -| 7 | Perform Stack operations using Linked List implementation. | | | -| 8 | Perform Stack operations using Array implementation. | | | -| 9 | Perform Queues operations using Array. | | | -| 10 | Perform Circular Queues operations using Array. | | | -| 11 | Perform Queues operations using linklist. | | | -| 12 | Create and perform different operations on Double-ended Queues using Linked List implementation. | | | -| 13 | WAP to scan a polynomial using linked list and add two polynomials. | | | -| 14 | WAP to calculate factorial and to compute the factors of a given no. (i) using recursion, (ii) using iteration. | | | -| 15 | WAP to display Fibonacci series (i) using recursion, (ii) using iteration. | | | -| 16 | WAP to create a Binary Search Tree and include following operations in tree: i. Insertion (Recursive and Iterative Implementation) ii. Deletion by copying iii. Deletion by Merging iv. Search a no. in BST v. Display its preorder, postorder and inorder traversals Recursively vi. Display its preorder, postorder and inorder traversals Iteratively vii. Display its level-by-level traversals viii. Count the non-leaf nodes and leaf nodes ix. Display height of tree x. Create a mirror image of tree xi. Check whether two BSTs are equal or not | | | -| 17 | WAP to convert the Sparse Matrix into non-zero form and vice-versa. | | | -| 18 | WAP to reverse the order of the elements in the stack using additional stack. | | | -| 19 | WAP to reverse the order of the elements in the stack using additional Queue. | | | +| 1 | Write a program to implement a Diagonal Matrix, a Lower Triangular Matrix, an Upper Triangular Matrix, and a Symmetric Matrix using a one-dimensional array. | 2 | | +| 2 | Write a program to search an element from a list. Give user the option to perform Linear or Binary search. | 9 | | +| 3 | WAP to sort a list of elements. Give user the option to perform sorting using Insertion sort, Bubble sort or Selection sort. | 15 | | +| 4 | Implement Linked List. Include functions for insertion, deletion and search of a number, reverse the list and concatenate two linked lists (include a function and also overload operator +). | 21 | | +| 5 | Implement Doubly Linked List. Include functions for insertion, deletion and search of a number, reverse the list. | 31 | | +| 6 | Implement Circular Linked List. Include functions for insertion, deletion and search of a number, reverse the list. | 40 | | +| 7 | Perform Stack operations using Linked List implementation. | 50 | | +| 8 | Perform Stack operations using Array implementation. | 55 | | +| 9 | Perform Queues operations using Array. | 59 | | +| 10 | Perform Circular Queues operations using Array. | 64 | | +| 11 | Perform Queues operations using linklist. | 69 | | +| 12 | Create and perform different operations on Double-ended Queues using Linked List implementation. | 73 | | +| 13 | WAP to scan a polynomial using linked list and add two polynomials. | 79 | | +| 14 | WAP to calculate factorial and to compute the factors of a given no. (i) using recursion, (ii) using iteration. | 85 | | +| 15 | WAP to display Fibonacci series (i) using recursion, (ii) using iteration. | 89 | | +| 16 | WAP to create a Binary Search Tree and include following operations in tree: i. Insertion (Recursive and Iterative Implementation) ii. Deletion by copying iii. Deletion by Merging iv. Search a no. in BST v. Display its preorder, postorder and inorder traversals Recursively vi. Display its preorder, postorder and inorder traversals Iteratively vii. Display its level-by-level traversals viii. Count the non-leaf nodes and leaf nodes ix. Display height of tree x. Create a mirror image of tree xi. Check whether two BSTs are equal or not | 92 | | +| 17 | WAP to convert the Sparse Matrix into non-zero form and vice-versa. | 110 | | +| 18 | WAP to reverse the order of the elements in the stack using additional stack. | 116 | | +| 19 | WAP to reverse the order of the elements in the stack using additional Queue. | 120 | | /// ## Assignment 1 @@ -724,9 +724,10 @@ int main() { ``` ### Output: -![[Pasted image 20260922133021.png|469]] - -![[Pasted image 20260922102559.png|472]] +![[Pasted image 20260922133021.png|522]] +<p align="right">Continue to next page...</p> +/// +![[Pasted image 20260922102559.png|521]] ### Discussion: - **insertionSort()** rebuilds the array from `arr` via `reset()`, then repeatedly takes an element (`key`) and shifts larger elements in the sorted left portion rightward until it finds the correct spot to insert the key. - **bubbleSort()** makes repeated passes, swapping adjacent out-of-order elements; a `swapped` flag lets it exit early once a pass makes no swaps, avoiding unnecessary iterations on an already-sorted array. @@ -1121,10 +1122,10 @@ int main() { ``` ### Output: -![[Pasted image 20260922135426.png|536]] +![[Pasted image 20260922135426.png|564]] <p align="right" >Continue to next page...</p> /// -![[Pasted image 20260922135454.png|534]] +![[Pasted image 20260922135454.png|561]] ### Discussion: - **insertAtBegin/insertAtEnd/insertAtPos** create a new node and link it into the chain — at the head, by traversing to the last node, or by traversing to the node just before the target position. - **deleteAtBegin/deleteAtEnd/deleteAtPos** unlink a node by redirecting the previous node's `next` pointer around it before freeing it, with edge cases handled for an empty list or a single-node list. @@ -4369,3 +4370,297 @@ int main() { - **convertToStandard()** reads the dimensions and count from row 0 of the triplet array, allocates a zero-filled 2D matrix, and places each stored value at its recorded row and column. /// +## Assignment 18 +### Problem Statement: +WAP to reverse the order of the elements in the stack using additional stack. +### Problem Defination: +Reversing a **Stack** means making the bottom element the new top and vice versa. This can be achieved using two **auxiliary stacks**: elements are popped off the original stack and pushed twice across two helper stacks, which reverses the order twice and restores the elements to the original stack in reversed order. + +### Algorithm: +**Reverse Stack Using Additional Stacks:** +``` +procedure reverseUsingAdditionalStacks(S, capacity) +begin + if(isEmpty(S)) + print "Stack is empty! Nothing to reverse."; + return; + end if + + initialize stack S1 of capacity; + initialize stack S2 of capacity; + + while(not isEmpty(S)) do + val ← pop(S); + push(S1, val); + end while + + while(not isEmpty(S1)) do + val ← pop(S1); + push(S2, val); + end while + + while(not isEmpty(S2)) do + val ← pop(S2); + push(S, val); + end while +end procedure +``` + +### Source Code: +``` +#include <iostream> +using namespace std; + +class Stack { +private: + int *arr; + int top; + int capacity; + +public: + Stack(int size) { + capacity = size; + arr = new int[capacity]; + top = -1; + } + + // Disable copy constructor and assignment operator + Stack(const Stack&) = delete; + Stack& operator=(const Stack&) = delete; + + bool isFull() const { return (top == capacity - 1); } + bool isEmpty() const { return (top == -1); } + + void push(int val) { + if (isFull()) { cout << "Stack Overflow!\n"; return; } + arr[++top] = val; + } + + int pop() { + if (isEmpty()) { cout << "Stack Underflow!\n"; return -1; } + return arr[top--]; + } + + void display() const { + if (isEmpty()) { cout << "Stack is empty!\n"; return; } + for (int i = top; i >= 0; i--) cout << arr[i] << " "; + cout << endl; + } + + void reverseUsingAdditionalStacks() { + if (isEmpty()) { cout << "Stack is empty! Nothing to reverse.\n"; return; } + + Stack s1(capacity); + Stack s2(capacity); + + while (!isEmpty()) s1.push(pop()); + while (!s1.isEmpty()) s2.push(s1.pop()); + while (!s2.isEmpty()) push(s2.pop()); + } + + ~Stack() { delete[] arr; } +}; + +int main() { + int size, choice, val; + cout << "Enter the capacity of the stack: "; + cin >> size; + if (size <= 0) { cout << "Invalid stack size!\n"; return 0; } + + Stack s(size); + + while (true) { + cout << "1.push 2.pop 3.reverse 0.display -1.Exit\n"; + cout << "Enter your choice: "; + cin >> choice; + + switch (choice) { + case 1: + cout << "Enter value: "; + cin >> val; + s.push(val); + break; + case 2: { + int v = s.pop(); + if (v != -1) cout << "Popped element: " << v << endl; + break; + } + case 3: + s.reverseUsingAdditionalStacks(); + cout << "Stack reversed.\n"; // Added feedback + break; + case 0: + s.display(); + break; + case -1: + cout << "Exiting...\n"; + return 0; + default: + cout << "Wrong choice.\n"; + } + } +} +``` +/// +### Output: +![[Pasted image 20260923205641.png]] + +### Discussion: +- **reverseUsingAdditionalStacks()** empties the original stack into `s1` (reversing the order once), then transfers `s1` into `s2` (reversing it again), then pushes `s2`'s elements back into the original stack, leaving it in reversed order. + +/// +## Assignment 19 +### Problem Statement: +WAP to reverse the order of the elements in the stack using additional Queue. +### Problem Defination: +Reversing a **Stack** using an auxiliary **Queue** exploits the FIFO order of a queue: elements popped off the stack (in top-to-bottom order) are enqueued, and dequeuing them back (in the same order they were enqueued) and pushing them onto the stack reverses the original arrangement. +### Algorithm: +**Reverse Stack Using Additional Queue:** +``` +procedure reverseUsingQueue(S, capacity) +begin + if(isEmpty(S)) + print "Stack is empty! Nothing to reverse."; + return; + end if + + initialize queue Q of capacity; + + while(not isEmpty(S)) do + val ← pop(S); + enqueue(Q, val); + end while + + while(not isEmpty(Q)) do + val ← dequeue(Q); + push(S, val); + end while +end procedure +``` +### Source Code: +``` +#include <iostream> +using namespace std; + +class Queue { +private: + int *arr; + int front; + int rear; + int capacity; + +public: + Queue(int size) { + capacity = size; + arr = new int[capacity]; + front = -1; + rear = -1; + } + + bool isEmpty() { return (front == -1 || front > rear); } + bool isFull() { return (rear == capacity - 1); } + + void enqueue(int val) { + if (isFull()) return; + if (front == -1) front = 0; + arr[++rear] = val; + } + + int dequeue() { + if (isEmpty()) return -1; + int val = arr[front++]; + if (front > rear) { front = -1; rear = -1; } + return val; + } + + ~Queue() { delete[] arr; } +}; + +class Stack { +private: + int *arr; + int top; + int capacity; + +public: + Stack(int size) { + capacity = size; + arr = new int[capacity]; + top = -1; + } + + bool isFull() { return (top == capacity - 1); } + bool isEmpty() { return (top == -1); } + + void push(int val) { + if (isFull()) { cout << "Stack Overflow!\n"; return; } + arr[++top] = val; + } + + int pop() { + if (isEmpty()) { cout << "Stack Underflow!\n"; return -1; } + return arr[top--]; + } + + void display() { + if (isEmpty()) { cout << "Stack is empty!\n"; return; } + for (int i = top; i >= 0; i--) cout << arr[i] << " "; + cout << endl; + } + + void reverseUsingQueue() { + if (isEmpty()) { cout << "Stack is empty! Nothing to reverse.\n"; return; } + + Queue q(capacity); + while (!isEmpty()) q.enqueue(pop()); + while (!q.isEmpty()) push(q.dequeue()); + } + + ~Stack() { delete[] arr; } +}; + +int main() { + int size, choice, val; + cout << "Enter the capacity of the stack: "; + cin >> size; + if (size <= 0) { cout << "Invalid stack size!\n"; return 0; } + + Stack s(size); + + while (true) { + cout << "1.push 2.pop 3.reverse 0.display -1.Exit\n"; + cout << "Enter your choice: "; + cin >> choice; + + switch (choice) { + case 1: + cout << "Enter value: "; + cin >> val; + s.push(val); + break; + case 2: { + int v = s.pop(); + if (v != -1) cout << "Popped element: " << v << endl; + break; + } + case 3: + s.reverseUsingQueue(); + break; + case 0: + s.display(); + break; + case -1: + cout << "Exiting...\n"; + return 0; + default: + cout << "Wrong choice.\n"; + } + } +} +``` + +### Output: +![[Pasted image 20260923205948.png|510]] +/// +### Discussion: +- **reverseUsingQueue()** dequeues elements from the stack and enqueues them into a queue in top-to-bottom order, then dequeues them from the queue (same order) and pushes them back onto the stack, producing the reversed arrangement.