├── 1- Big O
├── Slides
│ ├── 1-Basics
│ │ ├── 6.3-Search In BST.html
│ │ ├── 0.1.PNG
│ │ ├── 0.2.PNG
│ │ ├── 0.3.PNG
│ │ ├── 1.1.PNG
│ │ ├── 1.2.PNG
│ │ ├── 1.3.PNG
│ │ ├── 2.1.PNG
│ │ ├── 3.1.PNG
│ │ ├── 4.1.PNG
│ │ ├── 4.2.PNG
│ │ ├── 5.1.PNG
│ │ ├── 6.1.PNG
│ │ ├── 6.2.PNG
│ │ ├── 7.1.PNG
│ │ ├── 7.2.PNG
│ │ ├── 7.3.PNG
│ │ ├── 6.5-BST Print Code.html
│ │ ├── 7.4-Merge Sort.html
│ │ └── 6.4-Deeply Understanding Logarithms In Time Complexities & Their Role In Computer Science.html
│ ├── 3-Example
│ │ ├── 1.1.PNG
│ │ └── 1.2.PNG
│ └── 2-Simplify BigO
│ │ ├── 0.1.PNG
│ │ ├── 1.1.PNG
│ │ ├── 2.1.PNG
│ │ ├── 3.1.PNG
│ │ └── 4.1.PNG
└── BigO
│ ├── BigO
│ ├── BigO.csproj
│ ├── 1-Basics
│ │ ├── 2-O(n).cs
│ │ ├── 3-O(n^2).cs
│ │ ├── 4-O(n!).cs
│ │ ├── 1-O(1).cs
│ │ ├── 5-O(2^n).cs
│ │ ├── 7-O(nLogn).cs
│ │ └── 6-O(log n).cs
│ ├── 2-Simplify BigO
│ │ ├── Rule1 (Worst Case).cs
│ │ ├── Rule4 (Drop Non Dominants).cs
│ │ ├── Rule3 (Different Terms for Inputs).cs
│ │ └── Rule2 (Remove Constants).cs
│ ├── 3-Example
│ │ └── Example.cs
│ └── Program.cs
│ └── BigO.sln
├── 3-Algorithms
├── Slides
│ ├── 1-Recursion
│ │ ├── Recursion.html
│ │ ├── 1.1.PNG
│ │ ├── 1.2.PNG
│ │ ├── 1.3.PNG
│ │ ├── 1.4.PNG
│ │ ├── 1.5.PNG
│ │ ├── 1.6.PNG
│ │ ├── Tail and Non-Tail Recursion.html
│ │ └── Recursion VS Iteration.html
│ ├── 2-Dynamic Programming
│ │ ├── Closures in Arabic.html
│ │ ├── Dynamic Programming.html
│ │ ├── 1.1.PNG
│ │ ├── 1.2.PNG
│ │ ├── 1.3.PNG
│ │ ├── 1.4.PNG
│ │ ├── 1.5.PNG
│ │ ├── 1.6.PNG
│ │ ├── 1.7.PNG
│ │ └── 1.8.PNG
│ ├── 4-Sorting
│ │ ├── Animation Videos
│ │ │ ├── 5.1-Quick Sort.html
│ │ │ ├── 5.2-Quick Sort.html
│ │ │ ├── 3-Bubble Sort.html
│ │ │ ├── 4-Merge Sort.html
│ │ │ ├── 1-Insertion Sort.html
│ │ │ └── 2-Selection Sort.html
│ │ └── Useful links
│ │ │ ├── Stable V.S. Unstable Sorting Algorithms.html
│ │ │ └── Comparing different sorting algorithms by different data sets.html
│ └── 3- Algorithms Searching + BFS + DFS
│ │ ├── 1.PNG
│ │ ├── 2.PNG
│ │ ├── 3.PNG
│ │ ├── 4.PNG
│ │ ├── Connected vs Disconnected Graphs - Copy.html
│ │ └── Tree Traversals (Inorder, Preorder and Postorder).html
└── Algorithms
│ ├── Algorithms
│ ├── Algorithms.csproj
│ ├── 3-Searching_Traversing
│ │ ├── Helper
│ │ │ ├── BinarySearchTree
│ │ │ │ ├── 0-Node.cs
│ │ │ │ └── 1-BinarySearchTree.cs
│ │ │ └── GraphDataStructure
│ │ │ │ └── Graph.cs
│ │ ├── DepthFirstSearch
│ │ │ ├── 2-DFSforGraph.cs
│ │ │ └── 1-DFSforTree.cs
│ │ └── BreadthFirstSearch
│ │ │ ├── 1-BFSforTree.cs
│ │ │ └── 2-BFSforGraph.cs
│ ├── 2-DynamicProgramming
│ │ └── Example(Fibonacci)
│ │ │ ├── 2-UsingDynamicProramming
│ │ │ ├── 2-TabulatedSolution.cs
│ │ │ └── 1-MemoizedSolution.cs
│ │ │ └── 1-UsingRecursion
│ │ │ └── 1-Recursive solution.cs
│ ├── 1-Recursion
│ │ ├── 2-StackOverflowInRecursion
│ │ │ └── 2-StackOverflowInRecursion.cs
│ │ ├── 1-DirectAndIndirectRecursion
│ │ │ └── 1-DirectAndIndirectRecursion.cs
│ │ ├── 4-Recursion VS Iteration
│ │ │ ├── Factorial.cs
│ │ │ └── Fibonacci.cs
│ │ └── 3-TailAndNon_TailRecursion
│ │ │ └── 3-TailAndNon_TailRecursion.cs
│ ├── 4-Sorting
│ │ ├── 2-SelectionSort.cs
│ │ ├── 1-InsertionSort.cs
│ │ ├── 3-BubbleSort.cs
│ │ ├── 5-QuickSort.cs
│ │ └── 4-MergeSort.cs
│ └── Program.cs
│ └── Algorithms.sln
├── 2-Data Structure
├── Slides
│ ├── 5-Tree
│ │ ├── 2.7-Binary Search Tree ( VisuAlgo).html
│ │ ├── 0.1.PNG
│ │ ├── 0.2.PNG
│ │ ├── 0.3.PNG
│ │ ├── 1.1.PNG
│ │ ├── 1.2.PNG
│ │ ├── 1.3.PNG
│ │ ├── 1.4.PNG
│ │ ├── 2.1.PNG
│ │ ├── 2.2.PNG
│ │ ├── 2.3.PNG
│ │ ├── 2.4.PNG
│ │ ├── 2.5.PNG
│ │ └── 2.6-Binary Search Tree (Remove Cases).html
│ ├── 2-Stack
│ │ ├── 1.1.PNG
│ │ ├── 1.2.PNG
│ │ ├── 1.3.PNG
│ │ ├── 1.4.PNG
│ │ └── 1.5.PNG
│ ├── 3-Queue
│ │ ├── 1.1.PNG
│ │ ├── 1.2.PNG
│ │ ├── 1.3.PNG
│ │ ├── 1.4.PNG
│ │ └── 1.5.PNG
│ ├── 6-Gragh
│ │ ├── 1.1.PNG
│ │ ├── 1.2.PNG
│ │ ├── 1.3.PNG
│ │ ├── 1.4.PNG
│ │ ├── 1.5.PNG
│ │ └── 1.6-Graph (Wikipedia).html
│ ├── 1-Linked list
│ │ ├── 1.1.PNG
│ │ ├── 1.2.PNG
│ │ ├── 1.3.PNG
│ │ ├── 1.4.PNG
│ │ └── 1.5.PNG
│ └── 4-Hashtable
│ │ ├── 1.1.PNG
│ │ ├── 1.2.PNG
│ │ ├── 1.3.PNG
│ │ ├── 1.4.PNG
│ │ ├── 1.5.PNG
│ │ ├── 1.6.PNG
│ │ ├── 1.7.PNG
│ │ └── 1.8.PNG
└── DataStructure
│ ├── DataStructure
│ ├── DataStructure.csproj
│ ├── 5-Trees
│ │ ├── 2-BinarySearchTree
│ │ │ ├── 0-Helper
│ │ │ │ ├── BinarySearchTypes.cs
│ │ │ │ ├── TypeA.cs
│ │ │ │ ├── TypeC.cs
│ │ │ │ └── TypeB.cs
│ │ │ ├── 1-BSTNode.cs
│ │ │ └── 2-BinarySearchTree.cs
│ │ ├── 1-BinaryTree
│ │ │ ├── 2-BinaryTree.cs
│ │ │ └── 1-BTNode.cs
│ │ └── TreesPractices.cs
│ ├── 1-LinkedList
│ │ ├── 1-SingleLinkedList
│ │ │ ├── 1-SLLNode.cs
│ │ │ └── 2-SingleLinkedList.cs
│ │ ├── 2-DoublyLinkedLists
│ │ │ ├── 1-DLLNode.cs
│ │ │ └── 2-DoublyLinkedLists.cs
│ │ └── LinkedListPractices.cs
│ ├── 4-HashTable
│ │ ├── 0-HashNode.cs
│ │ ├── HashtablePractices.cs
│ │ ├── 1-WithoutHandlingCollision
│ │ │ └── 1-CustomHashTable.cs
│ │ └── 2-HandlingCollisionUsingSeparateChaining
│ │ │ └── 2-CustomHashTable2.cs
│ ├── 6-Graph
│ │ ├── GraphPrctices.cs
│ │ └── Graph.cs
│ ├── 2-Stack
│ │ ├── 2-StackUsingList.cs
│ │ ├── StackPractices.cs
│ │ └── 1-StackUsingLinkedList.cs
│ ├── Program.cs
│ └── 3-Queue
│ │ ├── QueuePractices.cs
│ │ ├── 1-QueueUsingStack.cs
│ │ └── 2- QueueUsingLinkedlist.cs
│ └── DataStructure.sln
├── LICENSE
├── README.md
└── .gitignore
/1- Big O/Slides/1-Basics/6.3-Search In BST.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/1- Big O/Slides/1-Basics/0.1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/1- Big O/Slides/1-Basics/0.1.PNG
--------------------------------------------------------------------------------
/1- Big O/Slides/1-Basics/0.2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/1- Big O/Slides/1-Basics/0.2.PNG
--------------------------------------------------------------------------------
/1- Big O/Slides/1-Basics/0.3.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/1- Big O/Slides/1-Basics/0.3.PNG
--------------------------------------------------------------------------------
/1- Big O/Slides/1-Basics/1.1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/1- Big O/Slides/1-Basics/1.1.PNG
--------------------------------------------------------------------------------
/1- Big O/Slides/1-Basics/1.2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/1- Big O/Slides/1-Basics/1.2.PNG
--------------------------------------------------------------------------------
/1- Big O/Slides/1-Basics/1.3.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/1- Big O/Slides/1-Basics/1.3.PNG
--------------------------------------------------------------------------------
/1- Big O/Slides/1-Basics/2.1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/1- Big O/Slides/1-Basics/2.1.PNG
--------------------------------------------------------------------------------
/1- Big O/Slides/1-Basics/3.1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/1- Big O/Slides/1-Basics/3.1.PNG
--------------------------------------------------------------------------------
/1- Big O/Slides/1-Basics/4.1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/1- Big O/Slides/1-Basics/4.1.PNG
--------------------------------------------------------------------------------
/1- Big O/Slides/1-Basics/4.2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/1- Big O/Slides/1-Basics/4.2.PNG
--------------------------------------------------------------------------------
/1- Big O/Slides/1-Basics/5.1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/1- Big O/Slides/1-Basics/5.1.PNG
--------------------------------------------------------------------------------
/1- Big O/Slides/1-Basics/6.1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/1- Big O/Slides/1-Basics/6.1.PNG
--------------------------------------------------------------------------------
/1- Big O/Slides/1-Basics/6.2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/1- Big O/Slides/1-Basics/6.2.PNG
--------------------------------------------------------------------------------
/1- Big O/Slides/1-Basics/7.1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/1- Big O/Slides/1-Basics/7.1.PNG
--------------------------------------------------------------------------------
/1- Big O/Slides/1-Basics/7.2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/1- Big O/Slides/1-Basics/7.2.PNG
--------------------------------------------------------------------------------
/1- Big O/Slides/1-Basics/7.3.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/1- Big O/Slides/1-Basics/7.3.PNG
--------------------------------------------------------------------------------
/3-Algorithms/Slides/1-Recursion/Recursion.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/1- Big O/Slides/3-Example/1.1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/1- Big O/Slides/3-Example/1.1.PNG
--------------------------------------------------------------------------------
/1- Big O/Slides/3-Example/1.2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/1- Big O/Slides/3-Example/1.2.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/5-Tree/2.7-Binary Search Tree ( VisuAlgo).html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/1- Big O/Slides/2-Simplify BigO/0.1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/1- Big O/Slides/2-Simplify BigO/0.1.PNG
--------------------------------------------------------------------------------
/1- Big O/Slides/2-Simplify BigO/1.1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/1- Big O/Slides/2-Simplify BigO/1.1.PNG
--------------------------------------------------------------------------------
/1- Big O/Slides/2-Simplify BigO/2.1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/1- Big O/Slides/2-Simplify BigO/2.1.PNG
--------------------------------------------------------------------------------
/1- Big O/Slides/2-Simplify BigO/3.1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/1- Big O/Slides/2-Simplify BigO/3.1.PNG
--------------------------------------------------------------------------------
/1- Big O/Slides/2-Simplify BigO/4.1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/1- Big O/Slides/2-Simplify BigO/4.1.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/2-Stack/1.1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/2-Stack/1.1.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/2-Stack/1.2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/2-Stack/1.2.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/2-Stack/1.3.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/2-Stack/1.3.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/2-Stack/1.4.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/2-Stack/1.4.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/2-Stack/1.5.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/2-Stack/1.5.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/3-Queue/1.1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/3-Queue/1.1.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/3-Queue/1.2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/3-Queue/1.2.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/3-Queue/1.3.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/3-Queue/1.3.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/3-Queue/1.4.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/3-Queue/1.4.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/3-Queue/1.5.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/3-Queue/1.5.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/5-Tree/0.1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/5-Tree/0.1.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/5-Tree/0.2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/5-Tree/0.2.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/5-Tree/0.3.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/5-Tree/0.3.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/5-Tree/1.1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/5-Tree/1.1.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/5-Tree/1.2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/5-Tree/1.2.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/5-Tree/1.3.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/5-Tree/1.3.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/5-Tree/1.4.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/5-Tree/1.4.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/5-Tree/2.1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/5-Tree/2.1.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/5-Tree/2.2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/5-Tree/2.2.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/5-Tree/2.3.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/5-Tree/2.3.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/5-Tree/2.4.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/5-Tree/2.4.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/5-Tree/2.5.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/5-Tree/2.5.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/6-Gragh/1.1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/6-Gragh/1.1.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/6-Gragh/1.2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/6-Gragh/1.2.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/6-Gragh/1.3.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/6-Gragh/1.3.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/6-Gragh/1.4.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/6-Gragh/1.4.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/6-Gragh/1.5.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/6-Gragh/1.5.PNG
--------------------------------------------------------------------------------
/3-Algorithms/Slides/1-Recursion/1.1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/3-Algorithms/Slides/1-Recursion/1.1.PNG
--------------------------------------------------------------------------------
/3-Algorithms/Slides/1-Recursion/1.2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/3-Algorithms/Slides/1-Recursion/1.2.PNG
--------------------------------------------------------------------------------
/3-Algorithms/Slides/1-Recursion/1.3.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/3-Algorithms/Slides/1-Recursion/1.3.PNG
--------------------------------------------------------------------------------
/3-Algorithms/Slides/1-Recursion/1.4.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/3-Algorithms/Slides/1-Recursion/1.4.PNG
--------------------------------------------------------------------------------
/3-Algorithms/Slides/1-Recursion/1.5.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/3-Algorithms/Slides/1-Recursion/1.5.PNG
--------------------------------------------------------------------------------
/3-Algorithms/Slides/1-Recursion/1.6.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/3-Algorithms/Slides/1-Recursion/1.6.PNG
--------------------------------------------------------------------------------
/1- Big O/Slides/1-Basics/6.5-BST Print Code.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/2-Data Structure/Slides/1-Linked list/1.1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/1-Linked list/1.1.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/1-Linked list/1.2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/1-Linked list/1.2.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/1-Linked list/1.3.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/1-Linked list/1.3.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/1-Linked list/1.4.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/1-Linked list/1.4.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/1-Linked list/1.5.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/1-Linked list/1.5.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/4-Hashtable/1.1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/4-Hashtable/1.1.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/4-Hashtable/1.2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/4-Hashtable/1.2.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/4-Hashtable/1.3.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/4-Hashtable/1.3.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/4-Hashtable/1.4.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/4-Hashtable/1.4.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/4-Hashtable/1.5.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/4-Hashtable/1.5.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/4-Hashtable/1.6.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/4-Hashtable/1.6.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/4-Hashtable/1.7.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/4-Hashtable/1.7.PNG
--------------------------------------------------------------------------------
/2-Data Structure/Slides/4-Hashtable/1.8.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/2-Data Structure/Slides/4-Hashtable/1.8.PNG
--------------------------------------------------------------------------------
/3-Algorithms/Slides/1-Recursion/Tail and Non-Tail Recursion.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/3-Algorithms/Slides/2-Dynamic Programming/Closures in Arabic.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/3-Algorithms/Slides/4-Sorting/Animation Videos/5.1-Quick Sort.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/3-Algorithms/Slides/4-Sorting/Animation Videos/5.2-Quick Sort.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/2-Data Structure/Slides/6-Gragh/1.6-Graph (Wikipedia).html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/3-Algorithms/Slides/2-Dynamic Programming/Dynamic Programming.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/3-Algorithms/Slides/2-Dynamic Programming/1.1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/3-Algorithms/Slides/2-Dynamic Programming/1.1.PNG
--------------------------------------------------------------------------------
/3-Algorithms/Slides/2-Dynamic Programming/1.2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/3-Algorithms/Slides/2-Dynamic Programming/1.2.PNG
--------------------------------------------------------------------------------
/3-Algorithms/Slides/2-Dynamic Programming/1.3.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/3-Algorithms/Slides/2-Dynamic Programming/1.3.PNG
--------------------------------------------------------------------------------
/3-Algorithms/Slides/2-Dynamic Programming/1.4.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/3-Algorithms/Slides/2-Dynamic Programming/1.4.PNG
--------------------------------------------------------------------------------
/3-Algorithms/Slides/2-Dynamic Programming/1.5.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/3-Algorithms/Slides/2-Dynamic Programming/1.5.PNG
--------------------------------------------------------------------------------
/3-Algorithms/Slides/2-Dynamic Programming/1.6.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/3-Algorithms/Slides/2-Dynamic Programming/1.6.PNG
--------------------------------------------------------------------------------
/3-Algorithms/Slides/2-Dynamic Programming/1.7.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/3-Algorithms/Slides/2-Dynamic Programming/1.7.PNG
--------------------------------------------------------------------------------
/3-Algorithms/Slides/2-Dynamic Programming/1.8.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/3-Algorithms/Slides/2-Dynamic Programming/1.8.PNG
--------------------------------------------------------------------------------
/3-Algorithms/Slides/1-Recursion/Recursion VS Iteration.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/3-Algorithms/Slides/4-Sorting/Useful links/Stable V.S. Unstable Sorting Algorithms.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/1- Big O/Slides/1-Basics/7.4-Merge Sort.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/2-Data Structure/Slides/5-Tree/2.6-Binary Search Tree (Remove Cases).html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/3-Algorithms/Slides/3- Algorithms Searching + BFS + DFS/1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/3-Algorithms/Slides/3- Algorithms Searching + BFS + DFS/1.PNG
--------------------------------------------------------------------------------
/3-Algorithms/Slides/3- Algorithms Searching + BFS + DFS/2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/3-Algorithms/Slides/3- Algorithms Searching + BFS + DFS/2.PNG
--------------------------------------------------------------------------------
/3-Algorithms/Slides/3- Algorithms Searching + BFS + DFS/3.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/3-Algorithms/Slides/3- Algorithms Searching + BFS + DFS/3.PNG
--------------------------------------------------------------------------------
/3-Algorithms/Slides/3- Algorithms Searching + BFS + DFS/4.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MohamedHashish42/Data-Structures-And-Algorithms/HEAD/3-Algorithms/Slides/3- Algorithms Searching + BFS + DFS/4.PNG
--------------------------------------------------------------------------------
/3-Algorithms/Slides/4-Sorting/Animation Videos/3-Bubble Sort.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/3-Algorithms/Slides/4-Sorting/Animation Videos/4-Merge Sort.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/1- Big O/Slides/1-Basics/6.4-Deeply Understanding Logarithms In Time Complexities & Their Role In Computer Science.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/3-Algorithms/Slides/4-Sorting/Animation Videos/1-Insertion Sort.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/3-Algorithms/Slides/4-Sorting/Animation Videos/2-Selection Sort.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/3-Algorithms/Slides/4-Sorting/Useful links/Comparing different sorting algorithms by different data sets.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/3-Algorithms/Slides/3- Algorithms Searching + BFS + DFS/Connected vs Disconnected Graphs - Copy.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/1- Big O/BigO/BigO/BigO.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.1
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/3-Algorithms/Slides/3- Algorithms Searching + BFS + DFS/Tree Traversals (Inorder, Preorder and Postorder).html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/2-Data Structure/DataStructure/DataStructure/DataStructure.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.1
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/2-Data Structure/DataStructure/DataStructure/5-Trees/2-BinarySearchTree/0-Helper/BinarySearchTypes.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace DataStructure.Trees.BinarySearchTree.Helper
6 | {
7 | public abstract class BinarySearchTypes
8 | {
9 | public int Key { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/3-Algorithms/Algorithms/Algorithms/Algorithms.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp3.1
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/1- Big O/BigO/BigO/1-Basics/2-O(n).cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BigO
6 | {
7 | class Linear
8 | {
9 | public static void PrinFromOneToNumber(int number)
10 | {
11 | for (int i = 1; i <= number; i++)
12 | {
13 | Console.WriteLine(i);
14 | }
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/2-Data Structure/DataStructure/DataStructure/1-LinkedList/1-SingleLinkedList/1-SLLNode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace DataStructure.LinkedList
6 | {
7 | public class SLLNode
8 | {
9 | public T Value { get; set; }
10 | public SLLNode Next { get; set; }
11 |
12 | public SLLNode(T value)
13 | {
14 | Value = value;
15 | }
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/2-Data Structure/DataStructure/DataStructure/4-HashTable/0-HashNode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace DataStructure.HashTable
6 | {
7 | class HashNode
8 | {
9 | public object Key { get; set; }
10 | public object Value { get; set; }
11 |
12 | public HashNode(object key, object value)
13 | {
14 | Key = key;
15 | Value = value;
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/2-Data Structure/DataStructure/DataStructure/5-Trees/2-BinarySearchTree/0-Helper/TypeA.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace DataStructure.Trees.BinarySearchTree.Helper
6 | {
7 | class TypeA : BinarySearchTypes
8 | {
9 | public int Value { get; set; }
10 | public TypeA(int key, int value)
11 | {
12 | Key = key;
13 | Value = value;
14 |
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/2-Data Structure/DataStructure/DataStructure/5-Trees/2-BinarySearchTree/0-Helper/TypeC.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace DataStructure.Trees.BinarySearchTree.Helper
6 | {
7 | class TypeC : BinarySearchTypes
8 | {
9 | public float Value { get; set; }
10 | public TypeC(int key, float value)
11 | {
12 | Key = key;
13 | Value = value;
14 |
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/2-Data Structure/DataStructure/DataStructure/5-Trees/2-BinarySearchTree/0-Helper/TypeB.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace DataStructure.Trees.BinarySearchTree.Helper
6 | {
7 | class TypeB : BinarySearchTypes
8 | {
9 | public string Value { get; set; }
10 | public TypeB(int key,string value)
11 | {
12 | Key = key;
13 | Value = value;
14 |
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/2-Data Structure/DataStructure/DataStructure/1-LinkedList/2-DoublyLinkedLists/1-DLLNode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace DataStructure.LinkedList
6 | {
7 |
8 | public class DLLNode
9 | {
10 | public T Value { get; set; }
11 | public DLLNode Next { get; set; }
12 | public DLLNode Previous { get; set; }
13 |
14 | public DLLNode(T value)
15 | {
16 | Value = value;
17 | }
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/2-Data Structure/DataStructure/DataStructure/5-Trees/1-BinaryTree/2-BinaryTree.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace DataStructure.Trees.BinaryTree
6 | {
7 |
8 | public class BinaryTree
9 | {
10 |
11 | public BTNode root { get; set; }
12 |
13 | public BinaryTree()
14 | {
15 | root = null;
16 | }
17 |
18 | public BinaryTree(T value)
19 | {
20 | root = new BTNode(value);
21 | }
22 |
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/3-Algorithms/Algorithms/Algorithms/3-Searching_Traversing/Helper/BinarySearchTree/0-Node.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Algorithms.Searching_Traversing
6 | {
7 | class Node
8 | {
9 | public int Value { get; set; }
10 | public Node Left { get; set; }
11 | public Node Right { get; set; }
12 |
13 | public Node(int value)
14 | {
15 | Value = value;
16 | Left = null;
17 | Right = null;
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/1- Big O/BigO/BigO/1-Basics/3-O(n^2).cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BigO
6 | {
7 | class Quadratic
8 | {
9 | public static void MultiplicationTable(int n)
10 | {
11 | for (int i = 1; i < n; i++)
12 | {
13 | for (int j = 1; j < n; j++)
14 | {
15 | Console.WriteLine(i +" * "+j+" =" +i*j);
16 | }
17 | Console.WriteLine("\n");
18 | }
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/1- Big O/BigO/BigO/2-Simplify BigO/Rule1 (Worst Case).cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BigO
6 | {
7 | class WorstCase
8 | {
9 | public static void FindNameInArray(string [] arr,string name)
10 | {
11 | foreach (var item in arr)
12 | {
13 | if (item == name)
14 | {
15 | Console.WriteLine(name); //O(n)
16 | break;
17 | }
18 | }
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/2-Data Structure/DataStructure/DataStructure/5-Trees/1-BinaryTree/1-BTNode.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace DataStructure.Trees.BinaryTree
6 | {
7 | public class BTNode
8 | {
9 | public T Value { get; set; }
10 | public BTNodeLeft { get; set; }
11 | public BTNode Right { get; set; }
12 |
13 | public BTNode(T value)
14 | {
15 | Value = value;
16 | Left = null;
17 | Right = null;
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/3-Algorithms/Algorithms/Algorithms/2-DynamicProgramming/Example(Fibonacci)/2-UsingDynamicProramming/2-TabulatedSolution.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Algorithms.DynamicProgramming
6 | {
7 | class TabulatedSolution
8 | {
9 | public static int Fib(int index)
10 | {
11 |
12 | var fibSeq = new List { 0, 1 };
13 | for (int i = 2; i <= index; i++)
14 | {
15 | fibSeq.Add(fibSeq[i - 1] + fibSeq[i - 2]);
16 | }
17 |
18 | return fibSeq[index];
19 | }
20 |
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/1- Big O/BigO/BigO/1-Basics/4-O(n!).cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BigO
6 | {
7 | class Factorial
8 | {
9 | public static void PrintUntilFactorial(int n)
10 | {
11 |
12 | for (int i = 1; i <= Fact(n); i++)
13 | {
14 | Console.WriteLine(i); //O(n!)
15 | }
16 | }
17 |
18 | public static int Fact(int number)
19 | {
20 | int factorial = 1;
21 | for (int i = number; i >= 1; i--)
22 | {
23 | factorial *= i;
24 | }
25 | return factorial;
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/2-Data Structure/DataStructure/DataStructure/5-Trees/2-BinarySearchTree/1-BSTNode.cs:
--------------------------------------------------------------------------------
1 | using DataStructure.Trees.BinarySearchTree.Helper;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace DataStructure.Trees.BinarySearchTree
7 | {
8 | public class BSTNode where T: BinarySearchTypes
9 | {
10 | public T Obj { get; set; }
11 | public BSTNode Left { get; set; }
12 | public BSTNode Right { get; set; }
13 | public BSTNode()
14 | {
15 |
16 | }
17 | public BSTNode(T obj)
18 | {
19 | Obj = obj;
20 | Left = null;
21 | Right = null;
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/1- Big O/BigO/BigO/2-Simplify BigO/Rule4 (Drop Non Dominants).cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BigO
6 | {
7 | class DropNonDominants
8 | {
9 | public static void PrintDone(int n)
10 | {
11 | for (int i = 0; i < n; i++)
12 | {
13 | for (int j = 0; j < n; j++)
14 | {
15 | Console.WriteLine("Done"); //O(n^2)
16 | }
17 | }
18 |
19 | for (int i = 0; i < n; i++)
20 | {
21 | Console.WriteLine("Done"); //O(n)
22 | }
23 | //Time complixity for this function = O(n^2 + n) = O(n^2)
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/1- Big O/BigO/BigO/2-Simplify BigO/Rule3 (Different Terms for Inputs).cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BigO
6 | {
7 | class DifferentTermsForInputs
8 | {
9 | public static void PrintNumberInTwoArrays(int [] arr1,int [] arr2)
10 | {
11 | var n = arr1.Length;
12 | var a = arr2.Length;
13 |
14 | for (int i = 0; i < n; i++)
15 | {
16 | Console.WriteLine(arr1[i]);
17 | }
18 |
19 | for (int i = 0; i < a; i++)
20 | {
21 | Console.WriteLine(arr2[i]);
22 | }
23 |
24 | //Time complixity for this function = O( n + a)
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/2-Data Structure/DataStructure/DataStructure/6-Graph/GraphPrctices.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace DataStructure.Graph
6 | {
7 | class GraphPrctices
8 | {
9 | public static void CustomGraph()
10 | {
11 | Graph myGraph = new Graph();
12 | myGraph.AddVertex("A");
13 | myGraph.AddVertex("B");
14 | myGraph.AddVertex("C");
15 | myGraph.AddVertex("D");
16 | myGraph.AddEdge("A", "B");
17 | myGraph.AddEdge("A", "C");
18 | myGraph.AddEdge("B", "C");
19 | myGraph.AddEdge("C", "D");
20 |
21 |
22 | myGraph.ShowConnections();
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/3-Algorithms/Algorithms/Algorithms/1-Recursion/2-StackOverflowInRecursion/2-StackOverflowInRecursion.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Algorithms.Recursion
6 | {
7 | class StackOverflowInRecursion
8 | {
9 | #region Base case is not reached
10 |
11 | int Fact(int n)
12 | {
13 | //Here if i called Fact as Fact(10) the
14 | //base case is never reached
15 | if (n == 100)
16 | return 1;
17 |
18 | else
19 | return n * Fact(n - 1);
20 | }
21 |
22 | #endregion
23 |
24 |
25 |
26 | #region Base case is not defined
27 |
28 | int fact(int n)
29 | {
30 | return n * fact(n - 1);
31 | }
32 |
33 |
34 |
35 | #endregion
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/3-Algorithms/Algorithms/Algorithms/1-Recursion/1-DirectAndIndirectRecursion/1-DirectAndIndirectRecursion.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Algorithms.Recursion
6 | {
7 | class DirectAndIndirectRecursion
8 | {
9 | #region Direct recursion
10 |
11 |
12 | void Fun()
13 | {
14 | // Some code....
15 | Fun();
16 | // Some code...
17 | }
18 |
19 | #endregion
20 |
21 |
22 |
23 |
24 | #region Indirect recursion
25 |
26 | void Fun1()
27 | {
28 | // Some code...
29 | Fun2();
30 | // Some code...
31 | }
32 | void Fun2()
33 | {
34 | // Some code...
35 | Fun1();
36 | // Some code...
37 | }
38 |
39 |
40 | #endregion
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/1- Big O/BigO/BigO/2-Simplify BigO/Rule2 (Remove Constants).cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BigO
6 | {
7 | class RemoveConstants
8 | {
9 | public static void PrintFromOneToNumberTwiceAndFromOneToTen(int number)
10 | {
11 | for (int i = 1; i < number; i++)
12 | {
13 | Console.WriteLine(i); //O(n)
14 | }
15 |
16 | for (int i = 1; i < number; i++)
17 | {
18 | Console.WriteLine(i); //O(n)
19 | }
20 |
21 | for (int i = 1; i < 10; i++)
22 | {
23 | Console.WriteLine(i); //O(10)
24 | }
25 |
26 |
27 | //Time complixity for this function
28 | // = O(2n + 10)
29 | // = O(2n + 1)
30 | // = O(n)
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/3-Algorithms/Algorithms/Algorithms/4-Sorting/2-SelectionSort.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Algorithms.Sorting
6 | {
7 | class SelectionSort
8 | {
9 |
10 | public static int[] Sort(int[] arr)
11 | {
12 | var n = arr.Length;
13 |
14 | // One by one move boundary of unsorted subarray
15 | for (int i = 0; i < n - 1; i++)
16 | {
17 | // Find the minimum element in unsorted array
18 | var min = i;
19 | for (int j = i + 1; j < n; j++)
20 | {
21 | if (arr[j] < arr[min])
22 | min = j;
23 | }
24 |
25 | // Swap the found minimum element
26 | var temp = arr[min];
27 | arr[min] = arr[i];
28 | arr[i] = temp;
29 | }
30 |
31 | return arr;
32 | }
33 |
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/3-Algorithms/Algorithms/Algorithms/2-DynamicProgramming/Example(Fibonacci)/1-UsingRecursion/1-Recursive solution.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Algorithms.DynamicProgramming
6 | {
7 | class RecursiveSolution
8 | {
9 |
10 | public static int Fib(int index)
11 | {
12 | if (index < 2)
13 | {
14 | return index;
15 | }
16 | return Fib(index - 1) + Fib(index - 2);
17 |
18 | // Fib(6)
19 |
20 | // Fib(5) + Fib(4)
21 |
22 | // Fib(4) + Fib(3) Fib(3) + Fib(2)
23 |
24 | // Fib(3) + Fib(2) Fib(2) + Fib(1) Fib(2) + Fib(1)
25 |
26 | // Fib(2) + Fib(1)
27 |
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/3-Algorithms/Algorithms/Algorithms/4-Sorting/1-InsertionSort.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Algorithms.Sorting
6 | {
7 | class InsertionSort
8 | {
9 |
10 |
11 | public static int[] Sort(int[] arr)
12 | {
13 | int n = arr.Length;
14 | for (int i = 1; i < n; ++i)
15 | {
16 | int key = arr[i];
17 | int j;
18 |
19 | // when Key 30
20 | // 40, 50, 30, 70
21 |
22 | for (j = i - 1; j >= 0 && key < arr[j]; j--)
23 | {
24 |
25 | // 1th 40, 50, 50, 70
26 | // 2th 40, 40, 50, 70
27 |
28 | arr[j + 1] = arr[j];
29 |
30 |
31 | }
32 |
33 | arr[j + 1] = key; // 30, 40, 50, 70
34 | }
35 | return arr;
36 | }
37 |
38 |
39 |
40 |
41 |
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/3-Algorithms/Algorithms/Algorithms/1-Recursion/4-Recursion VS Iteration/Factorial.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Algorithms.Recursion
6 | {
7 | class Factorial
8 | {
9 | public static int UsingItteration(int number)
10 | {
11 | int factorial = 1;
12 | for (int i = number; i >= 1; i--)
13 | {
14 | factorial *= i;
15 | }
16 | return factorial;
17 | }
18 |
19 | public static int UsingRecursion(int number)
20 | {
21 |
22 | //Base Case
23 | if (number == 0 || number == 1)
24 | {
25 | return 1;
26 | }
27 | //Recursive Case
28 | return number * UsingRecursion(number - 1);
29 | //5 * 4!
30 | // 4 * 3!
31 | // 3 * 2!
32 | // 2 * 1!
33 | // 1
34 |
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/3-Algorithms/Algorithms/Algorithms/4-Sorting/3-BubbleSort.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Algorithms.Sorting
6 | {
7 | class BubbleSort
8 | {
9 |
10 |
11 | public static int[] Sort(int[] arr)
12 | {
13 | var n = arr.Length;
14 | bool swapped;
15 | for (int i = 0; i < n - 1; i++)
16 | {
17 | swapped = false;
18 | for (int j = 0; j < n - i - 1; j++)
19 | {
20 | if (arr[j] > arr[j + 1])
21 | {
22 | // swap arr[j] and arr[j+1]
23 | var temp = arr[j];
24 | arr[j] = arr[j + 1];
25 | arr[j + 1] = temp;
26 | swapped = true;
27 | }
28 | }
29 |
30 | if (swapped == false)
31 | break;
32 | }
33 | return arr;
34 | }
35 |
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 MohamedHashish42
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/1- Big O/BigO/BigO.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31229.75
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BigO", "BigO\BigO.csproj", "{D8C8B9C2-C8F6-4694-923C-E070E73F46B1}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {D8C8B9C2-C8F6-4694-923C-E070E73F46B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {D8C8B9C2-C8F6-4694-923C-E070E73F46B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {D8C8B9C2-C8F6-4694-923C-E070E73F46B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {D8C8B9C2-C8F6-4694-923C-E070E73F46B1}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {AA0DDC1A-0F98-44E0-B1FC-FCE5F042381D}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/1- Big O/BigO/BigO/1-Basics/1-O(1).cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BigO
6 | {
7 | class Constant
8 | {
9 | public static void PrintNumber(int number)
10 | {
11 | Console.WriteLine(number);
12 | }
13 |
14 | public static void PrintNumberTwice(int number)
15 | {
16 | //This method gives O(2)
17 |
18 | Console.WriteLine(number); //O(1)
19 | Console.WriteLine(number); //O(1)
20 | }
21 |
22 |
23 | public static void PrintNumberThrice(int number)
24 | {
25 | //This method gives O(3)
26 |
27 | Console.WriteLine(number); //O(1)
28 | Console.WriteLine(number); //O(1)
29 | Console.WriteLine(number); //O(1)
30 | }
31 |
32 | public static void PrintNumberFourTimes(int number)
33 | {
34 | //This method gives O(4)
35 |
36 | Console.WriteLine(number); //O(1)
37 | Console.WriteLine(number); //O(1)
38 | Console.WriteLine(number); //O(1)
39 | Console.WriteLine(number); //O(1)
40 | }
41 |
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/3-Algorithms/Algorithms/Algorithms.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31229.75
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Algorithms", "Algorithms\Algorithms.csproj", "{2BF325C3-1A30-4333-8FBE-5F72404683FB}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {2BF325C3-1A30-4333-8FBE-5F72404683FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {2BF325C3-1A30-4333-8FBE-5F72404683FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {2BF325C3-1A30-4333-8FBE-5F72404683FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {2BF325C3-1A30-4333-8FBE-5F72404683FB}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {A09F7D49-DDB6-406F-97ED-2959C48584A5}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/2-Data Structure/DataStructure/DataStructure.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31229.75
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataStructure", "DataStructure\DataStructure.csproj", "{54C57C17-B3B9-4610-AD73-EA6E5087CE91}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {54C57C17-B3B9-4610-AD73-EA6E5087CE91}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {54C57C17-B3B9-4610-AD73-EA6E5087CE91}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {54C57C17-B3B9-4610-AD73-EA6E5087CE91}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {54C57C17-B3B9-4610-AD73-EA6E5087CE91}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {9164C979-6EF8-40FD-A9C0-9182C4F8D7A0}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/3-Algorithms/Algorithms/Algorithms/3-Searching_Traversing/DepthFirstSearch/2-DFSforGraph.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Algorithms.Searching_Traversing
6 | {
7 | class DFSforGraph
8 | {
9 | public static void DFSUtil(T v, List visited, Graph graph)
10 | {
11 |
12 | visited.Add(v);
13 | Console.Write(v + " ");
14 |
15 | var vList = graph.AdjacentList[v];
16 | foreach (var n in vList)
17 | {
18 | if (!visited.Contains(n))
19 | DFSUtil(n, visited, graph);
20 | }
21 | }
22 |
23 |
24 | public static void DFS(Graph graph, T v)
25 | {
26 |
27 | var visited = new List();
28 | DFSUtil(v, visited, graph);
29 | }
30 |
31 |
32 | public static void DFS(Graph graph)
33 | {
34 | var visited = new List();
35 | foreach (var item in graph.AdjacentList)
36 | {
37 | if (!visited.Contains(item.Key))
38 | DFSUtil(item.Key, visited, graph);
39 | }
40 |
41 |
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/1- Big O/BigO/BigO/3-Example/Example.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace BigO
7 | {
8 | class Example
9 | {
10 | public static bool HasPairWithSum(int[] arr, int sum)
11 | {
12 | for (int i = 0; i < arr.Length; i++)
13 | {
14 | for (int j = 0; j < arr.Length; j++)
15 | {
16 | if (arr[i] + arr[j] == sum)
17 | return true;
18 | }
19 |
20 | }
21 | return false;
22 |
23 | //Time Complexity is O(n^2)
24 | //Space Complexity is O(1)
25 | }
26 |
27 | public static bool HasPairWithSum2(int[] arr, int sum)
28 | {
29 | List list = new List();
30 | for (int i = 0; i < arr.Length; i++)
31 | {
32 | if (list.Contains(arr[i]))
33 | {
34 | return true;
35 | }
36 |
37 | list.Add(sum - arr[i]);
38 | }
39 | return false;
40 |
41 | //Time Complexity is O(n)
42 | //Space Complexity is O(n)
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/2-Data Structure/DataStructure/DataStructure/2-Stack/2-StackUsingList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace DataStructure.Stack
7 | {
8 |
9 | class StackUsingList
10 | {
11 | private List _list;
12 |
13 | public StackUsingList()
14 | {
15 | _list = new List();
16 |
17 | }
18 |
19 | public T Peek()
20 | {
21 | if (_list.Count > 0)
22 | return _list[_list.Count - 1];
23 | return default(T);
24 | }
25 |
26 | public void Push(T value)
27 | {
28 | _list.Add(value);
29 | }
30 |
31 | public T Pop()
32 | {
33 | if (_list.Count == 0)
34 | {
35 | return default(T);
36 | }
37 | T lastItem = _list[_list.Count - 1];
38 | _list.RemoveAt(_list.Count - 1);
39 | return lastItem;
40 | }
41 |
42 | public void Display()
43 | {
44 |
45 | foreach (var item in _list)
46 | {
47 | Console.Write(item +" ");
48 | }
49 | Console.WriteLine("\n");
50 | }
51 |
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/3-Algorithms/Algorithms/Algorithms/1-Recursion/3-TailAndNon_TailRecursion/3-TailAndNon_TailRecursion.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Algorithms.Recursion
6 | {
7 | class TailAndNon_TailRecursion
8 | {
9 | #region Non Tail Recursion
10 | public static int NonTRFact(int number)
11 | {
12 |
13 | //Base Case
14 | if (number == 0 || number == 1)
15 | {
16 | return 1;
17 | }
18 | //Recursive Case
19 | return number * NonTRFact(number - 1);
20 | //5 * 4!
21 | // 4 * 3!
22 | // 3 * 2!
23 | // 2 * 1!
24 | // 1
25 |
26 | }
27 | #endregion
28 |
29 | #region Tail Recursion
30 | public static int TRFact(int n, int a = 1)
31 | {
32 | if (n == 0)
33 | return a;
34 |
35 | return TRFact(n - 1, n * a);
36 |
37 | // TRFact(5 , 1) = TRFact(5-1 , 5*1)
38 |
39 | // TRFact(4-1 , 4*5)
40 |
41 | // TRFact(3-1 , 3*20)
42 |
43 | // TRFact(2-1 , 2*60)
44 |
45 | // TRFact(1-1 , 1*120)
46 |
47 | }
48 | #endregion
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/1- Big O/BigO/BigO/1-Basics/5-O(2^n).cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BigO
6 | {
7 | class Exponential
8 | {
9 | public static List PowerSet(string input)
10 | {
11 | int n = input.Length;
12 |
13 | // Power set contains 2^N subsets.
14 | // . . . 2^5 2^4 2^3 2^2 2^1 2^0
15 | // . . . 32 16 8 4 2 1
16 |
17 | int powerSetCount = 1 << n;
18 | var ans = new List();
19 | for (int counter = 0; counter < powerSetCount; counter++)
20 | {
21 | ans.Add(GetSet(input, n, counter)); //O(2^n)
22 | }
23 | ans.ForEach(s => Console.WriteLine(s));
24 | return ans;
25 | }
26 |
27 | public static string GetSet(string input, int n, int counter)
28 | {
29 | var s = new StringBuilder();
30 |
31 | for (int j = 0; j < n; j++)
32 | {
33 | //Console.WriteLine((counter ) +" & " +(1 << j)+" = "+(counter & (1 << j)));
34 | if ((counter & (1 << j)) > 0)
35 | {
36 | s.Append(input[j]);
37 | }
38 | }
39 | // Console.WriteLine("-----------------------------");
40 | return s.ToString();
41 | }
42 | }
43 | }
44 |
45 |
--------------------------------------------------------------------------------
/3-Algorithms/Algorithms/Algorithms/1-Recursion/4-Recursion VS Iteration/Fibonacci.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Algorithms.Recursion
6 | {
7 | class Fibonacci
8 | {
9 | // Fibonacci Sequence = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610 ......
10 | public static int UsingItteration(int index)
11 | {
12 |
13 | var fibSeq = new List { 0, 1 };
14 | for (int i = 2; i <= index; i++)
15 | {
16 | fibSeq.Add(fibSeq[i - 1] + fibSeq[i - 2]);
17 | }
18 |
19 | return fibSeq[index];
20 | }
21 |
22 |
23 |
24 | public static int UsingRecursion(int index)
25 | {
26 | if (index < 2)
27 | {
28 | return index;
29 | }
30 | return UsingRecursion(index - 1) + UsingRecursion(index - 2);
31 |
32 | //Fib(5) = Fib(4) + Fib(3)
33 |
34 | // Fib(3) + Fib(2) Fib(2) + Fib(1)
35 |
36 | // Fib(2) + Fib(1) Fib(1) + Fib(0) Fib(1) + Fib(0) 1
37 |
38 | // Fib(1) + Fib(0) 1 1 + 0 1 + 0
39 |
40 | // 1 + 0
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/3-Algorithms/Algorithms/Algorithms/4-Sorting/5-QuickSort.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | class QuickSort
4 | {
5 |
6 | static void Swap(int[] arr, int i, int j)
7 | {
8 | int temp = arr[i];
9 | arr[i] = arr[j];
10 | arr[j] = temp;
11 | }
12 |
13 | /*
14 | This function takes last element as pivot, places
15 | the pivot element at its correct position in sorted
16 | array, and places all smaller (smaller than pivot)
17 | to left of pivot and all greater elements to right
18 | of pivot
19 | */
20 | static int Partition(int[] arr, int low, int high)
21 | {
22 |
23 |
24 | int pivot = arr[high];
25 |
26 | //i : index of smaller element
27 | //j : index of greater element
28 | int i = (low - 1);
29 |
30 | for (int j = low; j <= high - 1; j++)
31 | {
32 | if (arr[j] < pivot)
33 | {
34 | i++;
35 | Swap(arr, i, j);
36 | }
37 | }
38 | Swap(arr, i + 1, high);
39 | return (i + 1);
40 | }
41 |
42 |
43 | public static int[] Sort(int[] arr, int low, int high)
44 | {
45 | if (low < high)
46 | {
47 |
48 | // p is partitioning index, arr[p] is now at right place
49 | int p = Partition(arr, low, high);
50 |
51 | // Separately sort elements before partition and after partition
52 | Sort(arr, low, p - 1);
53 | Sort(arr, p + 1, high);
54 | }
55 | return arr;
56 | }
57 | }
--------------------------------------------------------------------------------
/2-Data Structure/DataStructure/DataStructure/6-Graph/Graph.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace DataStructure.Graph
6 | {
7 | class Graph
8 | {
9 | public int NumOfNodes { get; set; }
10 |
11 | public Dictionary> AdjacentList { get; set; }
12 |
13 | public bool Directed { get; set; }
14 |
15 | public Graph(bool directed =false)
16 | {
17 | Directed = directed;
18 | NumOfNodes = 0;
19 | AdjacentList = new Dictionary>();
20 | }
21 | public void AddVertex(T node)
22 | {
23 | AdjacentList.Add(node, new List());
24 | NumOfNodes++;
25 | }
26 |
27 | public void AddEdge(T node1, T node2)
28 | {
29 | if (Directed)
30 | {
31 | AdjacentList[node1].Add(node2);
32 | return;
33 | }
34 |
35 | AdjacentList[node1].Add(node2);
36 | AdjacentList[node2].Add(node1);
37 | }
38 | public void ShowConnections()
39 | {
40 |
41 | foreach (var item in AdjacentList)
42 | {
43 | List nodeConnections = AdjacentList[item.Key];
44 | StringBuilder connections = new StringBuilder();
45 | for (int i = 0; i < nodeConnections.Count; i++)
46 | {
47 | connections.Append(nodeConnections[i]).Append(" ");
48 | }
49 | Console.WriteLine(item.Key + "-->" + connections);
50 |
51 | }
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/3-Algorithms/Algorithms/Algorithms/3-Searching_Traversing/Helper/GraphDataStructure/Graph.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Algorithms.Searching_Traversing
6 | {
7 | class Graph
8 | {
9 | public int NumOfNodes { get; set; }
10 |
11 | public Dictionary> AdjacentList { get; set; }
12 |
13 | public bool Directed { get; set; }
14 |
15 | public Graph(bool directed = false)
16 | {
17 | Directed = directed;
18 | NumOfNodes = 0;
19 | AdjacentList = new Dictionary>();
20 | }
21 | public void AddVertex(T node)
22 | {
23 | AdjacentList.Add(node, new List());
24 | NumOfNodes++;
25 | }
26 |
27 | public void AddEdge(T node1, T node2)
28 | {
29 | if (Directed)
30 | {
31 | AdjacentList[node1].Add(node2);
32 | return;
33 | }
34 |
35 | AdjacentList[node1].Add(node2);
36 | AdjacentList[node2].Add(node1);
37 | }
38 | public void ShowConnections()
39 | {
40 |
41 | foreach (var item in AdjacentList)
42 | {
43 | List nodeConnections = AdjacentList[item.Key];
44 | StringBuilder connections = new StringBuilder();
45 | for (int i = 0; i < nodeConnections.Count; i++)
46 | {
47 | connections.Append(nodeConnections[i]).Append(" ");
48 | }
49 | Console.WriteLine(item.Key + "-->" + connections);
50 |
51 | }
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/3-Algorithms/Algorithms/Algorithms/3-Searching_Traversing/BreadthFirstSearch/1-BFSforTree.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Algorithms.Searching_Traversing
6 | {
7 | class BFSforTree
8 | {
9 | public static List BFS_Iterative(Node currentNode)
10 | {
11 | List list = new List();
12 | Queue queue = new Queue();
13 | queue.Enqueue(currentNode);
14 |
15 | while (queue.Count > 0)
16 | {
17 | currentNode = queue.Dequeue();
18 | list.Add(currentNode.Value);
19 | if (currentNode.Left != null)
20 | {
21 | queue.Enqueue(currentNode.Left);
22 | }
23 |
24 | if (currentNode.Right != null)
25 | {
26 | queue.Enqueue(currentNode.Right);
27 | }
28 | }
29 | return list;
30 | }
31 |
32 | public static List BFS_Recurcive(Queue queue, List list)
33 | {
34 | if (queue.Count == 0)
35 | {
36 | return list;
37 | }
38 |
39 | var currentNode = queue.Dequeue();
40 | list.Add(currentNode.Value);
41 | if (currentNode.Left != null)
42 | {
43 | queue.Enqueue(currentNode.Left);
44 | }
45 |
46 | if (currentNode.Right != null)
47 | {
48 | queue.Enqueue(currentNode.Right);
49 | }
50 |
51 | return BFS_Recurcive(queue, list);
52 |
53 |
54 | }
55 |
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/2-Data Structure/DataStructure/DataStructure/Program.cs:
--------------------------------------------------------------------------------
1 |
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using DataStructure.Graph;
6 | using DataStructure.HashTable;
7 | using DataStructure.LinkedList;
8 | using DataStructure.Queue;
9 | using DataStructure.Stack;
10 | using DataStructure.Trees.BinaryTree;
11 |
12 | namespace DataStructure
13 | {
14 | class Program
15 | {
16 | static void Main(string[] args)
17 | {
18 | #region 1-Linked List
19 | //LinkedListPractices.CustomSingleLinkedList();
20 | //LinkedListPractices.CsharpBuiltInDoublyLinkedList();
21 | //LinkedListPractices.CustomDoublyLinkedList();
22 | #endregion
23 |
24 | #region 2-Stack
25 | //StackPractices.CsharpBuiltInStack();
26 | //StackPractices.CustomStackUsingLinkedList();
27 | //StackPractices.CustomStackUsingList();
28 | #endregion
29 |
30 | #region 3-Queue
31 | //QueuePractices.CsharpBuiltInQueue();
32 | //QueuePractices.CustomQueueUsingStack();
33 | //QueuePractices.CustomQueueUsingLinkedlist();
34 | #endregion
35 |
36 | #region 4-HashTable
37 | //HashtablePractices.CsharpBuiltInHashtable();
38 | //HashtablePractices.CustomHashtableWithoutHandlingCollision();
39 | //HashtablePractices.HandlingCollisionUsingSeparateChaining();
40 | #endregion
41 |
42 | #region 5-BinarySearchTree
43 | //TreesPractices.CustomBinaryTree();
44 | //TreesPractices.CustomBinarySearchTree();
45 |
46 | #endregion
47 |
48 | #region 6-Graph
49 | //GraphPrctices.CustomGraph();
50 | #endregion
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/2-Data Structure/DataStructure/DataStructure/2-Stack/StackPractices.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace DataStructure.Stack
7 | {
8 | class StackPractices
9 | {
10 | public static void CsharpBuiltInStack()
11 | {
12 | Stack myStack = new Stack();
13 | myStack.Push(1);
14 | myStack.Push(2);
15 | myStack.Push(3);
16 | myStack.Pop();
17 | Console.WriteLine("Element At 0 = " + myStack.ElementAt(0));
18 | Console.WriteLine("Peek = " + myStack.Peek());
19 | Display(myStack);
20 | }
21 |
22 |
23 | public static void CustomStackUsingLinkedList()
24 | {
25 | StackUsingLinkedList myStack = new StackUsingLinkedList();
26 | myStack.Push(1);
27 | myStack.Push(2);
28 | myStack.Push(3);
29 | myStack.Pop();
30 | Console.WriteLine("Element At 0 = " + myStack.ElementAt(0));
31 | Console.WriteLine("Peek = " + myStack.Peek());
32 | myStack.Display();
33 | }
34 |
35 |
36 | public static void CustomStackUsingList()
37 | {
38 | StackUsingList myStack = new StackUsingList();
39 | myStack.Push(1);
40 | myStack.Push(2);
41 | myStack.Push(3);
42 | myStack.Pop();
43 | Console.WriteLine("Peek = " + myStack.Peek());
44 | myStack.Display();
45 | }
46 |
47 |
48 | public static void Display(Stack stack)
49 | {
50 | foreach (T Item in stack)
51 | {
52 | Console.Write(Item + " ");
53 | }
54 | Console.WriteLine("\n");
55 |
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/2-Data Structure/DataStructure/DataStructure/3-Queue/QueuePractices.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace DataStructure.Queue
6 | {
7 | class QueuePractices
8 | {
9 | public static void CsharpBuiltInQueue()
10 | {
11 | Queue myQueue = new Queue();
12 | myQueue.Enqueue(1);
13 | myQueue.Enqueue(2);
14 | myQueue.Enqueue(3);
15 | myQueue.Dequeue();
16 | myQueue.Enqueue(4);
17 | Console.WriteLine("Peek = " + myQueue.Peek());
18 | Display(myQueue);
19 | }
20 |
21 |
22 | public static void CustomQueueUsingStack()
23 | {
24 | QueueUsingStack myQueue = new QueueUsingStack();
25 | myQueue.Enqueue(1);
26 | myQueue.Enqueue(2);
27 | myQueue.Enqueue(3);
28 | myQueue.Dequeue();
29 | myQueue.Enqueue(4);
30 | Console.WriteLine("Peek = " + myQueue.Peek());
31 | myQueue.Display();
32 | }
33 |
34 | public static void CustomQueueUsingLinkedlist()
35 | {
36 | QueueUsingLinkedlist myQueue = new QueueUsingLinkedlist();
37 | myQueue.Enqueue(1);
38 | myQueue.Enqueue(2);
39 | myQueue.Enqueue(3);
40 | myQueue.Dequeue();
41 | myQueue.Enqueue(4);
42 | Console.WriteLine("Peek = " + myQueue.Peek());
43 | myQueue.Display();
44 | }
45 |
46 |
47 |
48 |
49 |
50 | public static void Display(Queue queue)
51 | {
52 | foreach (T Item in queue)
53 | {
54 | Console.Write(Item + " ");
55 | }
56 | Console.WriteLine("\n");
57 |
58 | }
59 |
60 |
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | بسم الله الرحمن الرحيم
4 |
5 |
6 |
7 | # Data Structures And Algorithms
8 |
9 | This is a summary for some of Data Structures And Algorithms in C#
10 |
11 | This summary consists of 3 parts
12 |
13 | 1- Big O
14 |
15 | 2- Data Structures
16 |
17 | 3- Algorithms
18 |
19 | For each part, you will find
20 |
21 | 1- Separate slides folder for each subject derived from this part, please read the slides first
22 |
23 | 2- Simple console application contains an example for each subject derived from this part
24 |
25 |
26 |
27 | ## 1. Big O
28 |
29 | 1.1- Basics
30 |
31 | 1.2- Simplify Big O
32 |
33 | 1.3- Example
34 |
35 |
36 |
37 | 
38 |
39 |
40 |
41 | ## 2- Data Structures
42 |
43 | 2.1- Linked List
44 |
45 | 2.2- Stack
46 |
47 | 2.3- Queue
48 |
49 | 2.4- Hash table
50 |
51 | 2.5- Tree
52 |
53 | 2.6- Gragh
54 |
55 | 
56 |
57 |
58 |
59 | ## 3- Algorithms
60 |
61 | 3.1- Recursion
62 |
63 | 3.2- Dynamic Programming
64 |
65 | 3.3- BFS + DFS
66 |
67 | 3.4- Sorting
68 |
69 | 
70 |
71 |
72 |
73 | ## References
74 |
75 | The main two sources I relied on for this summary are
76 |
77 | Master the Coding Interview: Data Structures + Algorithms
78 |
79 | GeeksforGeeks
80 |
81 | ## Other references
82 |
83 | wikipedia
84 |
85 | Tutorialspoint
86 |
87 | ## أخيرا أرجو من الله ان يكون نافعا
88 |
--------------------------------------------------------------------------------
/2-Data Structure/DataStructure/DataStructure/3-Queue/1-QueueUsingStack.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace DataStructure.Queue
6 | {
7 | class QueueUsingStack
8 | {
9 | private Stack _PushStack = new Stack();
10 | private Stack _PopStack = new Stack();
11 |
12 | public T Peek()
13 | {
14 |
15 |
16 | if (_PopStack.Count == 0)
17 | {
18 | var count = _PushStack.Count;
19 | for (int i = 0; i < count; i++)
20 | {
21 | _PopStack.Push(_PushStack.Pop());
22 | }
23 | }
24 | if (_PopStack.Count > 0)
25 | {
26 | return _PopStack.Peek();
27 | }
28 |
29 |
30 | return default(T);
31 | }
32 |
33 | public void Enqueue(T value)
34 | {
35 | int count = _PopStack.Count;
36 |
37 | for (int i = 0; i < count; i++)
38 | {
39 | _PushStack.Push(_PopStack.Pop());
40 | }
41 |
42 | _PushStack.Push(value);
43 |
44 | }
45 |
46 | public T Dequeue()
47 | {
48 |
49 | int count = _PushStack.Count;
50 | for (int i = 0; i < count; i++)
51 | {
52 | _PopStack.Push(_PushStack.Pop());
53 | }
54 |
55 | return _PopStack.Pop();
56 |
57 | }
58 |
59 | public void Display()
60 | {
61 |
62 | if (_PopStack.Count == 0)
63 | {
64 | var count = _PushStack.Count;
65 | for (int i = 0; i < count; i++)
66 | {
67 | _PopStack.Push(_PushStack.Pop());
68 | }
69 | }
70 | foreach (T Item in _PopStack)
71 | {
72 | Console.Write(Item + " ");
73 | }
74 | Console.WriteLine("\n");
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/2-Data Structure/DataStructure/DataStructure/3-Queue/2- QueueUsingLinkedlist.cs:
--------------------------------------------------------------------------------
1 | using DataStructure.LinkedList;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace DataStructure.Queue
7 | {
8 |
9 |
10 | class QueueUsingLinkedlist
11 | {
12 | public SLLNode First;
13 | public SLLNode Last;
14 | public int Length;
15 |
16 | public QueueUsingLinkedlist()
17 | {
18 | First = null;
19 | Last = null;
20 | Length = 0;
21 | }
22 |
23 | public T Peek()
24 | {
25 | if (Length > 0)
26 | {
27 | return First.Value;
28 | }
29 | return default(T);
30 | }
31 |
32 | public void Enqueue(T value)
33 | {
34 | SLLNode newSLLNode = new SLLNode(value);
35 | if (Length == 0)
36 | {
37 | First = newSLLNode;
38 | Last = newSLLNode;
39 | }
40 | else
41 | {
42 | Last.Next = newSLLNode;
43 | Last = newSLLNode;
44 | }
45 | Length++;
46 | }
47 |
48 | public T Dequeue()
49 | {
50 | if (First == null)
51 | {
52 | return default(T);
53 | }
54 | if (Length == 0)
55 | {
56 | Last = null;
57 | }
58 | SLLNode holdingPointer = First;
59 | First = First.Next;
60 |
61 | Length--;
62 |
63 | return holdingPointer.Value;
64 | }
65 |
66 | public void Display()
67 | {
68 | if (First == null)
69 | {
70 | return;
71 | }
72 | SLLNode currentSLLNode = First;
73 | Console.Write(currentSLLNode.Value);
74 | currentSLLNode = currentSLLNode.Next;
75 | while (currentSLLNode != null)
76 | {
77 | Console.Write(" " + currentSLLNode.Value);
78 | currentSLLNode = currentSLLNode.Next;
79 | }
80 | Console.WriteLine();
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/3-Algorithms/Algorithms/Algorithms/2-DynamicProgramming/Example(Fibonacci)/2-UsingDynamicProramming/1-MemoizedSolution.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Algorithms.DynamicProgramming
6 | {
7 | class MemoizedSolution
8 | {
9 |
10 | // Fibonacci Sequence = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610 ....
11 |
12 |
13 | public Dictionary Cache = new Dictionary();
14 | public int Fib1(int index)
15 | {
16 |
17 | if (index < 2)
18 | {
19 | return index;
20 | }
21 | if (Cache.ContainsKey(index))
22 | {
23 | return Cache[index];
24 | }
25 | else
26 | {
27 | Cache[index] = Fib1(index - 1) + Fib1(index - 2);
28 | return Cache[index];
29 | }
30 | // Fib(6)
31 |
32 | // Fib(5) + Fib(4)
33 |
34 | // Fib(4) + Fib(3)
35 |
36 | // Fib(3) + Fib(2)
37 |
38 | // Fib(2) + Fib(1)
39 | }
40 |
41 | public Func Fib2()
42 | {
43 | var cache = new Dictionary();
44 |
45 | return (index) =>
46 | {
47 | if (index < 2)
48 | {
49 | return index;
50 | }
51 |
52 | if (cache.ContainsKey(index))
53 | {
54 | return cache[index];
55 | }
56 |
57 | else
58 | {
59 | cache[index] = Fib2()(index - 1) + Fib2()(index - 2);
60 |
61 | return cache[index];
62 | }
63 |
64 | };
65 |
66 | // Fib(6)
67 |
68 | // Fib(5) + Fib(4)
69 |
70 | // Fib(4) + Fib(3)
71 |
72 | // Fib(3) + Fib(2)
73 |
74 | // Fib(2) + Fib(1)
75 | }
76 | }
77 | }
78 |
79 |
--------------------------------------------------------------------------------
/2-Data Structure/DataStructure/DataStructure/1-LinkedList/LinkedListPractices.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace DataStructure.LinkedList
6 | {
7 | class LinkedListPractices
8 | {
9 |
10 |
11 | public static void CustomSingleLinkedList()
12 | {
13 | SingleLinkedList sentence = new SingleLinkedList();
14 | sentence.AddFirst("This");
15 | sentence.AddLast("Is");
16 | sentence.AddLast("Linked");
17 | sentence.AddLast("List");
18 | sentence.AddLast("Lesson");
19 | sentence.Remove(4);
20 | SLLNode IsNode2 = sentence.Find(2);
21 | sentence.AddAfter(IsNode2, "The");
22 | sentence.Display();
23 |
24 | sentence.Reverse();
25 | sentence.Display();
26 |
27 | }
28 |
29 | public static void CsharpBuiltInDoublyLinkedList()
30 | {
31 | LinkedList sentence = new LinkedList();
32 | sentence.AddFirst("This");
33 | sentence.AddLast("Is");
34 | sentence.AddLast("Linked");
35 | sentence.AddLast("List");
36 | sentence.AddLast("Lesson");
37 | LinkedListNode IsNode = sentence.Find("Is");
38 | sentence.AddAfter(IsNode, "The");
39 | Display(sentence);
40 | }
41 |
42 |
43 | public static void CustomDoublyLinkedList()
44 | {
45 | DoublyLinkedLists sentence = new DoublyLinkedLists();
46 | sentence.AddFirst("This");
47 | sentence.AddLast("Is");
48 | sentence.AddLast("Linked");
49 | sentence.AddLast("List");
50 | sentence.AddLast("Lesson");
51 | DLLNode IsNode2 = sentence.Find("Is");
52 | sentence.AddAfter(IsNode2, "The");
53 | sentence.Display();
54 |
55 | //sentence.Reverse();
56 | //sentence.Display();
57 |
58 | }
59 |
60 |
61 |
62 |
63 |
64 | public static void Display(LinkedList linkedList)
65 | {
66 |
67 | foreach (T Item in linkedList)
68 | {
69 | Console.Write(Item + " ");
70 | }
71 | Console.WriteLine();
72 | Console.WriteLine();
73 | }
74 |
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/2-Data Structure/DataStructure/DataStructure/4-HashTable/HashtablePractices.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace DataStructure.HashTable
7 | {
8 | class HashtablePractices
9 | {
10 | public static void CsharpBuiltInHashtable()
11 | {
12 | Hashtable myHashtable = new Hashtable();
13 | myHashtable.Add("First", "One");
14 | myHashtable.Add("Second", "Two");
15 | myHashtable.Add("Third", "Three");
16 | myHashtable.Add("Four", "Three");
17 | myHashtable.Add(9, "Nine");
18 | myHashtable.Remove(9);
19 | Console.WriteLine(myHashtable["Third"]);
20 |
21 | Display(myHashtable);
22 |
23 |
24 |
25 | }
26 |
27 | public static void CustomHashtableWithoutHandlingCollision()
28 | {
29 | CustomHashTable myHashtable = new CustomHashTable();
30 | myHashtable.Add("First", "One");
31 | myHashtable.Add("Second", "Two");
32 | myHashtable.Add("Third", "Three");
33 | myHashtable.Add("Four", "Three");
34 | myHashtable.Add(9, "Nine");
35 | //myHashtable.Add(8, "Eight"); // will make collision with First because (First and 8) keys have the same hash which equals 6
36 |
37 | myHashtable.Remove(9);
38 | Console.WriteLine(myHashtable["Third"]);
39 |
40 | myHashtable.Display();
41 |
42 | }
43 |
44 | public static void Display(Hashtable hashTable)
45 | {
46 | foreach (DictionaryEntry de in hashTable)
47 | Console.WriteLine("Key: {0}, Value: {1}", de.Key, de.Value);
48 |
49 | Console.WriteLine("\n\n");
50 | }
51 |
52 |
53 | public static void HandlingCollisionUsingSeparateChaining()
54 | {
55 | CustomHashTable2 myHashtable = new CustomHashTable2();
56 | myHashtable.Add(10, "Mohamed");
57 | myHashtable.Add(11, "Khalid");
58 | myHashtable.Add(12, "Mahmod");
59 | myHashtable.Add(13, "Ibrahim");
60 | myHashtable.Add(14, "Ali");
61 | myHashtable.Add(20, "Moaz");
62 | myHashtable.Remove(14);
63 | Console.WriteLine(myHashtable[20]);
64 |
65 | myHashtable.Display();
66 |
67 | }
68 |
69 |
70 |
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/2-Data Structure/DataStructure/DataStructure/2-Stack/1-StackUsingLinkedList.cs:
--------------------------------------------------------------------------------
1 | using DataStructure.LinkedList;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace DataStructure.Stack
7 | {
8 |
9 | class StackUsingLinkedList
10 | {
11 | public SLLNode Top;
12 | public SLLNode Bottom;
13 | public int Length;
14 |
15 | public StackUsingLinkedList()
16 | {
17 | Top = null;
18 | Bottom = null;
19 | Length = 0;
20 | }
21 |
22 | public T Peek()
23 | {
24 | if (Length > 0)
25 | return Top.Value;
26 | return default(T);
27 | }
28 |
29 | public void Push(T value)
30 | {
31 | SLLNode newNode = new SLLNode(value);
32 | if (Length == 0)
33 | {
34 | Top = newNode;
35 | Bottom = newNode;
36 | }
37 | else
38 | {
39 | SLLNode holdingPointer = Top;
40 | Top = newNode;
41 | Top.Next = holdingPointer;
42 | }
43 | Length++;
44 | }
45 |
46 | public T Pop()
47 | {
48 | if (Top == null)
49 | {
50 | return default(T);
51 | }
52 | SLLNode holdingPointer = Top;
53 | Top = Top.Next;
54 | Length--;
55 | return holdingPointer.Value;
56 | }
57 |
58 |
59 | public T ElementAt(int index)
60 | {
61 | int counter = 0;
62 | var currentNode = Top;
63 | while (counter != index)
64 | {
65 | currentNode = currentNode.Next;
66 | counter++;
67 | }
68 | return currentNode.Value;
69 | }
70 |
71 |
72 | public void Display()
73 | {
74 | if (Top == null)
75 | {
76 | return;
77 | }
78 | SLLNode currentNode = Top;
79 | Console.Write(currentNode.Value);
80 | currentNode = currentNode.Next;
81 | while (currentNode != null)
82 | {
83 | Console.Write(" " + currentNode.Value);
84 | currentNode = currentNode.Next;
85 | }
86 | Console.WriteLine("\n");
87 | }
88 |
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/3-Algorithms/Algorithms/Algorithms/3-Searching_Traversing/BreadthFirstSearch/2-BFSforGraph.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Algorithms.Searching_Traversing
7 | {
8 | class BFSforGraph
9 | {
10 | public static void BFS(Graph graph, T v)
11 | {
12 | var visited = new List();
13 |
14 |
15 |
16 | Queue queue = new Queue();
17 |
18 | // Mark the current node as
19 | // visited and enqueue it
20 | visited.Add(v);
21 | queue.Enqueue(v);
22 |
23 | while (queue.Any())
24 | {
25 |
26 | v = queue.First();
27 | Console.Write(v + " ");
28 | queue.Dequeue();
29 |
30 | var list = graph.AdjacentList[v];
31 |
32 | foreach (var val in list)
33 | {
34 | if (!visited.Contains(val))
35 | {
36 | visited.Add(val);
37 | queue.Enqueue(val);
38 | }
39 | }
40 | }
41 | }
42 |
43 | public static void BFS(Graph graph)
44 | {
45 | var visited = new List();
46 | foreach (var adj in graph.AdjacentList)
47 | {
48 |
49 |
50 | if (!visited.Contains(adj.Key))
51 | {
52 | Queue queue = new Queue();
53 |
54 | // Mark the current node as
55 | // visited and enqueue it
56 | visited.Add(adj.Key);
57 | queue.Enqueue(adj.Key);
58 |
59 | while (queue.Any())
60 | {
61 |
62 | var v = queue.First();
63 | Console.Write(v + " ");
64 | queue.Dequeue();
65 |
66 | var list = graph.AdjacentList[v];
67 |
68 | foreach (var val in list)
69 | {
70 | if (!visited.Contains(val))
71 | {
72 | visited.Add(val);
73 | queue.Enqueue(val);
74 | }
75 | }
76 | }
77 | }
78 | }
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/3-Algorithms/Algorithms/Algorithms/4-Sorting/4-MergeSort.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | class MergeSort
4 | {
5 |
6 | public static int T (int n)
7 | {
8 | if (n <= 1)
9 | return 0;
10 |
11 | return 2 * T(n / 2) + n;
12 |
13 | }
14 |
15 | #region Divide Part
16 | public static int[] Sort(int[] array)
17 | {
18 |
19 | //As this is a recursive algorithm, we need to have a base case to
20 | //avoid an infinite recursion and therfore a stackoverflow
21 | if (array.Length <= 1)
22 | return array;
23 |
24 |
25 |
26 | int[] left;
27 | int[] right;
28 |
29 | int midPoint = array.Length / 2;
30 | var leftLen = array.Length - midPoint;
31 | var rightLen = midPoint;
32 | left = new int[leftLen];
33 | right = new int[rightLen];
34 |
35 |
36 | for (int i = 0; i < leftLen; i++)
37 | left[i] = array[i];
38 |
39 | for (int i = leftLen; i < array.Length; i++)
40 | right[i - (leftLen)] = array[i];
41 |
42 | left = Sort(left);
43 | right = Sort(right);
44 |
45 | //Merge our two sorted arrays
46 | return Merge(left, right);
47 |
48 | }
49 | #endregion
50 |
51 | #region Conquer Part
52 | private static int[] Merge(int[] left, int[] right)
53 | {
54 | var leftLength = left.Length;
55 | var rightLength = right.Length;
56 | int resultLength = right.Length + left.Length;
57 | int[] result = new int[resultLength];
58 |
59 | int leftindex = 0, rightIndex = 0, resultIndex = 0;
60 |
61 |
62 | while (leftindex < leftLength && rightIndex < rightLength)
63 | {
64 | if (left[leftindex] <= right[rightIndex])
65 | {
66 | result[resultIndex] = left[leftindex];
67 | leftindex++;
68 | }
69 | else
70 | {
71 | result[resultIndex] = right[rightIndex];
72 | rightIndex++;
73 | }
74 | resultIndex++;
75 | }
76 |
77 | // Copy remaining elements of L[] if any
78 | while (leftindex < leftLength)
79 | {
80 | result[resultIndex] = left[leftindex];
81 | leftindex++;
82 | resultIndex++;
83 | }
84 |
85 | // Copy remaining elements of R[] if any
86 | while (rightIndex < rightLength)
87 | {
88 | result[resultIndex] = right[rightIndex];
89 | rightIndex++;
90 | resultIndex++;
91 | }
92 | return result;
93 | }
94 | #endregion
95 |
96 | }
97 |
98 |
--------------------------------------------------------------------------------
/1- Big O/BigO/BigO/1-Basics/7-O(nLogn).cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace BigO
6 | {
7 | class MergeSort
8 | {
9 |
10 | #region Divide Part
11 | public static int[] Sort(int[] array)
12 | {
13 |
14 | //As this is a recursive algorithm, we need to have a base case to
15 | //avoid an infinite recursion and therfore a stackoverflow
16 | if (array.Length <= 1)
17 | return array;
18 |
19 |
20 |
21 | int[] left;
22 | int[] right;
23 |
24 | int midPoint = array.Length / 2;
25 | var leftLen = array.Length - midPoint;
26 | var rightLen = midPoint;
27 | left = new int[leftLen];
28 | right = new int[rightLen];
29 |
30 |
31 | for (int i = 0; i < leftLen; i++)
32 | left[i] = array[i];
33 |
34 | for (int i = leftLen; i < array.Length; i++)
35 | right[i - (leftLen)] = array[i];
36 |
37 | left = Sort(left);
38 | right = Sort(right);
39 |
40 | return Merge(left, right);
41 |
42 | }
43 | #endregion
44 |
45 | #region Conquer Part
46 | private static int[] Merge(int[] left, int[] right)
47 | {
48 | var leftLength = left.Length;
49 | var rightLength = right.Length;
50 | int resultLength = right.Length + left.Length;
51 | int[] result = new int[resultLength];
52 |
53 | int leftindex = 0, rightIndex = 0, resultIndex = 0;
54 |
55 |
56 | while (leftindex < leftLength && rightIndex < rightLength)
57 | {
58 | if (left[leftindex] <= right[rightIndex])
59 | {
60 | result[resultIndex] = left[leftindex];
61 | leftindex++;
62 | }
63 | else
64 | {
65 | result[resultIndex] = right[rightIndex];
66 | rightIndex++;
67 | }
68 | resultIndex++;
69 | }
70 |
71 | // Copy remaining elements of L[] if any
72 | while (leftindex < leftLength)
73 | {
74 | result[resultIndex] = left[leftindex];
75 | leftindex++;
76 | resultIndex++;
77 | }
78 |
79 | // Copy remaining elements of R[] if any
80 | while (rightIndex < rightLength)
81 | {
82 | result[resultIndex] = right[rightIndex];
83 | rightIndex++;
84 | resultIndex++;
85 | }
86 | return result;
87 | }
88 | #endregion
89 |
90 | }
91 | }
92 |
93 |
--------------------------------------------------------------------------------
/2-Data Structure/DataStructure/DataStructure/4-HashTable/1-WithoutHandlingCollision/1-CustomHashTable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace DataStructure.HashTable
7 | {
8 |
9 |
10 | class CustomHashTable
11 | {
12 |
13 | Dictionary