From 44df989aeb6ccabef1271472c2f647ecb4e7bba2 Mon Sep 17 00:00:00 2001
From: dhruvil15 <76967484+dhruvil15@users.noreply.github.com>
Date: Mon, 6 Apr 2026 20:35:18 -0400
Subject: [PATCH] Complete PreCourse-2
---
.idea/.gitignore | 8 ++
.idea/misc.xml | 6 +
.idea/modules.xml | 8 ++
.idea/vcs.xml | 6 +
Exercise_1.java | 27 ++++-
Exercise_2.java | 103 +++++++++-------
Exercise_3.java | 106 +++++++++--------
Exercise_4.java | 112 +++++++++++-------
Exercise_5.java | 103 ++++++++++------
PreCourse-2.iml | 11 ++
out/production/PreCourse-2/.idea/.gitignore | 8 ++
out/production/PreCourse-2/.idea/misc.xml | 6 +
out/production/PreCourse-2/.idea/modules.xml | 8 ++
out/production/PreCourse-2/.idea/vcs.xml | 6 +
out/production/PreCourse-2/BinarySearch.class | Bin 0 -> 1507 bytes
out/production/PreCourse-2/Exercise_1.cpp | 21 ++++
out/production/PreCourse-2/Exercise_1.js | 16 +++
out/production/PreCourse-2/Exercise_1.py | 22 ++++
out/production/PreCourse-2/Exercise_2.cpp | 47 ++++++++
out/production/PreCourse-2/Exercise_2.js | 41 +++++++
out/production/PreCourse-2/Exercise_2.py | 23 ++++
out/production/PreCourse-2/Exercise_3.cpp | 50 ++++++++
out/production/PreCourse-2/Exercise_3.js | 43 +++++++
out/production/PreCourse-2/Exercise_3.py | 26 ++++
out/production/PreCourse-2/Exercise_4.cpp | 43 +++++++
out/production/PreCourse-2/Exercise_4.js | 34 ++++++
out/production/PreCourse-2/Exercise_4.py | 18 +++
out/production/PreCourse-2/Exercise_5.cpp | 42 +++++++
out/production/PreCourse-2/Exercise_5.js | 36 ++++++
out/production/PreCourse-2/Exercise_5.py | 10 ++
.../PreCourse-2/IterativeQuickSort.class | Bin 0 -> 2432 bytes
.../PreCourse-2/LinkedList$Node.class | Bin 0 -> 515 bytes
out/production/PreCourse-2/LinkedList.class | Bin 0 -> 1859 bytes
out/production/PreCourse-2/MergeSort.class | Bin 0 -> 2108 bytes
out/production/PreCourse-2/PreCourse-2.iml | 11 ++
out/production/PreCourse-2/QuickSort.class | Bin 0 -> 1966 bytes
out/production/PreCourse-2/README.md | 15 +++
37 files changed, 845 insertions(+), 171 deletions(-)
create mode 100644 .idea/.gitignore
create mode 100644 .idea/misc.xml
create mode 100644 .idea/modules.xml
create mode 100644 .idea/vcs.xml
create mode 100644 PreCourse-2.iml
create mode 100644 out/production/PreCourse-2/.idea/.gitignore
create mode 100644 out/production/PreCourse-2/.idea/misc.xml
create mode 100644 out/production/PreCourse-2/.idea/modules.xml
create mode 100644 out/production/PreCourse-2/.idea/vcs.xml
create mode 100644 out/production/PreCourse-2/BinarySearch.class
create mode 100644 out/production/PreCourse-2/Exercise_1.cpp
create mode 100644 out/production/PreCourse-2/Exercise_1.js
create mode 100644 out/production/PreCourse-2/Exercise_1.py
create mode 100644 out/production/PreCourse-2/Exercise_2.cpp
create mode 100644 out/production/PreCourse-2/Exercise_2.js
create mode 100644 out/production/PreCourse-2/Exercise_2.py
create mode 100644 out/production/PreCourse-2/Exercise_3.cpp
create mode 100644 out/production/PreCourse-2/Exercise_3.js
create mode 100644 out/production/PreCourse-2/Exercise_3.py
create mode 100644 out/production/PreCourse-2/Exercise_4.cpp
create mode 100644 out/production/PreCourse-2/Exercise_4.js
create mode 100644 out/production/PreCourse-2/Exercise_4.py
create mode 100644 out/production/PreCourse-2/Exercise_5.cpp
create mode 100644 out/production/PreCourse-2/Exercise_5.js
create mode 100644 out/production/PreCourse-2/Exercise_5.py
create mode 100644 out/production/PreCourse-2/IterativeQuickSort.class
create mode 100644 out/production/PreCourse-2/LinkedList$Node.class
create mode 100644 out/production/PreCourse-2/LinkedList.class
create mode 100644 out/production/PreCourse-2/MergeSort.class
create mode 100644 out/production/PreCourse-2/PreCourse-2.iml
create mode 100644 out/production/PreCourse-2/QuickSort.class
create mode 100644 out/production/PreCourse-2/README.md
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 00000000..13566b81
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 00000000..bcb5da6c
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 00000000..1039bae9
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000..35eb1ddf
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Exercise_1.java b/Exercise_1.java
index c3ff1141..23005e52 100644
--- a/Exercise_1.java
+++ b/Exercise_1.java
@@ -1,8 +1,29 @@
-class BinarySearch {
+// Time Complexity: O(log N)
+// Space Complexity: O(log N) -> due to using recursion
+
+class BinarySearch {
// Returns index of x if it is present in arr[l.. r], else return -1
int binarySearch(int arr[], int l, int r, int x)
- {
- //Write your code here
+ {
+ // only work if the arr is sorted
+ if (r >= l) {
+ //get the mid
+ int mid = l + (r -l)/2;
+
+ // if the value is in the middle return it
+ if (arr[mid] == x) {
+ return mid;
+ }
+
+ // if the value of the mid element is greater than the value x then only look at the left half
+ if (arr[mid] > x) {
+ return binarySearch(arr, l, mid - 1, x);
+ }
+
+ // the only remaining scenario where the value of x is greater than the mid element
+ return binarySearch(arr, mid+1, r, x);
+ }
+ return -1;
}
// Driver method to test above
diff --git a/Exercise_2.java b/Exercise_2.java
index d0b5fa5f..918d7e30 100644
--- a/Exercise_2.java
+++ b/Exercise_2.java
@@ -1,48 +1,65 @@
-class QuickSort
-{
- /* This function takes last element as pivot,
- places the pivot element at its correct
- position in sorted array, and places all
- smaller (smaller than pivot) to left of
- pivot and all greater elements to right
+// Time Complexity: O(N log N) -> Pivot splitting the array into halves
+// Space Complexity: O(log N)
+
+class QuickSort
+{
+ /* This function takes last element as pivot,
+ places the pivot element at its correct
+ position in sorted array, and places all
+ smaller (smaller than pivot) to left of
+ pivot and all greater elements to right
of pivot */
void swap(int arr[],int i,int j){
- //Your code here
+ int temp = arr[i];
+ arr[i] = arr[j];
+ arr[j] = temp;
}
-
- int partition(int arr[], int low, int high)
- {
- //Write code here for Partition and Swap
- }
- /* The main function that implements QuickSort()
- arr[] --> Array to be sorted,
- low --> Starting index,
+
+ int partition(int arr[], int low, int high)
+ {
+ int pivot = arr[high];
+ int index = low - 1;
+ for (int j = low; j <= high-1; j++){
+ if (arr[j] < pivot) {
+ index++;
+ swap(arr, index, j);
+ }
+ }
+ swap(arr, index + 1, high);
+ return index+1;
+ }
+ /* The main function that implements QuickSort()
+ arr[] --> Array to be sorted,
+ low --> Starting index,
high --> Ending index */
- void sort(int arr[], int low, int high)
- {
- // Recursively sort elements before
- // partition and after partition
- }
-
+ void sort(int arr[], int low, int high)
+ {
+ if (low < high) {
+ int pivotIndex = partition(arr, low, high);
+ sort(arr, low, pivotIndex - 1);
+ sort(arr, pivotIndex + 1, high);
+ }
+ }
+
/* A utility function to print array of size n */
- static void printArray(int arr[])
- {
- int n = arr.length;
- for (int i=0; i");
+ tnode = tnode.next;
+ }
+ System.out.println("NULL");
+ }
- public void printList()
- {
- Node tnode = head;
- while (tnode != null)
- {
- System.out.print(tnode.data+"->");
- tnode = tnode.next;
- }
- System.out.println("NULL");
- }
-
- public static void main(String [] args)
- {
- LinkedList llist = new LinkedList();
- for (int i=15; i>0; --i)
- {
- llist.push(i);
- llist.printList();
- llist.printMiddle();
- }
- }
-}
\ No newline at end of file
+ public static void main(String [] args)
+ {
+ LinkedList llist = new LinkedList();
+ for (int i=15; i>0; --i)
+ {
+ llist.push(i);
+ llist.printList();
+ llist.printMiddle();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Exercise_4.java b/Exercise_4.java
index 81afd3c2..0c14c36f 100644
--- a/Exercise_4.java
+++ b/Exercise_4.java
@@ -1,42 +1,72 @@
-class MergeSort
-{
- // Merges two subarrays of arr[].
- // First subarray is arr[l..m]
- // Second subarray is arr[m+1..r]
- void merge(int arr[], int l, int m, int r)
- {
- //Your code here
- }
-
- // Main function that sorts arr[l..r] using
- // merge()
- void sort(int arr[], int l, int r)
- {
- //Write your code here
- //Call mergeSort from here
- }
-
+//Time Complexity: O(NlogN) -> LogN comes from dividing the array into half and N from comparing at each level
+// Space Complexity: O(N) -> Due to storing the temp left and right arrays.
+
+import java.awt.image.renderable.RenderableImage;
+import java.lang.reflect.Array;
+import java.util.Arrays;
+
+class MergeSort
+{
+ // Merges two subarrays of arr[].
+ // First subarray is arr[l..m]
+ // Second subarray is arr[m+1..r]
+ void merge(int arr[], int l, int m, int r)
+ {
+ int[] leftArray = new int[m-l+1];
+ int[] rightArray = new int[r-m];
+ leftArray = Arrays.copyOfRange(arr, l, m+1);
+ rightArray = Arrays.copyOfRange(arr, m+1, r+1);
+
+ int index = l;
+ int i = 0, j = 0 ;
+ while (i < m-l+1 && j < r-m) {
+ if (leftArray[i] <= rightArray[j]) {
+ arr[index] = leftArray[i];
+ i++;
+ } else {
+ arr[index] = rightArray[j];
+ j++;
+ }
+ index++;
+ }
+
+ while (i < m-l+1) arr[index++] = leftArray[i++];
+ while (j < r-m) arr[index++] = rightArray[j++];
+ }
+
+ // Main function that sorts arr[l..r] using
+ // merge()
+ void sort(int arr[], int l, int r)
+ {
+ int middle = l + (r - l)/2;
+ if (l < r) {
+ sort(arr, l, middle);
+ sort(arr, middle + 1, r);
+ merge(arr, l, middle, r);
+ }
+ }
+
/* A utility function to print array of size n */
- static void printArray(int arr[])
- {
- int n = arr.length;
- for (int i=0; i s = new Stack();
+ s.push(l);
+ s.push(h);
+ while (!s.empty()) {
+ h = s.pop();
+ l = s.pop();
+ int pivotIndex = partition(arr, l, h);
+ if (pivotIndex - 1 > l) {
+ s.push(l);
+ s.push(pivotIndex - 1);
+ }
+ if (pivotIndex + 1 < h) {
+ s.push(pivotIndex + 1);
+ s.push(h);
+ }
+ }
+ }
+
+ // A utility function to print contents of arr
+ void printArr(int arr[], int n)
+ {
+ int i;
+ for (i = 0; i < n; ++i)
+ System.out.print(arr[i] + " ");
+ }
+
+ // Driver code to test above
+ public static void main(String args[])
+ {
+ IterativeQuickSort ob = new IterativeQuickSort();
+ int arr[] = { 4, 3, 5, 2, 1, 3, 2, 3 };
+ ob.QuickSort(arr, 0, arr.length - 1);
+ ob.printArr(arr, arr.length);
+ }
+}
\ No newline at end of file
diff --git a/PreCourse-2.iml b/PreCourse-2.iml
new file mode 100644
index 00000000..b107a2dd
--- /dev/null
+++ b/PreCourse-2.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/out/production/PreCourse-2/.idea/.gitignore b/out/production/PreCourse-2/.idea/.gitignore
new file mode 100644
index 00000000..13566b81
--- /dev/null
+++ b/out/production/PreCourse-2/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/out/production/PreCourse-2/.idea/misc.xml b/out/production/PreCourse-2/.idea/misc.xml
new file mode 100644
index 00000000..bcb5da6c
--- /dev/null
+++ b/out/production/PreCourse-2/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/out/production/PreCourse-2/.idea/modules.xml b/out/production/PreCourse-2/.idea/modules.xml
new file mode 100644
index 00000000..1039bae9
--- /dev/null
+++ b/out/production/PreCourse-2/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/out/production/PreCourse-2/.idea/vcs.xml b/out/production/PreCourse-2/.idea/vcs.xml
new file mode 100644
index 00000000..35eb1ddf
--- /dev/null
+++ b/out/production/PreCourse-2/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/out/production/PreCourse-2/BinarySearch.class b/out/production/PreCourse-2/BinarySearch.class
new file mode 100644
index 0000000000000000000000000000000000000000..893ba35266b324b37cb128d1f870a9c11f0141bc
GIT binary patch
literal 1507
zcmaJ>T~8ZV5Ixu4^%}=9F2q2noj4Ry8z_)|xF4pt#evk4sVkXKSv)k?_AP8!?^?U-
z2>wYQQ>jv4cxfLJDXsEassAN^psL!Q^*XH)s9x>v+_^Jn&Y9Wk-~W2?62RwpkU#`c
z16mR~Vgl*M@`+rxq+6l~J&cMwi=J6&&u1FRz`T>+>6TJ|^4-MeXi3)xxSiXS`0|kLZ(;2uOwQC0aCwESj+c7=$&Aqjt
zubkSpE}(mt4{M`GKS3rKE;-SO3>cV1Q!4M
z!c6;#bE4M6DTE#0l^x%4&jh|3pVKHXEcu1ByO#16>yC3W=$9{RAM;#D+&}B9E5gUy
z6MpmM@hOiWs?xHWrmr}tWX-mfTeYO;DbGMvVCj;ktEd{-5xDjLp`1sk3wfTI2tP|8
z%A1E1f<9oKZxMKwpF{jaBZ5182HSv!1wNBu0N%nPR|t+OJ$YKc4S|44F8e*o*<7}(
zTaQZmN=9GHXipK#=;xvR1JcVY*^I7rGuks4=gV|!k8p8C1x
zq^+z*b0cLXJ)=jSBK0#;Q#YPr=0~JyX7m@x0$c|j4yE2@QLu|~3SZ#0LFCq~P9rL%9*=Y~bCY$RfpsB1^c<{h&dC+!;jvCTPsS
n`v&3$J`jQsfKl7kP0^7KcUEKT!%N|2o
literal 0
HcmV?d00001
diff --git a/out/production/PreCourse-2/Exercise_1.cpp b/out/production/PreCourse-2/Exercise_1.cpp
new file mode 100644
index 00000000..a6dc14cc
--- /dev/null
+++ b/out/production/PreCourse-2/Exercise_1.cpp
@@ -0,0 +1,21 @@
+#include
+
+// A recursive binary search function. It returns
+// location of x in given array arr[l..r] is present,
+// otherwise -1
+int binarySearch(int arr[], int l, int r, int x)
+{
+ //Your Code here
+}
+
+int main(void)
+{
+ int arr[] = { 2, 3, 4, 10, 40 };
+ int n = sizeof(arr) / sizeof(arr[0]);
+ int x = 10;
+ int result = binarySearch(arr, 0, n - 1, x);
+ (result == -1) ? printf("Element is not present in array")
+ : printf("Element is present at index %d",
+ result);
+ return 0;
+}
\ No newline at end of file
diff --git a/out/production/PreCourse-2/Exercise_1.js b/out/production/PreCourse-2/Exercise_1.js
new file mode 100644
index 00000000..89d853ec
--- /dev/null
+++ b/out/production/PreCourse-2/Exercise_1.js
@@ -0,0 +1,16 @@
+class BinarySearch {
+ // Returns index of x if it is present in arr[l.. r], else return -1
+ function binarySearch(arr, l, r, x) {
+
+ }
+}
+// Driver method to test above
+const ob = new BinarySearch();
+const arr = [2, 3, 4, 10, 40];
+const n = arr.length;
+const x = 10;
+const result = ob.binarySearch(arr, 0, n - 1, x);
+if (result === -1)
+ console.log("Element not present");
+else
+ console.log("Element found at index " + result);
diff --git a/out/production/PreCourse-2/Exercise_1.py b/out/production/PreCourse-2/Exercise_1.py
new file mode 100644
index 00000000..3e6adcf4
--- /dev/null
+++ b/out/production/PreCourse-2/Exercise_1.py
@@ -0,0 +1,22 @@
+# Python code to implement iterative Binary
+# Search.
+
+# It returns location of x in given array arr
+# if present, else returns -1
+def binarySearch(arr, l, r, x):
+
+ #write your code here
+
+
+
+# Test array
+arr = [ 2, 3, 4, 10, 40 ]
+x = 10
+
+# Function call
+result = binarySearch(arr, 0, len(arr)-1, x)
+
+if result != -1:
+ print "Element is present at index % d" % result
+else:
+ print "Element is not present in array"
diff --git a/out/production/PreCourse-2/Exercise_2.cpp b/out/production/PreCourse-2/Exercise_2.cpp
new file mode 100644
index 00000000..c90e577e
--- /dev/null
+++ b/out/production/PreCourse-2/Exercise_2.cpp
@@ -0,0 +1,47 @@
+#include
+using namespace std;
+
+// A utility function to swap two elements
+void swap(int* a, int* b)
+{
+ //Your Code here
+}
+
+/* This function takes last element as pivot, places
+the pivot element at its correct position in sorted
+array, and places all smaller (smaller than pivot)
+to left of pivot and all greater elements to right
+of pivot */
+int partition (int arr[], int low, int high)
+{
+ //Your Code here
+}
+
+/* The main function that implements QuickSort
+arr[] --> Array to be sorted,
+low --> Starting index,
+high --> Ending index */
+void quickSort(int arr[], int low, int high)
+{
+ //Your Code here
+}
+
+/* Function to print an array */
+void printArray(int arr[], int size)
+{
+ int i;
+ for (i = 0; i < size; i++)
+ cout << arr[i] << " ";
+ cout << endl;
+}
+
+// Driver Code
+int main()
+{
+ int arr[] = {10, 7, 8, 9, 1, 5};
+ int n = sizeof(arr) / sizeof(arr[0]);
+ quickSort(arr, 0, n - 1);
+ cout << "Sorted array: \n";
+ printArray(arr, n);
+ return 0;
+}
\ No newline at end of file
diff --git a/out/production/PreCourse-2/Exercise_2.js b/out/production/PreCourse-2/Exercise_2.js
new file mode 100644
index 00000000..352e36cd
--- /dev/null
+++ b/out/production/PreCourse-2/Exercise_2.js
@@ -0,0 +1,41 @@
+class QuickSort {
+
+ /* This function takes last element as pivot,
+ places the pivot element at its correct
+ position in sorted array, and places all
+ smaller (smaller than pivot) to left of
+ pivot and all greater elements to right
+ of pivot */
+
+ function swap(arr, i, j) {
+ //Your code here
+ }
+
+ function partition(arr, low, high) {
+ //Write code here for Partition and Swap
+ }
+
+ /* The main function that implements QuickSort()
+ arr[] --> Array to be sorted,
+ low --> Starting index,
+ high --> Ending index */
+ function sort(arr, low, high) {
+ // Recursively sort elements before
+ // partition and after partition
+ }
+
+ /* A utility function to print array of size n */
+ function printArray(arr) {
+ let n = arr.length;
+ for (let i = 0; i < n; ++i)
+ console.log(arr[i] + " ");
+ console.log();
+ }
+}
+ // Driver program
+ let arr = [10, 7, 8, 9, 1, 5];
+ let n = arr.length;
+ let ob = new QuickSort();
+ ob.sort(arr, 0, n - 1);
+ console.log("sorted array");
+ ob.printArray(arr);
diff --git a/out/production/PreCourse-2/Exercise_2.py b/out/production/PreCourse-2/Exercise_2.py
new file mode 100644
index 00000000..35abf0dd
--- /dev/null
+++ b/out/production/PreCourse-2/Exercise_2.py
@@ -0,0 +1,23 @@
+# Python program for implementation of Quicksort Sort
+
+# give you explanation for the approach
+def partition(arr,low,high):
+
+
+ #write your code here
+
+
+# Function to do Quick sort
+def quickSort(arr,low,high):
+
+ #write your code here
+
+# Driver code to test above
+arr = [10, 7, 8, 9, 1, 5]
+n = len(arr)
+quickSort(arr,0,n-1)
+print ("Sorted array is:")
+for i in range(n):
+ print ("%d" %arr[i]),
+
+
diff --git a/out/production/PreCourse-2/Exercise_3.cpp b/out/production/PreCourse-2/Exercise_3.cpp
new file mode 100644
index 00000000..209ce0fe
--- /dev/null
+++ b/out/production/PreCourse-2/Exercise_3.cpp
@@ -0,0 +1,50 @@
+#include
+using namespace std;
+
+// Struct
+struct Node
+{
+ int data;
+ struct Node* next;
+};
+
+/* Function to get the middle of the linked list*/
+void printMiddle(struct Node *head)
+{
+ //YourCode here
+ //Use fast and slow pointer technique
+}
+
+// Function to add a new node
+void push(struct Node** head_ref, int new_data)
+{
+ struct Node* new_node = new Node;
+ new_node->data = new_data;
+ new_node->next = (*head_ref);
+ (*head_ref) = new_node;
+}
+
+// A utility function to print a given linked list
+void printList(struct Node *ptr)
+{
+ while (ptr != NULL)
+ {
+ printf("%d->", ptr->data);
+ ptr = ptr->next;
+ }
+ printf("NULL\n");
+}
+
+// Driver Code
+int main()
+{
+ struct Node* head = NULL;
+ for (int i=15; i>0; i--)
+ {
+ push(&head, i);
+ printList(head);
+ printMiddle(head);
+ }
+
+ return 0;
+}
\ No newline at end of file
diff --git a/out/production/PreCourse-2/Exercise_3.js b/out/production/PreCourse-2/Exercise_3.js
new file mode 100644
index 00000000..4c1eabdd
--- /dev/null
+++ b/out/production/PreCourse-2/Exercise_3.js
@@ -0,0 +1,43 @@
+class LinkedList {
+ constructor() {
+ this.head = null; // head of linked list
+ }
+
+ /* Linked list node */
+ static Node = class {
+ constructor(d) {
+ //Constructor here
+ this.data = d;
+ this.next = null;
+ }
+ }
+
+ /* Function to print middle of linked list */
+ //Complete this function
+ function printMiddle() {
+ //Write your code here
+ //Implement using Fast and slow pointers
+ }
+
+ function push(new_data) {
+ let new_node = new this.Node(new_data);
+ new_node.next = this.head;
+ this.head = new_node;
+ }
+
+ function printList() {
+ let tnode = this.head;
+ while (tnode != null) {
+ console.log(tnode.data + "->");
+ tnode = tnode.next;
+ }
+ console.log("NULL");
+ }
+}
+
+let llist = new LinkedList();
+for (let i = 15; i > 0; --i) {
+ llist.push(i);
+ llist.printList();
+ llist.printMiddle();
+}
diff --git a/out/production/PreCourse-2/Exercise_3.py b/out/production/PreCourse-2/Exercise_3.py
new file mode 100644
index 00000000..a26a69b8
--- /dev/null
+++ b/out/production/PreCourse-2/Exercise_3.py
@@ -0,0 +1,26 @@
+# Node class
+class Node:
+
+ # Function to initialise the node object
+ def __init__(self, data):
+
+class LinkedList:
+
+ def __init__(self):
+
+
+ def push(self, new_data):
+
+
+ # Function to get the middle of
+ # the linked list
+ def printMiddle(self):
+
+# Driver code
+list1 = LinkedList()
+list1.push(5)
+list1.push(4)
+list1.push(2)
+list1.push(3)
+list1.push(1)
+list1.printMiddle()
diff --git a/out/production/PreCourse-2/Exercise_4.cpp b/out/production/PreCourse-2/Exercise_4.cpp
new file mode 100644
index 00000000..1a528ee6
--- /dev/null
+++ b/out/production/PreCourse-2/Exercise_4.cpp
@@ -0,0 +1,43 @@
+#include
+#include
+
+// Merges two subarrays of arr[].
+// First subarray is arr[l..m]
+// Second subarray is arr[m+1..r]
+void merge(int arr[], int l, int m, int r)
+{
+ //Your code here
+}
+
+/* l is for left index and r is right index of the
+ sub-array of arr to be sorted */
+void mergeSort(int arr[], int l, int r)
+{
+ //Your code here
+}
+
+/* UTILITY FUNCTIONS */
+/* Function to print an array */
+void printArray(int A[], int size)
+{
+ int i;
+ for (i=0; i < size; i++)
+ printf("%d ", A[i]);
+ printf("\n");
+}
+
+/* Driver program to test above functions */
+int main()
+{
+ int arr[] = {12, 11, 13, 5, 6, 7};
+ int arr_size = sizeof(arr)/sizeof(arr[0]);
+
+ printf("Given array is \n");
+ printArray(arr, arr_size);
+
+ mergeSort(arr, 0, arr_size - 1);
+
+ printf("\nSorted array is \n");
+ printArray(arr, arr_size);
+ return 0;
+}
\ No newline at end of file
diff --git a/out/production/PreCourse-2/Exercise_4.js b/out/production/PreCourse-2/Exercise_4.js
new file mode 100644
index 00000000..58779757
--- /dev/null
+++ b/out/production/PreCourse-2/Exercise_4.js
@@ -0,0 +1,34 @@
+class MergeSort {
+ // Merges two subarrays of arr[].
+ // First subarray is arr[l..m]
+ // Second subarray is arr[m+1..r]
+ function merge(arr, l, m, r) {
+ //Your code here
+ }
+
+ // Main function that sorts arr[l..r] using
+ // merge()
+ function sort(arr, l, r) {
+ //Write your code here
+ //Call mergeSort from here
+ }
+
+ /* A utility function to print array of size n */
+ function printArray(arr) {
+ let n = arr.length;
+ for (let i = 0; i < n; ++i)
+ console.log(arr[i] + " ");
+ console.log();
+ }
+}
+ // Driver method
+ let arr = [12, 11, 13, 5, 6, 7];
+ console.log("Given Array");
+ let ob = new MergeSort();
+ ob.printArray(arr);
+ ob.sort(arr, 0, arr.length - 1);
+ console.log("\nSorted array");
+ ob.printArray(arr);
+
+
+
diff --git a/out/production/PreCourse-2/Exercise_4.py b/out/production/PreCourse-2/Exercise_4.py
new file mode 100644
index 00000000..9bc25d3d
--- /dev/null
+++ b/out/production/PreCourse-2/Exercise_4.py
@@ -0,0 +1,18 @@
+# Python program for implementation of MergeSort
+def mergeSort(arr):
+
+ #write your code here
+
+# Code to print the list
+def printList(arr):
+
+ #write your code here
+
+# driver code to test the above code
+if __name__ == '__main__':
+ arr = [12, 11, 13, 5, 6, 7]
+ print ("Given array is", end="\n")
+ printList(arr)
+ mergeSort(arr)
+ print("Sorted array is: ", end="\n")
+ printList(arr)
diff --git a/out/production/PreCourse-2/Exercise_5.cpp b/out/production/PreCourse-2/Exercise_5.cpp
new file mode 100644
index 00000000..a07c2bf6
--- /dev/null
+++ b/out/production/PreCourse-2/Exercise_5.cpp
@@ -0,0 +1,42 @@
+#include
+using namespace std;
+
+// A utility function to swap two elements
+void swap(int* a, int* b)
+{
+ int t = *a;
+ *a = *b;
+ *b = t;
+}
+
+/* This function is same in both iterative and recursive*/
+int partition(int arr[], int l, int h)
+{
+ //Do the comparison and swapping here
+}
+
+/* A[] --> Array to be sorted,
+l --> Starting index,
+h --> Ending index */
+void quickSortIterative(int arr[], int l, int h)
+{
+ //Try to think that how you can use stack here to remove recursion.
+}
+
+// A utility function to print contents of arr
+void printArr(int arr[], int n)
+{
+ int i;
+ for (i = 0; i < n; ++i)
+ cout << arr[i] << " ";
+}
+
+// Driver code
+int main()
+{
+ int arr[] = { 4, 3, 5, 2, 1, 3, 2, 3 };
+ int n = sizeof(arr) / sizeof(*arr);
+ quickSortIterative(arr, 0, n - 1);
+ printArr(arr, n);
+ return 0;
+}
\ No newline at end of file
diff --git a/out/production/PreCourse-2/Exercise_5.js b/out/production/PreCourse-2/Exercise_5.js
new file mode 100644
index 00000000..01fb9e63
--- /dev/null
+++ b/out/production/PreCourse-2/Exercise_5.js
@@ -0,0 +1,36 @@
+class IterativeQuickSort {
+
+ function swap(arr, i, j) {
+
+ //Try swapping without extra variable
+
+ }
+
+ /* This function is same in both iterative and
+ recursive*/
+ function partition(arr, l, h) {
+
+ //Compare elements and swap.
+
+ }
+
+ // Sorts arr[l..h] using iterative QuickSort
+ function QuickSort(arr, l, h) {
+
+ //Try using Stack Data Structure to remove recursion.
+
+ }
+
+ // A utility function to print contents of arr
+ function printArr(arr, n) {
+ let i;
+ for (i = 0; i < n; ++i)
+ console.log(arr[i] + " ");
+ }
+}
+
+ // Driver code to test above
+let ob = new IterativeQuickSort();
+let arr = [4, 3, 5, 2, 1, 3, 2, 3];
+ob.QuickSort(arr, 0, arr.length - 1);
+ob.printArr(arr, arr.length);
diff --git a/out/production/PreCourse-2/Exercise_5.py b/out/production/PreCourse-2/Exercise_5.py
new file mode 100644
index 00000000..1da24ffb
--- /dev/null
+++ b/out/production/PreCourse-2/Exercise_5.py
@@ -0,0 +1,10 @@
+# Python program for implementation of Quicksort
+
+# This function is same in both iterative and recursive
+def partition(arr, l, h):
+ #write your code here
+
+
+def quickSortIterative(arr, l, h):
+ #write your code here
+
diff --git a/out/production/PreCourse-2/IterativeQuickSort.class b/out/production/PreCourse-2/IterativeQuickSort.class
new file mode 100644
index 0000000000000000000000000000000000000000..d3402114b9f6503c3340c0a860dcb69e6bfa9084
GIT binary patch
literal 2432
zcmaJ@-%}e^7(JJ4vLRjMR|AD^5c-1#Lcyw~wvR6aAx0&09YolcJ|sd!DG-NUWAR$*e%HF6sfv>^~dC%RO0
zYdDCgK5^-%nhrrWjY8GTd@9frPmj#+nK31SdNmwEA2%*nD{BJ7@uqn`i>c)~st&+PW6ZH_%Qlt|a
z;usNVEgOz&xt3jOD3WeP0%IypY8c1FF3lJ3S6s756uU|xqdpJIp19_4heg*hjp9@n
z3wKJxn|Mp0w`gpbvvw(GxHm0#jjf7nl-vr}?v{&dtUdkTk-`66-T-=P6P9yj3!<
zR*Ng9bHi9EFw!+|=ZwOV;aIX?4=V1OMIs01_j+uK3K5
zgNOp-^hB_1ZQA4%v`TsNol?FhQ(J;e7R{-Lr#tx&MFh=-e;Hu?G+}wXjh$_IcG_&+ArNRot#xM@0=c&<)eQt
z*tT179izNpx@&g662@Jw6oc&{tVEDQUWF+Q!&7u@=LA`$O?$)Sag@&RJv3+JT-)I}
z__n$9^@%?C6{D0dn3ZGmw!Kj;Pwl1D6xp@#2IbpldNb>N&T1WE)+iJfE!U)^TDnv+
zo!Np>shAZNto`vloc2pq#fHGZ|4*e?eO^5MVP1^#FT@Y8MhIMBYl3efBcqQXeqo~p
zvwX^7Ab^W}YW@UV!W?^$7bPQd@mB;=_#V<@KVTrC-yToI#=puWVr=NL@hT#L10HY>
zmq_>^c#SfrUbHf|1KviXK3HR;Aza24Z}TCf@t&9e5Z-4ifO!v54D!Wmsh-bY1W*}C
zF^x$@SMrlVeKHgc#gzPy%r6=mk17w)z7-UsiD)nyszKcfiH9%$mR;p;jD7k3nGk-q
z!^{r6)Pv|k1l@@8Vjtjh2t62O{|)rv9QwWNuW;)&9QE>(8mAgOQVkv{EYx|VaMj}x
zp!8t8AQhFIG!#K1
zwu)EVB-+^?q-I0Z<_Ka`<2b)iPVqU7VcO>eS;z4a3uf{wqlhtlj+5A;3%{n8(rig`
zo8$AkrvzCxRNQW;xZO~3yRKp@zQhMuWF9w&A(iqYA2K4H(gEc;Vyw?|To%tTAWs5s
z^}21oV6~-<^*}PFKS1xV7^Q(8Gb7aS_Evxn`De$$UEbVDR{IQ{Fp0zb>XDiI?$sOl
z>WzGLERjtM|NA{3`|efI@|>62A*OnhlK3a;8x}i2u$d-dRYI9;
zFr3MTf|;zUWU^uQJ7lLr4P_P*V}Y@!O1_4v#Ms!=8j?Fl**|g9JZnknoWfZ$m)vE}
vgZ^g7;ud>hjxAGt!FgR?_WUV@+Z<`Z$N0pXAz*O)4p!NVu(gJD6wvoCriby<
literal 0
HcmV?d00001
diff --git a/out/production/PreCourse-2/LinkedList$Node.class b/out/production/PreCourse-2/LinkedList$Node.class
new file mode 100644
index 0000000000000000000000000000000000000000..44b76e6e3f0a3e37bb58ddc6a7633e6cee1fec0e
GIT binary patch
literal 515
zcmZ9IOH0E*6ot>E>C@O~eQVVUU1%3pa9I(gC>ClJl!7anHiJ!V6G*1grGLpq5nT8K
z{88eWDp*|1ndHv7-+g?3y?+2W!(I*+5^2~Dl1K?G^yRax4rK6Hz3%i?R|}+0{J__z
z0*U>Db`}|A)5tlPgCpQJ{oqM?O+VJNX7MuUO1nYYAeP#eF3BxfNp>^YMdhsz
zed|Bam-f|XI|?&8(?=irm-L~3L8mSK?rsKxFrCTXd+xdCp7WjWoO|>8zps7+@DaX^
zB7iOxK@A~vE9iSZU`(U`-fR1*h~wWqQf3iedyY#8vcZI3*9o-`eL%OFVTW=*MXl0~!V~bOcFx$8kl2
z0PJms8PGk9rd?QWnU-62Tf%5~F@`maV3h8vhHEHL78A_zjD~TXRWQ^rw#2+`RSfrm
z>DDMYu3@gP7uCb~OP7XJnYXhA9~%hm}G4*
z^YA3vSUZ!5jn*bH^q*ituIhEK>7r$OyHybjrc5P%=c#B_Oh>F=o{{w;#wFpnB_Y$L
ztG-*d?K*DDXqJRqv#U-R%LL?ifKKzw?x738^6OAjEZZwb`<>7*%oa>KlWY2VqKiHZrfYi&EjzyIy6TP
zuIx0$3Fe(F`B%5t+0|_q^G3a1HeFF7R|+PNrFIfx72hZr
z|9?|H9)5aAu`dI>jS4@$92`U5*G8l42{ri|v9;Xj9xjxoB;c3m%}u?8dYF2GmcRs&q>&(oAzbJ{kUXFviCe_Ur4CcpnaWTJ(EBxO3
zA+Y~!|IfF}GRp?Kia4&}G%KHE-N(2-Pb9K8WLbJh(Z{4hraOVVSmYe$`V;nxa#)rg
w6=CHs{>KFIDJ=rfQQ{n=O$YFX&a=bsAWmEuqD}LHcO|>
zIO7X5zBxYXj4$E?BX9aZJGH}ukNzV%{t1p+zq?5&TE<~^@44sK{mysJ-tf!cPj>-a
z!95)v2&hmZ2qGj9ePBE^GBv|q$`ltLm=#YTbiuMM?~*`ZbZkzChOi1ff=)!*?rWY^
z%Up3?W4$5JS#eg^i}!Ccg(;wo&gb*_vH84?E_ADiMsOHC0^u3cT{26K%L9~#zo<=D
z9?^xP5yWszAXt}f?KJtZxiDTqpNiuV^dsIr--laTZ+K>%D4jLtj1~MsEGKi*wQR5C
zxu#Li^|0o_2wp`(pto+Um{X2jF}ypLw@j(w8Mem?Vx#%7W_UBP#|%q39YZ*&VmN{k
zoDw*4Kz`y~m8Z!RFDH=X4Pi8bF-f%Qd)90XDROqrdT81SpF-($Mmn96L}Vg(9cKk}
z-`#iMDP&4!>q0=oxWFM@5@}WwhU@_eopP!qt-D~^=8d)bqUp{Wi#2L`3QonS%^9vG
z_bsL3EnBj0g}s*K$Rbk-bj;@kM2(MJNv@zWTr=-`EhM^YEiJb6mmJui?4I>Wt|vJJp7U+l&;6?hs~me1JI>cjP#HC@}nD@GbkH
zvtnjAGwgeFLZ*$1=eVTytNo2_IX07DH*8kc7%n)@%Gzq~<&ySk{uMa8zG@!ezQ5|`
zrd+C2y;Emzkc*!6i1O_eP>zWyXeI&-dcCjhXqCluQZX%r;JYaR>CRyPar*F@ZgvOXFuQDaGET08wS}w_AK1iTG8K<0
zJ2;d~$+ism5;YW#ykO@z@qm|E7)cIJihP{r>1U|P_*IWLGw)TM+^agdS9Q{_HNYGv
zaLun;*1*a76Jz{okQZbN>F4A|vNMw0y%4w<@83l4kLXRt(@!w~?BK*k2YdcIbvt
z1!{}264XpI^h_@YqLE@*iFOvt!RVo4IiwZKYBW?VYf-gWAh4d~4o;_@ApH}%%8&8J
z%;{7hwX0M~ue83|vcCAjhR6U2Vu&myISXm_K1-;V3FAb
literal 0
HcmV?d00001
diff --git a/out/production/PreCourse-2/PreCourse-2.iml b/out/production/PreCourse-2/PreCourse-2.iml
new file mode 100644
index 00000000..b107a2dd
--- /dev/null
+++ b/out/production/PreCourse-2/PreCourse-2.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/out/production/PreCourse-2/QuickSort.class b/out/production/PreCourse-2/QuickSort.class
new file mode 100644
index 0000000000000000000000000000000000000000..b1f207dcf234991b185714474cb633778492fc22
GIT binary patch
literal 1966
zcmaJ?%~IP|7(LgPE!z=bLkvw~6Tm=>onS&!nqUY`Xj0r7oYXX_hea!F4G4_nkwt#?
z%yidv*L2ZMH|>IS(hd*M7wER@K0;=i_FTy|WMDcT>E7?&@8_IzKVAR+_VqDwM4IzXD;yd~?z0lOHtwLpU$Edpk;RVw&-Ma$8?9`JOB8aMpX}ADQAo_UUtnXHB
zhki=?x!w{`vm2#S$@lEl(1$qPTDs$!u4!A{{gTYouVFx@QQFK9MG}K5hBUl~OYb15
zzHGb39s$_Nb)yT-C@)phr&>27n@c6G~b
zGd5eA^20rfj5V#TVhmR?qGD9T7%~C_=j0a%wPZD!;%oxR_9`YcOiB$^&$DSshQSD?
z1T@LdXpHENqra4{dFh&w4mUJRqaYCTg6>HN)}n?}PpHeX-7p0D%BE$k?eA?G&bq$Y
ziOV0Pm?Nw}{&TLd(4&Nd<0n`B+J
z_no@&(3GV59=tG|y4g0qnw^$Mz#h17+iu%+^wz53ZrhD^1fMZdjP!-E8p9eYDjvy0
ze=IP5(z&Mf%-%H${^|OC@KCS2wnJ&ZJAHf|M?d+BZZ(=ld%SGhyZf!;SxTo?-U(cP
z*)q;?Kh4_zmWro)uaja~Z#Ju@Yw)PFl4Tjra#L@&jkbz)fr&Gm&V#Cgtup-ouKbLB
zUKnB11^BT5VLtrmAuz*PfuoQsxmOTBaT35yzU4NcV3u#qcfk9&MGNu@;ED{k=@H_X
z$fu^~lzb|mp04E6Nu_d()*iD+i2bl8;CGa6`dsq{=!?
z8s<5ZnPdjP_#d=Yt}LPll(H$|3p=LL!$>hLYhUs0U&3
z!#{sYQ~5egTaG_6MbP6si74k6SuTkf2KgSsFmI(%Ttbfa3_ETfX%GGiOZOn-0hEF+
zb%`u>i7cVmA+m&p4v~2*dPHLMy31LJky7E{Tl5GaQg1w2csq7TeoI>_oJpk*F_O!t
z2)k!a;UuXjjUyyTM)Albq~<=6K`&&2?@6kDjTExH;&NTxdr9&m4+ax=foHnFGhN`B
z4sZ!F2r