master f10437d8129b cached
313 files
481.8 KB
143.8k tokens
1293 symbols
1 requests
Download .txt
Showing preview only (564K chars total). Download the full file or copy to clipboard to get everything.
Repository: BaReinhard/Hacktoberfest-Data-Structure-and-Algorithms
Branch: master
Commit: f10437d8129b
Files: 313
Total size: 481.8 KB

Directory structure:
gitextract_z9vtg38d/

├── .gitignore
├── .vscode/
│   └── settings.json
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── algorithms/
│   ├── EuclideanAlgorithm/
│   │   ├── c/
│   │   │   └── euclid.c
│   │   └── python/
│   │       └── euclideanAlgorithm.py
│   ├── Graph/
│   │   └── connected_components_in_undirected_graph/
│   │       └── python/
│   │           └── ConnectedComponents.py
│   ├── a_search/
│   │   └── cpp/
│   │       └── a_star.cpp
│   ├── backtracking/
│   │   └── c/
│   │       ├── n_queens_problem.c
│   │       ├── rat_in_a_maze_problem.c
│   │       ├── sudoku_problem.c
│   │       └── the_knight_tour_problem.c
│   ├── bellman_ford/
│   │   ├── cpp/
│   │   │   └── bellman_ford.cpp
│   │   └── java/
│   │       └── BellmanFord.java
│   ├── bfs/
│   │   ├── cpp/
│   │   │   └── bfs.cpp
│   │   └── java/
│   │       └── Graph.java
│   ├── binary_search/
│   │   ├── PHP/
│   │   │   └── binarysearch.php
│   │   ├── binary_search.md
│   │   ├── c/
│   │   │   └── binary_search.c
│   │   ├── cpp/
│   │   │   └── binary_search.cpp
│   │   ├── java/
│   │   │   └── binarysearch.java
│   │   ├── javascript/
│   │   │   └── binary_search.js
│   │   ├── python/
│   │   │   └── binary_search.py
│   │   └── ruby/
│   │       └── binary_search.rb
│   ├── bipartite_check/
│   │   └── cpp/
│   │       └── bipartite.cpp
│   ├── bitwise/
│   │   ├── cpp/
│   │   │   └── generating_subsets.cpp
│   │   └── java/
│   │       ├── AddTwoNumbersWithoutPlusOperator.java
│   │       ├── BinaryPalidrome.java
│   │       ├── NegateANumberWithoutPlusOperator.java
│   │       ├── Optimized_permutation
│   │       └── Subsets.java
│   ├── bogo_sort/
│   │   ├── java/
│   │   │   └── BogoSort.java
│   │   ├── python/
│   │   │   └── bogo.py
│   │   └── ruby/
│   │       └── bogo_sort.rb
│   ├── breadth_first_search/
│   │   └── cpp/
│   │       └── bfs.cpp
│   ├── bubble_sort/
│   │   ├── README.md
│   │   ├── assembly_mips/
│   │   │   └── bubble_sort.asm
│   │   ├── bash/
│   │   │   └── bubblesort.sh
│   │   ├── c/
│   │   │   └── bubble_sort.c
│   │   ├── cpp/
│   │   │   ├── bubble_sort_1.cpp
│   │   │   └── bubblesort.cpp
│   │   ├── crystal/
│   │   │   └── bubble_sort.cr
│   │   ├── csharp/
│   │   │   └── BubbleSort.cs
│   │   ├── elixir/
│   │   │   ├── README.md
│   │   │   └── bubblesort.ex
│   │   ├── go/
│   │   │   └── bubble-sort-algorithm.go
│   │   ├── haskell/
│   │   │   └── bubble_sort.hs
│   │   ├── java/
│   │   │   ├── BubbleSortExample.java
│   │   │   └── GenericBubbleSort.java
│   │   ├── javascript/
│   │   │   ├── bubble-sort.js
│   │   │   ├── bubbleSort.js
│   │   │   └── main_bs.js
│   │   ├── kotlin/
│   │   │   └── bubblesort.kt
│   │   ├── objetive-c/
│   │   │   └── BubbleSort.m
│   │   ├── perl/
│   │   │   └── BubbleSort.pl
│   │   ├── power_shell/
│   │   │   └── bubble_sort.ps1
│   │   ├── python/
│   │   │   └── bubble_sort.py
│   │   ├── ruby/
│   │   │   └── bubble_sort.rb
│   │   ├── swift/
│   │   │   └── bubble_sort.swift
│   │   └── vb/
│   │       └── bubble_sort.bas
│   ├── bucket_sort/
│   │   ├── bucket_sort.cpp
│   │   ├── bucket_sort.java
│   │   ├── bucket_sort.py
│   │   └── c/
│   │       └── bucket_sort.c
│   ├── caesar_cipher/
│   │   ├── java/
│   │   │   └── caesar.java
│   │   └── javascript/
│   │       └── caesarCipher.js
│   ├── check_pallindrome_number/
│   │   ├── c/
│   │   │   └── checkPalindrome.c
│   │   └── cpp/
│   │       └── checkPall.cpp
│   ├── closest/
│   │   └── java/
│   │       └── Closest.java
│   ├── count_sort/
│   │   └── javascript/
│   │       └── count_sort.js
│   ├── cycle_sort/
│   │   └── java/
│   │       └── cycleSort.java
│   ├── decoding/
│   │   └── c/
│   │       └── base64_decoder.c
│   ├── dfs/
│   │   ├── cpp/
│   │   │   └── dfs.cpp
│   │   ├── java/
│   │   │   └── Graph.java
│   │   └── python/
│   │       └── Dfs.py
│   ├── dijkstra/
│   │   ├── cpp/
│   │   │   └── Dijkstras.cpp
│   │   ├── java/
│   │   │   └── ShortestPath.java
│   │   └── python/
│   │       └── djikstra.py
│   ├── doomsday/
│   │   ├── java/
│   │   │   └── doomsday.java
│   │   └── javascript/
│   │       └── doomsday.js
│   ├── dynamic_programming/
│   │   ├── c/
│   │   │   ├── 0_1_knapsack_problem.c
│   │   │   ├── Coin_change_DP.c
│   │   │   ├── coinChange.c
│   │   │   ├── count_no_of_ways_to_reach_nth_stair.c
│   │   │   ├── longestIncreasingSubsequence.c
│   │   │   ├── longestRepeatedSequence.c
│   │   │   ├── longest_pallindrome_sequence.c
│   │   │   ├── maxSumIncSequence.c
│   │   │   └── subsetSum.c
│   │   ├── cpp/
│   │   │   ├── kadens.cpp
│   │   │   ├── nCr.cpp
│   │   │   └── subset_sum.cpp
│   │   └── java/
│   │       └── MinCostPath.java
│   ├── encoding/
│   │   └── base64_encoder.c
│   ├── fibonacci/
│   │   └── cpp/
│   │       └── constexpr-fibonacci.cpp
│   ├── floyd_warshall/
│   │   └── java/
│   │       └── ShortestPath.java
│   ├── greedy_search/
│   │   └── cpp/
│   │       └── prims_algorithm.cpp
│   ├── heap_sort/
│   │   ├── crystal/
│   │   │   └── heap_sort.cr
│   │   ├── java/
│   │   │   ├── heap_sort.java
│   │   │   └── heapsort.java
│   │   ├── javascript/
│   │   │   └── heap_sort.js
│   │   └── python/
│   │       └── heap_sort.py
│   ├── histogram_equalization/
│   │   └── java/
│   │       └── HistogramEqualization.java
│   ├── huffmann_algorithm/
│   │   └── java/
│   │       └── Huffman.java
│   ├── insertion_sort/
│   │   ├── ada/
│   │   │   └── insertion_sort.adb
│   │   ├── c/
│   │   │   └── InsertionSort.c
│   │   ├── cpp/
│   │   │   └── insertion_sort.cpp
│   │   ├── crystal/
│   │   │   └── insertion_sort.cr
│   │   ├── java/
│   │   │   └── InsertionSort.java
│   │   ├── javascript/
│   │   │   ├── insertionSort.js
│   │   │   └── insertion_sort.js
│   │   ├── python/
│   │   │   └── insertionsort.py3
│   │   └── ruby/
│   │       └── insertion_sort.rb
│   ├── inversion_count/
│   │   └── cpp/
│   │       └── inversion_count.cpp
│   ├── jarvis/
│   │   └── cpp/
│   │       └── jarvis.cpp
│   ├── johnson_algorithm/
│   │   └── cpp/
│   │       └── johnson_algorithm.cpp
│   ├── kmp_search/
│   │   ├── cpp/
│   │   │   └── KMPSearch.cpp
│   │   ├── java/
│   │   │   └── KMPSearch.java
│   │   └── python/
│   │       └── KMPSearch.py
│   ├── linear_search/
│   │   ├── c/
│   │   │   └── linearsearch.C
│   │   ├── cpp/
│   │   │   └── linearSearch.cpp
│   │   ├── java/
│   │   │   └── LinearSearch.java
│   │   ├── javascript/
│   │   │   └── linear_search.js
│   │   └── python/
│   │       └── linear_search.py
│   ├── longest_common_subsequence/
│   │   ├── cpp/
│   │   │   └── LongestCommonSubsequence.cpp
│   │   ├── javaj/
│   │   │   └── LCS.java
│   │   ├── javascript/
│   │   │   └── longest_common_subsequence.js
│   │   └── python/
│   │       └── LCS.py
│   ├── longest_common_substring/
│   │   └── java/
│   │       └── LongestCommonSubString.java
│   ├── matrix_chain_multiplication/
│   │   ├── cpp/
│   │   │   └── MCM.cpp
│   │   ├── java/
│   │   │   └── MCM.java
│   │   └── python/
│   │       └── MCM.py
│   ├── merge_sort/
│   │   ├── c#/
│   │   │   └── MergeSort.cs
│   │   ├── cpp/
│   │   │   └── merge_sort.cpp
│   │   ├── haskell/
│   │   │   └── merge_sort.hs
│   │   ├── java/
│   │   │   └── merge_sort.java
│   │   ├── javascript/
│   │   │   └── MergeSort.js
│   │   ├── python/
│   │   │   └── merge_sort.py
│   │   └── ruby/
│   │       └── merge_sort.rb
│   ├── minimum_spanning_tree/
│   │   └── cpp/
│   │       └── MST.cpp
│   ├── optimal_binary_search_tree/
│   │   └── java/
│   │       └── OptimalBst.java
│   ├── parse_tree/
│   │   └── python/
│   │       └── parse_tree.py
│   ├── permutations/
│   │   ├── java/
│   │   │   └── Permutation.java
│   │   └── javascript/
│   │       └── permutations.js
│   ├── quick_sort/
│   │   ├── ada/
│   │   │   └── quick_sort.adb
│   │   ├── c/
│   │   │   └── quick_sort.c
│   │   ├── cpp/
│   │   │   └── quickSort.cpp
│   │   ├── csharp/
│   │   │   ├── QuickSort.cs
│   │   │   └── quicksort.cs
│   │   ├── haskell/
│   │   │   └── quicksort.hs
│   │   ├── java/
│   │   │   └── QuickSort.java
│   │   ├── javascript/
│   │   │   └── quick_sort.js
│   │   ├── kotlin/
│   │   │   └── quicksort.kt
│   │   ├── python/
│   │   │   └── quicksort.py
│   │   └── ruby/
│   │       └── quick_sort.rb
│   ├── rabin_karp/
│   │   └── java/
│   │       └── RabinKarp.java
│   ├── radixsort/
│   │   ├── c++/
│   │   │   └── radixsort.cpp
│   │   └── python/
│   │       └── lsd_radixsort.py
│   ├── selection_sort/
│   │   ├── c/
│   │   │   └── SelectionSort.c
│   │   ├── crystal/
│   │   │   └── selection_sort.cr
│   │   ├── java/
│   │   │   └── SelectionSort.java
│   │   ├── javascript/
│   │   │   └── selection_sort.js
│   │   ├── python/
│   │   │   └── selection_sort.py
│   │   └── ruby/
│   │       └── selection_sort.rb
│   ├── shell_sort/
│   │   ├── C/
│   │   │   └── ShellSort.c
│   │   ├── C++/
│   │   │   └── ShellSort.cpp
│   │   ├── Java/
│   │   │   └── ShellSort.java
│   │   └── python/
│   │       └── shellsort.py
│   ├── sieve_of_eratosthenes/
│   │   ├── cpp/
│   │   │   └── sieve_of_eratosthenes.cpp
│   │   ├── java/
│   │   │   └── sieve.java
│   │   ├── javascript/
│   │   │   └── sieve.js
│   │   └── python/
│   │       └── sieve.py
│   ├── sort/
│   │   └── heap_sort/
│   │       └── java/
│   │           └── heap_sort.java
│   ├── strings/
│   │   └── cpp/
│   │       └── anagrams.cpp
│   └── tower_of_hanoi/
│       ├── cpp/
│       │   └── tower_of_hanoi.cpp
│       ├── java/
│       │   └── towers_of_hanoi.java
│       ├── javascript/
│       │   └── tower_of_hanoi.js
│       ├── php/
│       │   └── towers_of_hanoi.php
│       └── python/
│           └── tower_of_hanoi.py
├── data_structures/
│   ├── arraylist/
│   │   └── java/
│   │       └── arraylist.java
│   ├── avl_tree/
│   │   ├── java/
│   │   │   └── AVL.java
│   │   └── javascript/
│   │       └── avl.js
│   ├── bag/
│   │   └── java/
│   │       └── Bag.java
│   ├── binary_search_tree/
│   │   ├── binary_search_tree.md
│   │   ├── c/
│   │   │   └── BSTtraversal.c
│   │   ├── cpp/
│   │   │   └── BST.h
│   │   ├── java/
│   │   │   ├── binary_search_tree.java
│   │   │   └── bst_operations/
│   │   │       ├── CheckBST.java
│   │   │       ├── CorrectBST.java
│   │   │       ├── FindAncestor.java
│   │   │       ├── InorderSuccessor.java
│   │   │       ├── LargestBST.java
│   │   │       ├── LevelOrder.java
│   │   │       ├── MorrisTraversal.java
│   │   │       ├── Node.java
│   │   │       └── PathFromRootToNode.java
│   │   ├── javascript/
│   │   │   ├── binary_tree.js
│   │   │   ├── binary_tree_search.js
│   │   │   ├── breadth_first_search.js
│   │   │   └── depth_first_search.js
│   │   └── python/
│   │       ├── bst.py
│   │       ├── bst1.py
│   │       └── bst2.py
│   ├── binary_tree/
│   │   ├── c/
│   │   │   └── diameterBT.c
│   │   ├── cpp/
│   │   │   ├── binary_tree.cpp
│   │   │   └── boundaryTraversal.cpp
│   │   ├── csharp/
│   │   │   └── BinaryTree.cs
│   │   ├── java/
│   │   │   ├── binary_tree_bfs.java
│   │   │   └── binary_tree_dfs.java
│   │   └── python/
│   │       └── binary_tree.py
│   ├── bloom_filter/
│   │   └── python/
│   │       └── bloom_filter.py
│   ├── circular_queue/
│   │   ├── circular_queue.md
│   │   ├── cpp/
│   │   │   └── circular queue.cpp
│   │   ├── java/
│   │   │   └── circular_queue.java
│   │   └── python/
│   │       └── circular_queue.py
│   ├── d_heap/
│   │   └── c/
│   │       └── d_heap.c
│   ├── dimaeter_of_a_tree/
│   │   ├── cpp/
│   │   │   └── Diameter.cpp
│   │   ├── diameter_of_a_tree.md
│   │   └── java/
│   │       └── Diameter.java
│   ├── double_linked_list/
│   │   └── cpp/
│   │       └── doublelinkedlist.cpp
│   ├── doubly_linked_list/
│   │   ├── java/
│   │   │   └── DoublyLinkedList.java
│   │   └── python/
│   │       └── DoublyLinkedList.py
│   ├── generic_tree/
│   │   └── java/
│   │       └── gt.java
│   ├── graph/
│   │   ├── cpp/
│   │   │   └── graph.cpp
│   │   └── python/
│   │       └── graph.py
│   ├── hash_table/
│   │   ├── cpp/
│   │   │   └── hashtable.h
│   │   ├── csharp/
│   │   │   └── hash_table.cs
│   │   ├── java/
│   │   │   └── Hash_table.java
│   │   └── python/
│   │       └── hashTable.py
│   ├── hashmap/
│   │   └── java/
│   │       └── hashmap.java
│   ├── hashset/
│   │   └── java/
│   │       └── hashset.java
│   ├── heap/
│   │   ├── cpp/
│   │   │   └── MinHeap.h
│   │   ├── java/
│   │   │   ├── Heap.java
│   │   │   └── heaps.java
│   │   ├── python/
│   │   │   └── minheap.py
│   │   └── ruby/
│   │       └── heap.rb
│   ├── heapify_insert_extract_min/
│   │   └── cpp/
│   │       └── max-heap_functions.cpp
│   ├── left_learning_red_black_tree/
│   │   ├── c/
│   │   │   └── llrb_tree.c
│   │   └── java/
│   │       └── left_leaning_red_black_tree.java
│   ├── linked_list/
│   │   ├── c/
│   │   │   └── linked_list.c
│   │   ├── cpp/
│   │   │   ├── LinkedList.cpp
│   │   │   └── singly_linked_list.cpp
│   │   ├── csharp/
│   │   │   └── LinkedList.cs
│   │   ├── go/
│   │   │   └── linked_list.go
│   │   ├── java/
│   │   │   ├── LinkedList.java
│   │   │   ├── LinkedListLinkedList.java
│   │   │   └── LinkedListTest.java
│   │   ├── kotlin/
│   │   │   └── LinkedList.kt
│   │   ├── linked_list.md
│   │   ├── python/
│   │   │   └── linked_list.py
│   │   └── ruby/
│   │       └── linked_list.rb
│   ├── linked_list_queue/
│   │   └── cpp/
│   │       └── queue_linked_list.cpp
│   ├── min_heap/
│   │   └── cpp/
│   │       ├── impl_minHeap.cpp
│   │       ├── minHeap.cpp
│   │       └── minHeap.hpp
│   ├── mirror_of_a_tree.java/
│   │   └── java/
│   │       └── Mirror.java
│   ├── mirrot_of_a_tree.cpp/
│   │   └── mirror.cpp
│   ├── mst/
│   │   ├── cpp/
│   │   │   └── mst.cpp
│   │   └── java/
│   │       └── prims.java
│   ├── priority_queue/
│   │   └── c/
│   │       └── priority_queue.cpp
│   ├── queue/
│   │   ├── c/
│   │   │   └── queue.c
│   │   ├── cpp/
│   │   │   ├── Queue.cpp
│   │   │   └── Queue.h
│   │   ├── csharp/
│   │   │   └── Queue.cs
│   │   ├── go/
│   │   │   └── queue.go
│   │   ├── java/
│   │   │   └── IterableQueue.java
│   │   ├── javascript/
│   │   │   ├── queue_ES5.js
│   │   │   └── queue_ES6.js
│   │   ├── kotlin/
│   │   │   └── IterableQueue.kt
│   │   ├── php/
│   │   │   └── queue.php
│   │   ├── python/
│   │   │   └── queue_two_stacks.py
│   │   └── ruby/
│   │       └── queue.rb
│   ├── simple_queue/
│   │   ├── java/
│   │   │   ├── QueueImplementation.java
│   │   │   ├── arrayQueue.java
│   │   │   └── queue.java
│   │   ├── python/
│   │   │   └── queue.py
│   │   └── simple_queue.md
│   ├── stack/
│   │   ├── c/
│   │   │   └── stack1.c
│   │   ├── c#/
│   │   │   ├── main.cs
│   │   │   └── stack.cs
│   │   ├── cpp/
│   │   │   ├── celement.h
│   │   │   ├── cstack.cpp
│   │   │   ├── cstack.h
│   │   │   ├── cstack.test.cpp
│   │   │   ├── stack_balanced_paranthesis.cpp
│   │   │   ├── templated_stack.cpp
│   │   │   └── templated_stack.hpp
│   │   ├── crystal/
│   │   │   └── stack.cr
│   │   ├── csharp/
│   │   │   └── Stack.cs
│   │   ├── go/
│   │   │   └── stack.go
│   │   ├── java/
│   │   │   ├── Node.java
│   │   │   ├── Stack.java
│   │   │   └── integer_stack.java
│   │   ├── javascript/
│   │   │   ├── stack.js
│   │   │   └── usingstack.js
│   │   ├── lisp/
│   │   │   ├── Stack.bak
│   │   │   └── Stack.rkt
│   │   ├── php/
│   │   │   └── stack.php
│   │   ├── python/
│   │   │   └── stack.py
│   │   └── ruby/
│   │       └── stack.rb
│   ├── treemap/
│   │   └── java/
│   │       └── treemap.java
│   ├── treeset/
│   │   └── java/
│   │       └── treeset.java
│   ├── trie/
│   │   ├── Trie.md
│   │   ├── java/
│   │   │   └── Trie.java
│   │   └── javascript/
│   │       └── Trie.js
│   └── union_find/
│       ├── cpp/
│       │   └── UnionFind.cpp
│       ├── java/
│       │   └── UnionFind.java
│       ├── python/
│       │   └── UnionFind.py
│       └── union_find.md
├── design_patterns/
│   └── behavioral/
│       └── javascript/
│           ├── mediator-example.js
│           └── mediator.js
└── package.json

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
*.out
javascript/node_modules
.idea

================================================
FILE: .vscode/settings.json
================================================
{
  "files.associations": {
    "vector": "cpp"
  }
}

================================================
FILE: CONTRIBUTING.md
================================================
# Contributing to this repo
**Implementing new File/Directory Structure**
* Try to keep things as modular as possible, the new file/directory structure should be: 
```
/data_structures/structure/language/file
ex: /data_structures/char_stack/cpp/cstack.cpp
/algorithms/algorithm/language/file
ex: /algorithms/bubble_sort/cpp/bubble_sort.cpp
```

## How To:

1. `git clone https://github.com/bareinhard/Hacktoberfest-Data-Structure-and-Algorithms`
2. `git checkout -b <Your-Branch-Name-Here>`
3. Code your files in the proper directory based on the instructions above
4. add all your files `git add your/directory/path/to/file/` (see new directory structure above)
5. commit your file changes `git commit -m "Whatever you did here, e.g. created linkedlist class in C++"`
6. push your changes `git push origin <Your-Branch-Name-Here>`
7. Create a Pull Request to master

### Alternate via Web

1. Fork Repo on Web Page
2. Make your changes on your forked repo
3. Make Pull Request to master


================================================
FILE: LICENSE
================================================
                    GNU GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The GNU General Public License is a free, copyleft license for
software and other kinds of works.

  The licenses for most software and other practical works are designed
to take away your freedom to share and change the works.  By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.  We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors.  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.

  To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights.  Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received.  You must make sure that they, too, receive
or can get the source code.  And you must show them these terms so they
know their rights.

  Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.

  For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software.  For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.

  Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so.  This is fundamentally incompatible with the aim of
protecting users' freedom to change the software.  The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable.  Therefore, we
have designed this version of the GPL to prohibit the practice for those
products.  If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.

  Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary.  To prevent this, the GPL assures that
patents cannot be used to render the program non-free.

  The precise terms and conditions for copying, distribution and
modification follow.

                       TERMS AND CONDITIONS

  0. Definitions.

  "This License" refers to version 3 of the GNU General Public License.

  "Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.

  "The Program" refers to any copyrightable work licensed under this
License.  Each licensee is addressed as "you".  "Licensees" and
"recipients" may be individuals or organizations.

  To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy.  The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.

  A "covered work" means either the unmodified Program or a work based
on the Program.

  To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy.  Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.

  To "convey" a work means any kind of propagation that enables other
parties to make or receive copies.  Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.

  An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License.  If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.

  1. Source Code.

  The "source code" for a work means the preferred form of the work
for making modifications to it.  "Object code" means any non-source
form of a work.

  A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.

  The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form.  A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.

  The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities.  However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work.  For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.

  The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.

  The Corresponding Source for a work in source code form is that
same work.

  2. Basic Permissions.

  All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met.  This License explicitly affirms your unlimited
permission to run the unmodified Program.  The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work.  This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.

  You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force.  You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright.  Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.

  Conveying under any other circumstances is permitted solely under
the conditions stated below.  Sublicensing is not allowed; section 10
makes it unnecessary.

  3. Protecting Users' Legal Rights From Anti-Circumvention Law.

  No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.

  When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.

  4. Conveying Verbatim Copies.

  You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.

  You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.

  5. Conveying Modified Source Versions.

  You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:

    a) The work must carry prominent notices stating that you modified
    it, and giving a relevant date.

    b) The work must carry prominent notices stating that it is
    released under this License and any conditions added under section
    7.  This requirement modifies the requirement in section 4 to
    "keep intact all notices".

    c) You must license the entire work, as a whole, under this
    License to anyone who comes into possession of a copy.  This
    License will therefore apply, along with any applicable section 7
    additional terms, to the whole of the work, and all its parts,
    regardless of how they are packaged.  This License gives no
    permission to license the work in any other way, but it does not
    invalidate such permission if you have separately received it.

    d) If the work has interactive user interfaces, each must display
    Appropriate Legal Notices; however, if the Program has interactive
    interfaces that do not display Appropriate Legal Notices, your
    work need not make them do so.

  A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit.  Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.

  6. Conveying Non-Source Forms.

  You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:

    a) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by the
    Corresponding Source fixed on a durable physical medium
    customarily used for software interchange.

    b) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by a
    written offer, valid for at least three years and valid for as
    long as you offer spare parts or customer support for that product
    model, to give anyone who possesses the object code either (1) a
    copy of the Corresponding Source for all the software in the
    product that is covered by this License, on a durable physical
    medium customarily used for software interchange, for a price no
    more than your reasonable cost of physically performing this
    conveying of source, or (2) access to copy the
    Corresponding Source from a network server at no charge.

    c) Convey individual copies of the object code with a copy of the
    written offer to provide the Corresponding Source.  This
    alternative is allowed only occasionally and noncommercially, and
    only if you received the object code with such an offer, in accord
    with subsection 6b.

    d) Convey the object code by offering access from a designated
    place (gratis or for a charge), and offer equivalent access to the
    Corresponding Source in the same way through the same place at no
    further charge.  You need not require recipients to copy the
    Corresponding Source along with the object code.  If the place to
    copy the object code is a network server, the Corresponding Source
    may be on a different server (operated by you or a third party)
    that supports equivalent copying facilities, provided you maintain
    clear directions next to the object code saying where to find the
    Corresponding Source.  Regardless of what server hosts the
    Corresponding Source, you remain obligated to ensure that it is
    available for as long as needed to satisfy these requirements.

    e) Convey the object code using peer-to-peer transmission, provided
    you inform other peers where the object code and Corresponding
    Source of the work are being offered to the general public at no
    charge under subsection 6d.

  A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.

  A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling.  In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage.  For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product.  A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.

  "Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source.  The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.

  If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information.  But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).

  The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed.  Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.

  Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.

  7. Additional Terms.

  "Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law.  If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.

  When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it.  (Additional permissions may be written to require their own
removal in certain cases when you modify the work.)  You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.

  Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:

    a) Disclaiming warranty or limiting liability differently from the
    terms of sections 15 and 16 of this License; or

    b) Requiring preservation of specified reasonable legal notices or
    author attributions in that material or in the Appropriate Legal
    Notices displayed by works containing it; or

    c) Prohibiting misrepresentation of the origin of that material, or
    requiring that modified versions of such material be marked in
    reasonable ways as different from the original version; or

    d) Limiting the use for publicity purposes of names of licensors or
    authors of the material; or

    e) Declining to grant rights under trademark law for use of some
    trade names, trademarks, or service marks; or

    f) Requiring indemnification of licensors and authors of that
    material by anyone who conveys the material (or modified versions of
    it) with contractual assumptions of liability to the recipient, for
    any liability that these contractual assumptions directly impose on
    those licensors and authors.

  All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10.  If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term.  If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.

  If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.

  Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.

  8. Termination.

  You may not propagate or modify a covered work except as expressly
provided under this License.  Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).

  However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.

  Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.

  Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License.  If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.

  9. Acceptance Not Required for Having Copies.

  You are not required to accept this License in order to receive or
run a copy of the Program.  Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance.  However,
nothing other than this License grants you permission to propagate or
modify any covered work.  These actions infringe copyright if you do
not accept this License.  Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.

  10. Automatic Licensing of Downstream Recipients.

  Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License.  You are not responsible
for enforcing compliance by third parties with this License.

  An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations.  If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.

  You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License.  For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.

  11. Patents.

  A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based.  The
work thus licensed is called the contributor's "contributor version".

  A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version.  For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.

  Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.

  In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement).  To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.

  If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients.  "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.

  If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.

  A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License.  You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.

  Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.

  12. No Surrender of Others' Freedom.

  If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all.  For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.

  13. Use with the GNU Affero General Public License.

  Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work.  The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.

  14. Revised Versions of this License.

  The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

  Each version is given a distinguishing version number.  If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation.  If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.

  If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.

  Later license versions may give you additional or different
permissions.  However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.

  15. Disclaimer of Warranty.

  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

  16. Limitation of Liability.

  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

  17. Interpretation of Sections 15 and 16.

  If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

                     END OF TERMS AND CONDITIONS

            How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    {one line to give the program's name and a brief idea of what it does.}
    Copyright (C) {year}  {name of author}

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

  If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

    {project}  Copyright (C) {year}  {fullname}
    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

  You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.

  The GNU General Public License does not permit incorporating your program
into proprietary programs.  If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library.  If this is what you want to do, use the GNU Lesser General
Public License instead of this License.  But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.


================================================
FILE: README.md
================================================
# Hacktoberfest-Data-Structure-and-Algorithms
A repository containing data structures and algorithms, regardless of language.

No longer active

***Not Affiliated with Digital Ocean or Hacktoberfest***

![Hacktoberfest](https://pbs.twimg.com/media/Dn4njsBXkAEQWZs.jpg)

# CONTRIBUTING!

# Contributing to this repo
**Implementing new File/Directory Structure**
* Try to keep things as modular as possible, the new file/directory structure should be:
```
/data_structures/structure/language/file
ex: /data_structures/char_stack/cpp/cstack.cpp
/algorithms/algorithm/language/file
ex: /algorithms/bubble_sort/cpp/bubble_sort.cpp
```



## How To:

1. Fork Repo on Web Page
2. `git clone https://github.com/{your-username}/Hacktoberfest-Data-Structure-and-Algorithms`
3. Code your files in the proper directory based on the instructions above
4. add all your files `git add your/directory/path/to/file/` (see new directory structure above)
5. commit your file changes `git commit -m "Whatever you did here, e.g. created linkedlist class in C++"`
6. push your changes `git push`
7. Create a Pull Request to master on Web Page

### Alternate via Web

1. Fork Repo on Web Page
2. Make your changes on your forked repo
3. Make Pull Request to master

#### Credits
Logo created with: http://logomakr.com


================================================
FILE: algorithms/EuclideanAlgorithm/c/euclid.c
================================================
#include<stdio.h>

int gcd(int x, int y){
	if(x == 0)
		return y;
	return gcd(y % x, x);
}

void main(){
	int hcf, a, b;
	printf("Enter the 2 numbers: ");
	scanf("%d%d",&a, &b);
	hcf = gcd(a, b);
	printf("The HCF is: %d\n",hcf);
}


================================================
FILE: algorithms/EuclideanAlgorithm/python/euclideanAlgorithm.py
================================================
def euclidean(a,b):#for natural numbers a,b
  
  #sanitize the inputs
  a=int(a)
  b=int(b)
  
  if(not(a and b)):#if either are 0
    return(0)
  
  if(b>a):#to have it so a>=b
    temp=a
    a=b
    b=temp
  
  while(1):
    remainder=a%b
    a=b
    b=remainder
    if(b==0):
      return(a)


================================================
FILE: algorithms/Graph/connected_components_in_undirected_graph/python/ConnectedComponents.py
================================================
'''
Question source -- LeetCode
Given n nodes labeled from 0 to n - 1 and a list of undirected edges
(where each edge is a pair of nodes), write a function to find the number
of connected components in an undirected graph.

'''

def countComponents( n, edges):
    """
    :type n: int
    :type edges: List[List[int]]
    :rtype: int
    """
    # finds the path recursively
    def find(data, i):
        if i != data[i]:
            data[i] = find(data, data[i]) 
        return data[i]

    # creates the union find data structure
    def union(data, i, j):
        root_i, root_j = find(data, i), find(data, j)
        if root_i != root_j:
            data[root_i] = root_j

    data = [i for i in range(n)]
    
    for i,j in edges:
        union(data, i, j)
    # set data structure to eliminate the possibilities of duplicates. 
    res = set()

    # union-find the roots of the each nodes in the components. 
    for i in range(n):
        res.add(find(data,i))

    # the total length of the root nodes determine the total number of components. 
    return len(res)


print(countComponents(5, [[0, 1], [1, 2], [3, 4]]))



================================================
FILE: algorithms/a_search/cpp/a_star.cpp
================================================
// A C++ Program to implement A* Search Algorithm
#include <bits/stdc++.h>
using namespace std;
 
#define ROW 9
#define COL 10
 
// Creating a shortcut for int, int pair type
typedef pair<int, int> Pair;
 
// Creating a shortcut for pair<int, pair<int, int>> type
typedef pair<double, pair<int, int>> pPair;
 
// A structure to hold the neccesary parameters
struct cell
{
    // Row and Column index of its parent
    // Note that 0 <= i <= ROW-1 & 0 <= j <= COL-1
    int parent_i, parent_j;
    // f = g + h
    double f, g, h;
};
 
// A Utility Function to check whether given cell (row, col)
// is a valid cell or not.
bool isValid(int row, int col)
{
    // Returns true if row number and column number
    // is in range
    return (row >= 0) && (row < ROW) &&
           (col >= 0) && (col < COL);
}
 
// A Utility Function to check whether the given cell is
// blocked or not
bool isUnBlocked(int grid[][COL], int row, int col)
{
    // Returns true if the cell is not blocked else false
    if (grid[row][col] == 1)
        return (true);
    else
        return (false);
}
 
// A Utility Function to check whether destination cell has
// been reached or not
bool isDestination(int row, int col, Pair dest)
{
    if (row == dest.first && col == dest.second)
        return (true);
    else
        return (false);
}
 
// A Utility Function to calculate the 'h' heuristics.
double calculateHValue(int row, int col, Pair dest)
{
    // Return using the distance formula
    return ((double)sqrt ((row-dest.first)*(row-dest.first)
                          + (col-dest.second)*(col-dest.second)));
}
 
// A Utility Function to trace the path from the source
// to destination
void tracePath(cell cellDetails[][COL], Pair dest)
{
    printf ("\nThe Path is ");
    int row = dest.first;
    int col = dest.second;
 
    stack<Pair> Path;
 
    while (!(cellDetails[row][col].parent_i == row
             && cellDetails[row][col].parent_j == col ))
    {
        Path.push (make_pair (row, col));
        int temp_row = cellDetails[row][col].parent_i;
        int temp_col = cellDetails[row][col].parent_j;
        row = temp_row;
        col = temp_col;
    }
 
    Path.push (make_pair (row, col));
    while (!Path.empty())
    {
        pair<int,int> p = Path.top();
        Path.pop();
        printf("-> (%d,%d) ",p.first,p.second);
    }
 
    return;
}
 
// A Function to find the shortest path between
// a given source cell to a destination cell according
// to A* Search Algorithm
void aStarSearch(int grid[][COL], Pair src, Pair dest)
{
    // If the source is out of range
    if (isValid (src.first, src.second) == false)
    {
        printf ("Source is invalid\n");
        return;
    }
 
    // If the destination is out of range
    if (isValid (dest.first, dest.second) == false)
    {
        printf ("Destination is invalid\n");
        return;
    }
 
    // Either the source or the destination is blocked
    if (isUnBlocked(grid, src.first, src.second) == false ||
            isUnBlocked(grid, dest.first, dest.second) == false)
    {
        printf ("Source or the destination is blocked\n");
        return;
    }
 
    // If the destination cell is the same as source cell
    if (isDestination(src.first, src.second, dest) == true)
    {
        printf ("We are already at the destination\n");
        return;
    }
 
    // Create a closed list and initialise it to false which means
    // that no cell has been included yet
    // This closed list is implemented as a boolean 2D array
    bool closedList[ROW][COL];
    memset(closedList, false, sizeof (closedList));
 
    // Declare a 2D array of structure to hold the details
    //of that cell
    cell cellDetails[ROW][COL];
 
    int i, j;
 
    for (i=0; i<ROW; i++)
    {
        for (j=0; j<COL; j++)
        {
            cellDetails[i][j].f = FLT_MAX;
            cellDetails[i][j].g = FLT_MAX;
            cellDetails[i][j].h = FLT_MAX;
            cellDetails[i][j].parent_i = -1;
            cellDetails[i][j].parent_j = -1;
        }
    }
 
    // Initialising the parameters of the starting node
    i = src.first, j = src.second;
    cellDetails[i][j].f = 0.0;
    cellDetails[i][j].g = 0.0;
    cellDetails[i][j].h = 0.0;
    cellDetails[i][j].parent_i = i;
    cellDetails[i][j].parent_j = j;
 
    /*
     Create an open list having information as-
     <f, <i, j>>
     where f = g + h,
     and i, j are the row and column index of that cell
     Note that 0 <= i <= ROW-1 & 0 <= j <= COL-1
     This open list is implenented as a set of pair of pair.*/
    set<pPair> openList;
 
    // Put the starting cell on the open list and set its
    // 'f' as 0
    openList.insert(make_pair (0.0, make_pair (i, j)));
 
    // We set this boolean value as false as initially
    // the destination is not reached.
    bool foundDest = false;
 
    while (!openList.empty())
    {
        pPair p = *openList.begin();
 
        // Remove this vertex from the open list
        openList.erase(openList.begin());
 
        // Add this vertex to the open list
        i = p.second.first;
        j = p.second.second;
        closedList[i][j] = true;
      
       /*
        Generating all the 8 successor of this cell
 
            N.W   N   N.E
              \   |   /
               \  |  /
            W----Cell----E
                 / | \
               /   |  \
            S.W    S   S.E
 
        Cell-->Popped Cell (i, j)
        N -->  North       (i-1, j)
        S -->  South       (i+1, j)
        E -->  East        (i, j+1)
        W -->  West           (i, j-1)
        N.E--> North-East  (i-1, j+1)
        N.W--> North-West  (i-1, j-1)
        S.E--> South-East  (i+1, j+1)
        S.W--> South-West  (i+1, j-1)*/
 
        // To store the 'g', 'h' and 'f' of the 8 successors
        double gNew, hNew, fNew;
 
        //----------- 1st Successor (North) ------------
 
        // Only process this cell if this is a valid one
        if (isValid(i-1, j) == true)
        {
            // If the destination cell is the same as the
            // current successor
            if (isDestination(i-1, j, dest) == true)
            {
                // Set the Parent of the destination cell
                cellDetails[i-1][j].parent_i = i;
                cellDetails[i-1][j].parent_j = j;
                printf ("The destination cell is found\n");
                tracePath (cellDetails, dest);
                foundDest = true;
                return;
            }
            // If the successor is already on the closed
            // list or if it is blocked, then ignore it.
            // Else do the following
            else if (closedList[i-1][j] == false &&
                     isUnBlocked(grid, i-1, j) == true)
            {
                gNew = cellDetails[i][j].g + 1.0;
                hNew = calculateHValue (i-1, j, dest);
                fNew = gNew + hNew;
 
                // If it isn’t on the open list, add it to
                // the open list. Make the current square
                // the parent of this square. Record the
                // f, g, and h costs of the square cell
                //                OR
                // If it is on the open list already, check
                // to see if this path to that square is better,
                // using 'f' cost as the measure.
                if (cellDetails[i-1][j].f == FLT_MAX ||
                        cellDetails[i-1][j].f > fNew)
                {
                    openList.insert( make_pair(fNew,
                                               make_pair(i-1, j)));
 
                    // Update the details of this cell
                    cellDetails[i-1][j].f = fNew;
                    cellDetails[i-1][j].g = gNew;
                    cellDetails[i-1][j].h = hNew;
                    cellDetails[i-1][j].parent_i = i;
                    cellDetails[i-1][j].parent_j = j;
                }
            }
        }
 
        //----------- 2nd Successor (South) ------------
 
        // Only process this cell if this is a valid one
        if (isValid(i+1, j) == true)
        {
            // If the destination cell is the same as the
            // current successor
            if (isDestination(i+1, j, dest) == true)
            {
                // Set the Parent of the destination cell
                cellDetails[i+1][j].parent_i = i;
                cellDetails[i+1][j].parent_j = j;
                printf("The destination cell is found\n");
                tracePath(cellDetails, dest);
                foundDest = true;
                return;
            }
            // If the successor is already on the closed
            // list or if it is blocked, then ignore it.
            // Else do the following
            else if (closedList[i+1][j] == false &&
                     isUnBlocked(grid, i+1, j) == true)
            {
                gNew = cellDetails[i][j].g + 1.0;
                hNew = calculateHValue(i+1, j, dest);
                fNew = gNew + hNew;
 
                // If it isn’t on the open list, add it to
                // the open list. Make the current square
                // the parent of this square. Record the
                // f, g, and h costs of the square cell
                //                OR
                // If it is on the open list already, check
                // to see if this path to that square is better,
                // using 'f' cost as the measure.
                if (cellDetails[i+1][j].f == FLT_MAX ||
                        cellDetails[i+1][j].f > fNew)
                {
                    openList.insert( make_pair (fNew, make_pair (i+1, j)));
                    // Update the details of this cell
                    cellDetails[i+1][j].f = fNew;
                    cellDetails[i+1][j].g = gNew;
                    cellDetails[i+1][j].h = hNew;
                    cellDetails[i+1][j].parent_i = i;
                    cellDetails[i+1][j].parent_j = j;
                }
            }
        }
 
        //----------- 3rd Successor (East) ------------
 
        // Only process this cell if this is a valid one
        if (isValid (i, j+1) == true)
        {
            // If the destination cell is the same as the
            // current successor
            if (isDestination(i, j+1, dest) == true)
            {
                // Set the Parent of the destination cell
                cellDetails[i][j+1].parent_i = i;
                cellDetails[i][j+1].parent_j = j;
                printf("The destination cell is found\n");
                tracePath(cellDetails, dest);
                foundDest = true;
                return;
            }
 
            // If the successor is already on the closed
            // list or if it is blocked, then ignore it.
            // Else do the following
            else if (closedList[i][j+1] == false &&
                     isUnBlocked (grid, i, j+1) == true)
            {
                gNew = cellDetails[i][j].g + 1.0;
                hNew = calculateHValue (i, j+1, dest);
                fNew = gNew + hNew;
 
                // If it isn’t on the open list, add it to
                // the open list. Make the current square
                // the parent of this square. Record the
                // f, g, and h costs of the square cell
                //                OR
                // If it is on the open list already, check
                // to see if this path to that square is better,
                // using 'f' cost as the measure.
                if (cellDetails[i][j+1].f == FLT_MAX ||
                        cellDetails[i][j+1].f > fNew)
                {
                    openList.insert( make_pair(fNew,
                                        make_pair (i, j+1)));
 
                    // Update the details of this cell
                    cellDetails[i][j+1].f = fNew;
                    cellDetails[i][j+1].g = gNew;
                    cellDetails[i][j+1].h = hNew;
                    cellDetails[i][j+1].parent_i = i;
                    cellDetails[i][j+1].parent_j = j;
                }
            }
        }
 
        //----------- 4th Successor (West) ------------
 
        // Only process this cell if this is a valid one
        if (isValid(i, j-1) == true)
        {
            // If the destination cell is the same as the
            // current successor
            if (isDestination(i, j-1, dest) == true)
            {
                // Set the Parent of the destination cell
                cellDetails[i][j-1].parent_i = i;
                cellDetails[i][j-1].parent_j = j;
                printf("The destination cell is found\n");
                tracePath(cellDetails, dest);
                foundDest = true;
                return;
            }
 
            // If the successor is already on the closed
            // list or if it is blocked, then ignore it.
            // Else do the following
            else if (closedList[i][j-1] == false &&
                     isUnBlocked(grid, i, j-1) == true)
            {
                gNew = cellDetails[i][j].g + 1.0;
                hNew = calculateHValue(i, j-1, dest);
                fNew = gNew + hNew;
 
                // If it isn’t on the open list, add it to
                // the open list. Make the current square
                // the parent of this square. Record the
                // f, g, and h costs of the square cell
                //                OR
                // If it is on the open list already, check
                // to see if this path to that square is better,
                // using 'f' cost as the measure.
                if (cellDetails[i][j-1].f == FLT_MAX ||
                        cellDetails[i][j-1].f > fNew)
                {
                    openList.insert( make_pair (fNew,
                                          make_pair (i, j-1)));
 
                    // Update the details of this cell
                    cellDetails[i][j-1].f = fNew;
                    cellDetails[i][j-1].g = gNew;
                    cellDetails[i][j-1].h = hNew;
                    cellDetails[i][j-1].parent_i = i;
                    cellDetails[i][j-1].parent_j = j;
                }
            }
        }
 
        //----------- 5th Successor (North-East) ------------
 
        // Only process this cell if this is a valid one
        if (isValid(i-1, j+1) == true)
        {
            // If the destination cell is the same as the
            // current successor
            if (isDestination(i-1, j+1, dest) == true)
            {
                // Set the Parent of the destination cell
                cellDetails[i-1][j+1].parent_i = i;
                cellDetails[i-1][j+1].parent_j = j;
                printf ("The destination cell is found\n");
                tracePath (cellDetails, dest);
                foundDest = true;
                return;
            }
 
            // If the successor is already on the closed
            // list or if it is blocked, then ignore it.
            // Else do the following
            else if (closedList[i-1][j+1] == false &&
                     isUnBlocked(grid, i-1, j+1) == true)
            {
                gNew = cellDetails[i][j].g + 1.414;
                hNew = calculateHValue(i-1, j+1, dest);
                fNew = gNew + hNew;
 
                // If it isn’t on the open list, add it to
                // the open list. Make the current square
                // the parent of this square. Record the
                // f, g, and h costs of the square cell
                //                OR
                // If it is on the open list already, check
                // to see if this path to that square is better,
                // using 'f' cost as the measure.
                if (cellDetails[i-1][j+1].f == FLT_MAX ||
                        cellDetails[i-1][j+1].f > fNew)
                {
                    openList.insert( make_pair (fNew, 
                                    make_pair(i-1, j+1)));
 
                    // Update the details of this cell
                    cellDetails[i-1][j+1].f = fNew;
                    cellDetails[i-1][j+1].g = gNew;
                    cellDetails[i-1][j+1].h = hNew;
                    cellDetails[i-1][j+1].parent_i = i;
                    cellDetails[i-1][j+1].parent_j = j;
                }
            }
        }
 
        //----------- 6th Successor (North-West) ------------
 
        // Only process this cell if this is a valid one
        if (isValid (i-1, j-1) == true)
        {
            // If the destination cell is the same as the
            // current successor
            if (isDestination (i-1, j-1, dest) == true)
            {
                // Set the Parent of the destination cell
                cellDetails[i-1][j-1].parent_i = i;
                cellDetails[i-1][j-1].parent_j = j;
                printf ("The destination cell is found\n");
                tracePath (cellDetails, dest);
                foundDest = true;
                return;
            }
 
            // If the successor is already on the closed
            // list or if it is blocked, then ignore it.
            // Else do the following
            else if (closedList[i-1][j-1] == false &&
                     isUnBlocked(grid, i-1, j-1) == true)
            {
                gNew = cellDetails[i][j].g + 1.414;
                hNew = calculateHValue(i-1, j-1, dest);
                fNew = gNew + hNew;
 
                // If it isn’t on the open list, add it to
                // the open list. Make the current square
                // the parent of this square. Record the
                // f, g, and h costs of the square cell
                //                OR
                // If it is on the open list already, check
                // to see if this path to that square is better,
                // using 'f' cost as the measure.
                if (cellDetails[i-1][j-1].f == FLT_MAX ||
                        cellDetails[i-1][j-1].f > fNew)
                {
                    openList.insert( make_pair (fNew, make_pair (i-1, j-1)));
                    // Update the details of this cell
                    cellDetails[i-1][j-1].f = fNew;
                    cellDetails[i-1][j-1].g = gNew;
                    cellDetails[i-1][j-1].h = hNew;
                    cellDetails[i-1][j-1].parent_i = i;
                    cellDetails[i-1][j-1].parent_j = j;
                }
            }
        }
 
        //----------- 7th Successor (South-East) ------------
 
        // Only process this cell if this is a valid one
        if (isValid(i+1, j+1) == true)
        {
            // If the destination cell is the same as the
            // current successor
            if (isDestination(i+1, j+1, dest) == true)
            {
                // Set the Parent of the destination cell
                cellDetails[i+1][j+1].parent_i = i;
                cellDetails[i+1][j+1].parent_j = j;
                printf ("The destination cell is found\n");
                tracePath (cellDetails, dest);
                foundDest = true;
                return;
            }
 
            // If the successor is already on the closed
            // list or if it is blocked, then ignore it.
            // Else do the following
            else if (closedList[i+1][j+1] == false &&
                     isUnBlocked(grid, i+1, j+1) == true)
            {
                gNew = cellDetails[i][j].g + 1.414;
                hNew = calculateHValue(i+1, j+1, dest);
                fNew = gNew + hNew;
 
                // If it isn’t on the open list, add it to
                // the open list. Make the current square
                // the parent of this square. Record the
                // f, g, and h costs of the square cell
                //                OR
                // If it is on the open list already, check
                // to see if this path to that square is better,
                // using 'f' cost as the measure.
                if (cellDetails[i+1][j+1].f == FLT_MAX ||
                        cellDetails[i+1][j+1].f > fNew)
                {
                    openList.insert(make_pair(fNew, 
                                        make_pair (i+1, j+1)));
 
                    // Update the details of this cell
                    cellDetails[i+1][j+1].f = fNew;
                    cellDetails[i+1][j+1].g = gNew;
                    cellDetails[i+1][j+1].h = hNew;
                    cellDetails[i+1][j+1].parent_i = i;
                    cellDetails[i+1][j+1].parent_j = j;
                }
            }
        }
 
        //----------- 8th Successor (South-West) ------------
 
        // Only process this cell if this is a valid one
        if (isValid (i+1, j-1) == true)
        {
            // If the destination cell is the same as the
            // current successor
            if (isDestination(i+1, j-1, dest) == true)
            {
                // Set the Parent of the destination cell
                cellDetails[i+1][j-1].parent_i = i;
                cellDetails[i+1][j-1].parent_j = j;
                printf("The destination cell is found\n");
                tracePath(cellDetails, dest);
                foundDest = true;
                return;
            }
 
            // If the successor is already on the closed
            // list or if it is blocked, then ignore it.
            // Else do the following
            else if (closedList[i+1][j-1] == false &&
                     isUnBlocked(grid, i+1, j-1) == true)
            {
                gNew = cellDetails[i][j].g + 1.414;
                hNew = calculateHValue(i+1, j-1, dest);
                fNew = gNew + hNew;
 
                // If it isn’t on the open list, add it to
                // the open list. Make the current square
                // the parent of this square. Record the
                // f, g, and h costs of the square cell
                //                OR
                // If it is on the open list already, check
                // to see if this path to that square is better,
                // using 'f' cost as the measure.
                if (cellDetails[i+1][j-1].f == FLT_MAX ||
                        cellDetails[i+1][j-1].f > fNew)
                {
                    openList.insert(make_pair(fNew, 
                                        make_pair(i+1, j-1)));
 
                    // Update the details of this cell
                    cellDetails[i+1][j-1].f = fNew;
                    cellDetails[i+1][j-1].g = gNew;
                    cellDetails[i+1][j-1].h = hNew;
                    cellDetails[i+1][j-1].parent_i = i;
                    cellDetails[i+1][j-1].parent_j = j;
                }
            }
        }
    }
 
    // When the destination cell is not found and the open
    // list is empty, then we conclude that we failed to
    // reach the destiantion cell. This may happen when the
    // there is no way to destination cell (due to blockages)
    if (foundDest == false)
        printf("Failed to find the Destination Cell\n");
 
    return;
}
 
 
// Driver program to test above function
int main()
{
    /* Description of the Grid-
     1--> The cell is not blocked
     0--> The cell is blocked    */
    int grid[ROW][COL] =
    {
        { 1, 0, 1, 1, 1, 1, 0, 1, 1, 1 },
        { 1, 1, 1, 0, 1, 1, 1, 0, 1, 1 },
        { 1, 1, 1, 0, 1, 1, 0, 1, 0, 1 },
        { 0, 0, 1, 0, 1, 0, 0, 0, 0, 1 },
        { 1, 1, 1, 0, 1, 1, 1, 0, 1, 0 },
        { 1, 0, 1, 1, 1, 1, 0, 1, 0, 0 },
        { 1, 0, 0, 0, 0, 1, 0, 0, 0, 1 },
        { 1, 0, 1, 1, 1, 1, 0, 1, 1, 1 },
        { 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 }
    };
 
    // Source is the left-most bottom-most corner
    Pair src = make_pair(8, 0);
 
    // Destination is the left-most top-most corner
    Pair dest = make_pair(0, 0);
 
    aStarSearch(grid, src, dest);
 
    return(0);
}


================================================
FILE: algorithms/backtracking/c/n_queens_problem.c
================================================
/* C/C++ program to solve N Queen Problem using
   backtracking */
#define N 4
#include<stdio.h>

/* A utility function to print solution */
void printSolution(int board[N][N])
{
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
            printf(" %d ", board[i][j]);
        printf("n");
    }
}

/* A utility function to check if a queen can
   be placed on board[row][col]. Note that this
   function is called when "col" queens are
   already placed in columns from 0 to col -1.
   So we need to check only left side for
   attacking queens */
bool isSafe(int board[N][N], int row, int col)
{
    int i, j;

    /* Check this row on left side */
    for (i = 0; i < col; i++)
        if (board[row][i])
            return false;

    /* Check upper diagonal on left side */
    for (i=row, j=col; i>=0 && j>=0; i--, j--)
        if (board[i][j])
            return false;

    /* Check lower diagonal on left side */
    for (i=row, j=col; j>=0 && i<N; i++, j--)
        if (board[i][j])
            return false;

    return true;
}

/* A recursive utility function to solve N
   Queen problem */
bool solveNQUtil(int board[N][N], int col)
{
    /* base case: If all queens are placed
      then return true */
    if (col >= N)
        return true;

    /* Consider this column and try placing
       this queen in all rows one by one */
    for (int i = 0; i < N; i++)
    {
        /* Check if queen can be placed on
          board[i][col] */
        if ( isSafe(board, i, col) )
        {
            /* Place this queen in board[i][col] */
            board[i][col] = 1;

            /* recur to place rest of the queens */
            if ( solveNQUtil(board, col + 1) )
                return true;

            /* If placing queen in board[i][col]
               doesn't lead to a solution, then
               remove queen from board[i][col] */
            board[i][col] = 0; // BACKTRACK
        }
    }

     /* If queen can not be place in any row in
        this colum col  then return false */
    return false;
}

/* This function solves the N Queen problem using
   Backtracking. It mainly uses solveNQUtil() to
   solve the problem. It returns false if queens
   cannot be placed, otherwise return true and
   prints placement of queens in the form of 1s.
   Please note that there may be more than one
   solutions, this function prints one  of the
   feasible solutions.*/
bool solveNQ()
{
    int board[N][N] = { {0, 0, 0, 0},
        {0, 0, 0, 0},
        {0, 0, 0, 0},
        {0, 0, 0, 0}
    };

    if ( solveNQUtil(board, 0) == false )
    {
      printf("Solution does not exist");
      return false;
    }

    printSolution(board);
    return true;
}

// driver program to test above function
int main()
{
    solveNQ();
    return 0;
}


================================================
FILE: algorithms/backtracking/c/rat_in_a_maze_problem.c
================================================
/* C/C++ program to solve Rat in a Maze problem using
   backtracking */
#include<stdio.h>

// Maze size
#define N 4

bool solveMazeUtil(int maze[N][N], int x, int y, int sol[N][N]);

/* A utility function to print solution matrix sol[N][N] */
void printSolution(int sol[N][N])
{
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
            printf(" %d ", sol[i][j]);
        printf("\n");
    }
}

/* A utility function to check if x,y is valid index for N*N maze */
bool isSafe(int maze[N][N], int x, int y)
{
    // if (x,y outside maze) return false
    if(x >= 0 && x < N && y >= 0 && y < N && maze[x][y] == 1)
        return true;

    return false;
}

/* This function solves the Maze problem using Backtracking.  It mainly
   uses solveMazeUtil() to solve the problem. It returns false if no
   path is possible, otherwise return true and prints the path in the
   form of 1s. Please note that there may be more than one solutions,
   this function prints one of the feasible solutions.*/
bool solveMaze(int maze[N][N])
{
    int sol[N][N] = { {0, 0, 0, 0},
        {0, 0, 0, 0},
        {0, 0, 0, 0},
        {0, 0, 0, 0}
    };

    if(solveMazeUtil(maze, 0, 0, sol) == false)
    {
        printf("Solution doesn't exist");
        return false;
    }

    printSolution(sol);
    return true;
}

/* A recursive utility function to solve Maze problem */
bool solveMazeUtil(int maze[N][N], int x, int y, int sol[N][N])
{
    // if (x,y is goal) return true
    if(x == N-1 && y == N-1)
    {
        sol[x][y] = 1;
        return true;
    }

    // Check if maze[x][y] is valid
    if(isSafe(maze, x, y) == true)
    {
        // mark x,y as part of solution path
        sol[x][y] = 1;

        /* Move forward in x direction */
        if (solveMazeUtil(maze, x+1, y, sol) == true)
            return true;

        /* If moving in x direction doesn't give solution then
           Move down in y direction  */
        if (solveMazeUtil(maze, x, y+1, sol) == true)
            return true;

        /* If none of the above movements work then BACKTRACK:
            unmark x,y as part of solution path */
        sol[x][y] = 0;
        return false;
    }

    return false;
}

// driver program to test above function
int main()
{
    int maze[N][N]  =  { {1, 0, 0, 0},
        {1, 1, 0, 1},
        {0, 1, 0, 0},
        {1, 1, 1, 1}
    };

    solveMaze(maze);
    return 0;
}


================================================
FILE: algorithms/backtracking/c/sudoku_problem.c
================================================
// A Backtracking program  in C++ to solve Sudoku problem
#include <stdio.h>

// UNASSIGNED is used for empty cells in sudoku grid
#define UNASSIGNED 0

// N is used for size of Sudoku grid. Size will be NxN
#define N 9

// This function finds an entry in grid that is still unassigned
bool FindUnassignedLocation(int grid[N][N], int &row, int &col);

// Checks whether it will be legal to assign num to the given row,col
bool isSafe(int grid[N][N], int row, int col, int num);

/* Takes a partially filled-in grid and attempts to assign values to
  all unassigned locations in such a way to meet the requirements
  for Sudoku solution (non-duplication across rows, columns, and boxes) */
bool SolveSudoku(int grid[N][N])
{
    int row, col;

    // If there is no unassigned location, we are done
    if (!FindUnassignedLocation(grid, row, col))
       return true; // success!

    // consider digits 1 to 9
    for (int num = 1; num <= 9; num++)
    {
        // if looks promising
        if (isSafe(grid, row, col, num))
        {
            // make tentative assignment
            grid[row][col] = num;

            // return, if success, yay!
            if (SolveSudoku(grid))
                return true;

            // failure, unmake & try again
            grid[row][col] = UNASSIGNED;
        }
    }
    return false; // this triggers backtracking
}

/* Searches the grid to find an entry that is still unassigned. If
   found, the reference parameters row, col will be set the location
   that is unassigned, and true is returned. If no unassigned entries
   remain, false is returned. */
bool FindUnassignedLocation(int grid[N][N], int &row, int &col)
{
    for (row = 0; row < N; row++)
        for (col = 0; col < N; col++)
            if (grid[row][col] == UNASSIGNED)
                return true;
    return false;
}

/* Returns a boolean which indicates whether any assigned entry
   in the specified row matches the given number. */
bool UsedInRow(int grid[N][N], int row, int num)
{
    for (int col = 0; col < N; col++)
        if (grid[row][col] == num)
            return true;
    return false;
}

/* Returns a boolean which indicates whether any assigned entry
   in the specified column matches the given number. */
bool UsedInCol(int grid[N][N], int col, int num)
{
    for (int row = 0; row < N; row++)
        if (grid[row][col] == num)
            return true;
    return false;
}

/* Returns a boolean which indicates whether any assigned entry
   within the specified 3x3 box matches the given number. */
bool UsedInBox(int grid[N][N], int boxStartRow, int boxStartCol, int num)
{
    for (int row = 0; row < 3; row++)
        for (int col = 0; col < 3; col++)
            if (grid[row+boxStartRow][col+boxStartCol] == num)
                return true;
    return false;
}

/* Returns a boolean which indicates whether it will be legal to assign
   num to the given row,col location. */
bool isSafe(int grid[N][N], int row, int col, int num)
{
    /* Check if 'num' is not already placed in current row,
       current column and current 3x3 box */
    return !UsedInRow(grid, row, num) &&
           !UsedInCol(grid, col, num) &&
           !UsedInBox(grid, row - row%3 , col - col%3, num);
}

/* A utility function to print grid  */
void printGrid(int grid[N][N])
{
    for (int row = 0; row < N; row++)
    {
       for (int col = 0; col < N; col++)
             printf("%2d", grid[row][col]);
        printf("n");
    }
}

/* Driver Program to test above functions */
int main()
{
    // 0 means unassigned cells
    int grid[N][N] = {{3, 0, 6, 5, 0, 8, 4, 0, 0},
                      {5, 2, 0, 0, 0, 0, 0, 0, 0},
                      {0, 8, 7, 0, 0, 0, 0, 3, 1},
                      {0, 0, 3, 0, 1, 0, 0, 8, 0},
                      {9, 0, 0, 8, 6, 3, 0, 0, 5},
                      {0, 5, 0, 0, 9, 0, 6, 0, 0},
                      {1, 3, 0, 0, 0, 0, 2, 5, 0},
                      {0, 0, 0, 0, 0, 0, 0, 7, 4},
                      {0, 0, 5, 2, 0, 6, 3, 0, 0}};
    if (SolveSudoku(grid) == true)
          printGrid(grid);
    else
         printf("No solution exists");

    return 0;
}


================================================
FILE: algorithms/backtracking/c/the_knight_tour_problem.c
================================================
// C program for Knight Tour problem
#include<stdio.h>
#define N 8

int solveKTUtil(int x, int y, int movei, int sol[N][N],
                int xMove[],  int yMove[]);

/* A utility function to check if i,j are valid indexes
   for N*N chessboard */
bool isSafe(int x, int y, int sol[N][N])
{
    return ( x >= 0 && x < N && y >= 0 &&
             y < N && sol[x][y] == -1);
}

/* A utility function to print solution matrix sol[N][N] */
void printSolution(int sol[N][N])
{
    for (int x = 0; x < N; x++)
    {
        for (int y = 0; y < N; y++)
            printf(" %2d ", sol[x][y]);
        printf("\n");
    }
}

/* This function solves the Knight Tour problem using
   Backtracking.  This function mainly uses solveKTUtil()
   to solve the problem. It returns false if no complete
   tour is possible, otherwise return true and prints the
   tour.
   Please note that there may be more than one solutions,
   this function prints one of the feasible solutions.  */
bool solveKT()
{
    int sol[N][N];

    /* Initialization of solution matrix */
    for (int x = 0; x < N; x++)
        for (int y = 0; y < N; y++)
            sol[x][y] = -1;

    /* xMove[] and yMove[] define next move of Knight.
       xMove[] is for next value of x coordinate
       yMove[] is for next value of y coordinate */
    int xMove[8] = {  2, 1, -1, -2, -2, -1,  1,  2 };
    int yMove[8] = {  1, 2,  2,  1, -1, -2, -2, -1 };

    // Since the Knight is initially at the first block
    sol[0][0]  = 0;

    /* Start from 0,0 and explore all tours using
       solveKTUtil() */
    if (solveKTUtil(0, 0, 1, sol, xMove, yMove) == false)
    {
        printf("Solution does not exist");
        return false;
    }
    else
        printSolution(sol);

    return true;
}

/* A recursive utility function to solve Knight Tour
   problem */
int solveKTUtil(int x, int y, int movei, int sol[N][N],
                int xMove[N], int yMove[N])
{
   int k, next_x, next_y;
   if (movei == N*N)
       return true;

   /* Try all next moves from the current coordinate x, y */
   for (k = 0; k < 8; k++)
   {
       next_x = x + xMove[k];
       next_y = y + yMove[k];
       if (isSafe(next_x, next_y, sol))
       {
         sol[next_x][next_y] = movei;
         if (solveKTUtil(next_x, next_y, movei+1, sol,
                         xMove, yMove) == true)
             return true;
         else
             sol[next_x][next_y] = -1;// backtracking
       }
   }

   return false;
}

/* Driver program to test above functions */
int main()
{
    solveKT();
    return 0;
}


================================================
FILE: algorithms/bellman_ford/cpp/bellman_ford.cpp
================================================
/* 1. shortest path from source to vertices
   2. can be used for negetive weights
   3.can be used to detect neg cycle.
   */
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define mp make_pair
#define INF (1<<20);
pair<int ,pii> G[1000];
int dis[1000];

int main()
{
	int nodes,edges;
	cin>>nodes>>edges;
	for(int i=0;i<edges;i++)
	{
		int u,v,w;
		cin>>u>>v>>w;
		G[i]=mp(u,mp(v,w));
	//	v[v].push_back(mp(u,w)); for undirected;
	}
	for(int i=1;i<=nodes;i++)
		dis[i]=INF;
	dis[1]=0;
	for(int i=0;i<nodes-1;i++)
	{
	for(int j=0;j<edges;j++)
	{
		int u,v,w;
		u=G[j].first;
		v=G[j].second.first;
		w=G[j].second.second;
		if(dis[v]>dis[u]+w)
		{
			dis[v]=dis[u]+w;
		}
	}
	}
	bool negc=false;
	for(int j=0;j<edges;j++)
	{
		int u,v,w;
		u=G[j].first;
		v=G[j].second.first;
		w=G[j].second.second;
		if(dis[v]>dis[u]+w)
		{
			negc=true;
			break;
		}
	}
	if(negc)
	cout<<"negetive cycle";
	else
	{
		for(int i=1;i<=nodes;i++)
		{
			cout<<"1"<<" - "<<i<<"= "<<dis[i]<<endl;
		}
	}


}



================================================
FILE: algorithms/bellman_ford/java/BellmanFord.java
================================================
import java.util.*;

class Graph
{
	private class Edge {
		int src, dest, weight;
		private Edge(int src, int dest, int weight) {
			this.src = src;
			this.dest = dest;
			this.weight = weight;
		}
	};

	private int V;
	private LinkedList<Edge> edgeList;
	public Graph(int v)
	{
		this.V = v;
		edgeList = new LinkedList<Edge>();
	}

	public void bellmanFord(int src) {
		if (src < 0 || src > (V - 1)) {
			System.out.println("Invalid starting vertex");
			return;
		}
		
		int dist[] = new int[V];

		for (int i=0; i<V; ++i)
			dist[i] = Integer.MAX_VALUE;
		dist[src] = 0;

		for (int i=1; i < V; ++i) {
			for (int j=0; j <  edgeList.size(); ++j) {		
				int u = edgeList.get(j).src;
				int v = edgeList.get(j).dest;
				int weight = edgeList.get(j).weight;
				
				if (dist[u] != Integer.MAX_VALUE && dist[u] + weight<dist[v]) {
					dist[v]=dist[u]+weight;
				}
			}
		}

		for (int j = 0; j < edgeList.size(); ++j) {
			int u = edgeList.get(j).src;
			int v = edgeList.get(j).dest;
			int weight = edgeList.get(j).weight;
			
			if (dist[u] != Integer.MAX_VALUE && dist[u] + weight < dist[v]) {
				System.out.println("Graph contains negative weight cycle");
				return;
			}
			
		}
		
		printArr(dist, V);
	}

	private void printArr(int dist[], int V)
	{
		System.out.println("Vertex Distance from Source");
		for (int i=0; i<V; ++i)
			System.out.println(i+"tt"+dist[i]);
	}
	
	public boolean addEdge(int src, int dest, int weight) {
		if (src < 0 || dest < 0 || src > (V - 1) || dest > (V - 1)) {
			return false;
		}
		
		Edge edge = new Edge(src, dest, weight);
		edgeList.add(edge);
		return true;
	}

	public static void main(String[] args)
	{
		int V = 5;

		Graph graph = new Graph(V);
		
		graph.addEdge(0, 1, -1);
		graph.addEdge(0, 2, 4);
		graph.addEdge(1, 2, 3);
		graph.addEdge(1, 3, 2);
		graph.addEdge(1, 4, 2);
		graph.addEdge(3, 2, 5);
		graph.addEdge(3, 1, 1);
		graph.addEdge(4, 3, -3);

		graph.bellmanFord(1);
	}
}


================================================
FILE: algorithms/bfs/cpp/bfs.cpp
================================================

#import <vector>
#import <queue>
#import <iostream>

class Vertex {
public:
    Vertex(std::string n);

    Vertex * prev; //predecessor
    Vertex *next;   //for queue purposes
    int dist;
    std::string name;
    std::vector <Vertex *> neighbours;
};

Vertex::Vertex(std::string n) {
    prev = nullptr;
    next = nullptr;
    dist = -1;
    name = n;
}

class Queue{
public:
    Queue(Vertex *first){
        head = first;
        tail = first;
        first->dist = 0;
    }
    void Enqueue(Vertex *pred_, Vertex * cur) {
        if(head == nullptr) {
            head = cur;
        }
        cur->dist = pred_->dist+1;
        cur->prev = pred_;
        tail->next = cur;
        tail = cur;
    }

    Vertex * Dequeue(){
        Vertex *tmp = head;
        head = head->next;
        return tmp;
    }

    bool isEmpty(){
        return head== nullptr;
    }

    bool isInQueue(Vertex v){
        Vertex *iter = head;
        while(iter != nullptr) {
            if (iter->name == v.name)
                return true;
            iter = iter->next;
        }
        return false;
    }
    Vertex *head;
    Vertex *tail;

};


void BFS(Vertex *root) {

    Queue q(root);
    Vertex *cur;
    int dist=0;
    root->dist = 0;
    while(!q.isEmpty()) {

        cur = q.Dequeue();
        for (Vertex *v : cur->neighbours) {
            if (q.isInQueue(*v))
                continue;
            cur->dist = dist;
            q.Enqueue(cur,v);
        }
        dist++;
    }
}

int main() {
    Vertex v1("v1");
    Vertex v2("v2");
    Vertex v3("v3");
    Vertex v4("v4");
    v1.neighbours.emplace_back(&v2);
    v1.neighbours.emplace_back(&v3);
    v2.neighbours.emplace_back(&v3);
    v3.neighbours.emplace_back(&v4);
    v1.neighbours.emplace_back(&v4);
    BFS(&v1);
    std::cout << v1.dist << "   v2prevname" << v2.prev->name << "    " << v3.dist << "    " << v4.dist;
    return 0;
}



================================================
FILE: algorithms/bfs/java/Graph.java
================================================
import java.util.*;

/**
 * Represents a directed graph using adjacency list
 */
public class Graph {
    private int vertexNumber;
    private LinkedList[] adj;

    /**
     *
     * @param v number of vertex
     */
    public Graph(int v) {
        vertexNumber = v;
        adj = new LinkedList[v];
        for (int i = 0; i < v; ++i)
            adj[i] = new LinkedList();
    }

    /**
     * Add edge into graph
     * @param v vertex
     * @param w vertex
     */
    public void addEdge(int v, int w)  {
        adj[v].add(w);
    }

    /**
     * Prints BFS traversal from a given source vertex
     * @param source source vertex
     */
    public void BFS(int source) {
        boolean visited[] = new boolean[vertexNumber];

        LinkedList<Integer> queue = new LinkedList<>();

        visited[source] = true;
        queue.add(source);

        while (queue.size() != 0) {
            source = queue.poll();
            System.out.print(source + " ");

            for (Integer n : (Iterable<Integer>) adj[source]) {
                if (!visited[n]) {
                    visited[n] = true;
                    queue.add(n);
                }
            }
        }
    }

    /**
     * Test
     * @param args
     */
    public static void main(String args[]) {
        Graph g = new Graph(4);

        g.addEdge(0, 1);
        g.addEdge(0, 2);
        g.addEdge(1, 2);
        g.addEdge(2, 0);
        g.addEdge(2, 3);
        g.addEdge(3, 3);

        g.BFS(2);
    }
}

================================================
FILE: algorithms/binary_search/PHP/binarysearch.php
================================================
<?php
/*
 * @Author: Sushma Kure
 * @ProblemStatement: Binary search in PHP
 */

function binary_search( $sourceArr, $keyword )
{
  $start  = 0;
  $end    = count( $sourceArr ) - 1;
  while ( $start <= $end )
  {
    $middle = ( $start + $end ) / 2;
    if( $keyword == $sourceArr[$middle] ) {

      return $middle;

    } elseif( $keyword < $sourceArr[$middle] ) {

      $end = $middle - 1;

    } else {

      $start = $middle + 1;

    }

  }
  return -1;
}

$sourceArr = range(1, 100, 7);
$keyword   = $sourceArr[ array_rand( $sourceArr ) ];  
$position  = binary_search( $sourceArr, $keyword );
echo '<pre>'; print_r( $sourceArr ); echo '</pre>';
echo ( $position >= 0 ) ? 'Keyword ' . $keyword . ' is found at position: ' . $position :  'Your keyword is not found.';

?>

================================================
FILE: algorithms/binary_search/binary_search.md
================================================
## ELI5
**Binary Serch** is a way of searching for a thing in a list of things. The list must be sorted, that is, it must be in order of some comparable value or the it won't work. First, we go to the middle of the list and see if the item value equals to the value we want to find. Then, if our value is less/greater than the item in the middle, we work on a new list (which starts from the middle and all the way to the bottom or top) and everything on the bottom or top side. We keep doing this until we find the value we were looking for or if were fluctuating between two elements.

## Pros
* It takes much less time than a reqular sequential search. 
* Average case of O(log n) vs O(n) for a linear search

## Cons
* The list must be sorted

## Technical Explanation

If we have the list

`a = [45,64,68,46,70,6,46,4,6,48]`

And we want to find an element if it exists in the list or not

The naive solution is to go in the list element by element, ask if this is the element I'm looking for or not.

The worst case is that the element is not in the list, or at the end of it,

then the time Complexity it takes to end the search process is O(n);

We can to do better.

Here comes the **Binary Search**,

Pseudocode for Binary Searching:

Given an array A of n elements with values or records A0, A1, ..., An−1, sorted such that A0 ≤ A1 ≤ ... ≤ An−1, and target value T, the following subroutine uses binary search to find the index of T in A.[7]
1. Set L to 0 and R to n − 1.
2. If L > R, the search terminates as unsuccessful.
3. Set m (the position of the middle element) to the floor (the largest previous integer) of (L + R) / 2.
4. If Am < T, set L to m + 1 and go to step 2.
5. If Am > T, set R to m − 1 and go to step 2.
6. Now Am = T, the search is done; return m.

## Pros
* The Time Complexity is O(log(n))
* Binary search adds a small amount of complexity for large performance gains.
* Simple to write.
* One of the fastest way to find elements in a list.

## Cons
* The list must be sorted, which is,
* The complexity can increase when the collection is not stored in a simple structure, such as a list.
* The list has to be sorted.
* Doesn't help in reducing the time much and adds complexity for small arrays.


================================================
FILE: algorithms/binary_search/c/binary_search.c
================================================
#include <stdio.h>

int binarySearch(int arr[], int l, int r, int key) {
  if (r >= l) {
       int mid = l + (r - l)/2;

       // If the element is present at the middle
       if (arr[mid] == key)  return mid;

       // If element is smaller than mid, then it can only be present in left subarray
       else if (arr[mid] > key) return binarySearch(arr, l, mid-1, key);

       // Else the element can only be present in right subarray
       return binarySearch(arr, mid+1, r, key);
  }
  // When element is not present in array
  return -1;
}

int main(void) {
  int arr[] = {2, 3, 4, 10, 40};
  int n = sizeof(arr)/ sizeof(arr[0]);
  int key = 10;
  int result = binarySearch(arr, 0, n-1, key);
  (result == -1) ? printf("Element is not present in array") : printf("Element is present at index %d", result);
  return 0;
}

================================================
FILE: algorithms/binary_search/cpp/binary_search.cpp
================================================
//saru95, cruxiu :)
#include <iostream> /* cout and cin */
#include <chrono> /* steady_clock::now */

bool binarySearchIterative(int list[], int first, int end, int item){

	int middle;

	while(first <= end){
		middle = (first + end)/2;
		if(list[middle] == item) {
			return true;
		}
		if(list[middle] < item) {
			first = middle + 1;
		} else {
			end = middle - 1;
		}
	}
	return false;
}

bool binarySearchRecursive(int list[], int first, int end, int item){

	int middle = (first + end)/2;

	if(list[middle] == item){
		return true;
	}
	if(first >= end){
		return false;
	}
	if(list[middle] < item){
		return binarySearchRecursive(list, middle+1, end, item);
	} else {
		return binarySearchRecursive(list, first, middle-1, item);
	}

}

int main(int argc, char const *argv[]){
  std::cout << "Please, enter the size of the list." << std::endl;
  int size, value, option;
  bool find;
  std::cin >> size;
  int *list = new int[size];
  for(int i = 0; i < size; i++){
    std::cout << "Enter the element " << i << " of the list." << std::endl;
    std::cin >> list[i];
  }
  std::cout << "Now, enter a value to be searched in the list." << std::endl;
  std::cin >> value;
  std::cout << "Now, would you like to use a binary search iterative (0) or a binary search recursive(1)." << std::endl;
  std::cin >> option;
  switch (option) {
    case 0:
      {
        auto start = std::chrono::steady_clock::now();
        find = binarySearchIterative(list, 0, size-1, value);
        auto end = std::chrono::steady_clock::now();
        auto diff = end - start;
        if(find)
        {
          std::cout << "You find the element using the binary search iterative." << std::endl;
        }
        else{
          std::cout << "You not find the element using the binary search iterative." << std::endl;
        }
        std::cout << "And the time of search was" << std::chrono::duration <double, std::milli> (diff).count() << " ms." << std::endl;
      }
      break;
    case 1:
      {
        auto start = std::chrono::steady_clock::now();
        find = binarySearchRecursive(list, 0, size-1, value);
        auto end = std::chrono::steady_clock::now();
        auto diff = start - end;
        if(find)
        {
          std::cout << "You find the element using the binary search recursive." << std::endl;
        }
        else{
          std::cout << "You not find the element using the binary search recursive." << std::endl;
        }
        std::cout << "And the time of search was" << std::chrono::duration <double, std::milli> (diff).count() << " ms." << std::endl;
      }
      break;
    default:
      std::cout << "This isn't a valid option, please restart the program." << std::endl;
      break;
  }
  delete[] list;
	return 0;
}


================================================
FILE: algorithms/binary_search/java/binarysearch.java
================================================
// Java implementation of Binary Search
class BinarySearch
{
    // Returns index of x if it is present in arr[l..r], else return -1
    int binarySearch(int ar[], int l, int r, int x){
		if(ar.length == 0) {
    		return -1;
    	}
		
        if (r >= l){
            int mid = l + (r - l) / 2;
            // If the search is present at the mid postion
            if (ar[mid] == x){
               return mid;
            }
            // If element is smaller than mid, then it can only be in left subarray
            if (ar[mid] > x){
               return binarySearch(ar, l, mid - 1, x);
            }
            // Else the element can only be present in right subarray
            return binarySearch(ar, mid + 1, r, x);
        }
        // We reach here when element is not present in array
        return -1;
    }
    // Main method for testing
    public static void main(String args[])
    {
        BinarySearch ob = new BinarySearch();
        int arr[] = {1, 4, 5, 10, 11, 27, 36, 67, 90};
        int n = arr.length;
        int x = 10;
        int result = ob.binarySearch(arr, 0, n - 1, x);
        if (result == -1){
            System.out.println("Element not present");
        }
        else{
            System.out.println("Element found at index " + result);
        }
    }
}


================================================
FILE: algorithms/binary_search/javascript/binary_search.js
================================================
function binarySearch(ar, el, compare_fn) {
    var m = 0;
    var n = ar.length - 1;
    while (m <= n) {
        var k = (n + m) >> 1;
        var cmp = compare_fn(el, ar[k]);
        if (cmp > 0) {
            m = k + 1;
        } else if(cmp < 0) {
            n = k - 1;
        } else {
            return k;
        }
    }
    return -m - 1;
}


================================================
FILE: algorithms/binary_search/python/binary_search.py
================================================
#Simple implementation of the binary search

def b_search(a,s,start,end):
    target = int((start+end)/2)
    if start > end:
        return -1
    if s == a[target]:
        return target
    if s > a[target]:
        return b_search(a,s, target+1, end)
    if s < a[target]:
        return b_search(a,s, start, target-1)

#input: s = target, a = array 
print('Insert array (list of ints separated by a space): ')
a = list(map(int, input().split()))
print('Insert target: ')
s = int(input())
print('Pos: ')
print(b_search(a,s,0,len(a)-1))


================================================
FILE: algorithms/binary_search/ruby/binary_search.rb
================================================
def binary_search(an_array, item)
  first = 0
  last = an_array.length - 1

  while first <= last
    i = (first + last) / 2

    if an_array[i] == item
      return i
    elsif an_array[i] > item
      last = i - 1
    elsif an_array[i] < item
      first = i + 1
    else
      return -1
    end
  end
end

arr = [0,1,2,3,4,27,5,6,7,8,9]

binary_search(arr, 27)
# => 5


================================================
FILE: algorithms/bipartite_check/cpp/bipartite.cpp
================================================
#include<bits/stdc++.h>
using namespace std;
int col[100];
int G[100][100];
int nodes,edges;
bool bipartite(int src)
{
col[src]=1;
queue<int> q;
q.push(src);
while(!q.empty())
{
	int u=q.front();
	q.pop();
	for(int i=1;i<=nodes;i++)
	{
		if(G[u][i]==1 && col[i]==-1)
		{
			col[i]=1-col[u];
			q.push(i);
		}
		else
			if(G[u][i]==1 && col[i]==col[u])
				return false;
	}
}
return true;

}
int main()
{

	cin>>nodes>>edges;
	for(int i=0;i<100;i++)
	{
		col[i]=-1;
	for(int j=0;j<100;j++)
	{
		G[i][j]=0;
	}
}
	for(int i=0;i<edges;i++)
	{
		int u,v;
		cin>>u>>v;
		G[u][v]=1;
		G[v][u]=1;

	}
	cout<<bipartite(1);

}


================================================
FILE: algorithms/bitwise/cpp/generating_subsets.cpp
================================================
#include <iostream>
#include <vector>

#define pb push_back

using namespace std;

int main(void)
{
    vector<int> v = {1,2,3};
    int numSubsets = 1 << v.size();
    for(int i = 0; i < numSubsets; ++i)
    {
        int pos = v.size() - 1;
        int subsetMask = i;
        cout << "{ ";
        while(subsetMask > 0)
        {
            if(subsetMask & 1)
                cout << v[pos] << " ";
            subsetMask >>= 1;
            pos--;
        }
        cout << "}\n";
    }
    return 0;
}


================================================
FILE: algorithms/bitwise/java/AddTwoNumbersWithoutPlusOperator.java
================================================

public class AddTwoNumbersWithoutPlusOperator {
    public static void main(String[] args) {
        int a = 10;
        int b = 90;
        add(a, b);
    }

    private static void add(int a, int b) {
        int carry;
        while (b != 0) {
            carry = a & b;
            a = a ^ b;
            b = carry << 1;
        }
        System.out.println("The sum  " + a);
    }
}


================================================
FILE: algorithms/bitwise/java/BinaryPalidrome.java
================================================
public class BinaryPalidrome {
    // check if binary representation of a number is palidrome
    public static void main(String[] args) {
        int n = 153;
        if (new BinaryPalidrome().isPalidrome(n)) {
            System.out.println("Yes, the binary representation of the number " + n + " is palidrome.");
        } else {
            System.out.println("No, the binary representation of the number " + n + " is not a palidrome.");
        }
    }

    private boolean isPalidrome(int n) {
        int m = getTotalBits(n) - 1;
        int i = 0;
        while (i <= m) {
            if (kthBit(n, i) != kthBit(n, m)) {
                return false;
            }
            i++;
            m--;
        }
        return true;
    }

    private int kthBit(int n, int kthBit) {
        return (n & 1 << kthBit) > 0 ? 1 : 0;
    }

    private int getTotalBits(int n) {
        int totalBits = 0;
        while (n != 0) {
            totalBits++;
            n = n >> 1;
        }
        return totalBits;
    }
}


================================================
FILE: algorithms/bitwise/java/NegateANumberWithoutPlusOperator.java
================================================
public class NegateANumberWithoutPlusOperator {
    public static void main(String[] args) {
        NegateANumberWithoutPlusOperator number = new NegateANumberWithoutPlusOperator();
        int n = 54;
        System.out.println("Negation of number " + n + " is " + number.negate(n));
    }

    private int negate(int n) {
        n = ~n;
        return add(n, 1);
    }
    private int add(int a, int b) {
        int carry;
        while (b != 0) {
            carry = a & b;
            a = a ^ b;
            b = carry << 1;
        }
        return a;
    }
}


================================================
FILE: algorithms/bitwise/java/Optimized_permutation
================================================
//Initial values
int x = 0;
int y = 1;
//Optimzed permutation:
x = x ^ y;
y = x ^ y;
x = x ^ y;
//Yields: x = 1 and y = 0


================================================
FILE: algorithms/bitwise/java/Subsets.java
================================================
/**
 * Subsets of a set:
 * input: array of size of n elements
 * output: 2^n subsets
 */

public class Subsets {
    public static void main(String[] args) {
        char[] array = {'a', 'b', 'c'};
        Subsets set = new Subsets();
        set.printSubsets(array);
    }

    private void printSubsets(char[] set) {
        int n = set.length;
        int totalSubsets = 1 << n;
        for (int i = 0; i < totalSubsets; i++) {
            System.out.print("{ ");
            for (int j = 0; j < n; j++) {
                if ((i & (1 << j))  > 0) {
                    System.out.print(set[j] + " ");
                }
            }
            System.out.println(" }");

        }


    }
}

================================================
FILE: algorithms/bogo_sort/java/BogoSort.java
================================================
import java.util.Arrays;
import java.util.List;
import java.util.Collections;

public class BogoSort {
	
	public static List<Integer> bogoSort(List<Integer> nums) {
		if (isSorted(nums)) {
			return nums;
		}
		
		for (;;) {
			Collections.shuffle(nums);
			
			if (isSorted(nums)) {
				break;
			}
		}
		
		return nums;
	}
	
	public static boolean isSorted(List<Integer> x) {
		for (int i = 0; i < x.size() - 1; i++) {
			if (x.get(i) > x.get(i + 1)) {
				return false;
			}
		}
		
		return true;
	}
}

================================================
FILE: algorithms/bogo_sort/python/bogo.py
================================================
from random import *

seed()
x = []
for i in range(0, 10):
    x.append(randint(0, 100))

def inorder(x):
    i = 0
    j = len(x)
    while i + 1 < j:
        if x[i] > x[i + 1]:
            return False
        i += 1
    return True

def bogo(x):
    while not inorder(x):
        shuffle(x)
    return x



================================================
FILE: algorithms/bogo_sort/ruby/bogo_sort.rb
================================================
def bogosort(arr)
  arr.shuffle! while !arr.each_cons(2).all? do |x, y|
    x <= y
  end
end
array = [ 0, 5, 4, 3, 2, 8, 7, 1, 9, 6]
bogosort(array)
puts array # => 0, 1, 2, 3, 4, 5, 6, 7, 8, 9


================================================
FILE: algorithms/breadth_first_search/cpp/bfs.cpp
================================================
#include<iostream>
#include <list>
 
using namespace std;
 
// This class represents a directed graph using adjacency list representation
class Graph
{
    int V;    // No. of vertices
    list<int> *adj;    // Pointer to an array containing adjacency lists
public:
    Graph(int V);  // Constructor
    void addEdge(int v, int w); // function to add an edge to graph
    void BFS(int s);  // prints BFS traversal from a given source s
};
 
Graph::Graph(int V)
{
    this->V = V;
    adj = new list<int>[V];
}
 
void Graph::addEdge(int v, int w)
{
    adj[v].push_back(w); // Add w to v’s list.
}
 
void Graph::BFS(int s)
{
    // Mark all the vertices as not visited
    bool *visited = new bool[V];
    for(int i = 0; i < V; i++)
        visited[i] = false;
 
    // Create a queue for BFS
    list<int> queue;
 
    // Mark the current node as visited and enqueue it
    visited[s] = true;
    queue.push_back(s);
 
    // 'i' will be used to get all adjacent vertices of a vertex
    list<int>::iterator i;
 
    while(!queue.empty())
    {
        // Dequeue a vertex from queue and print it
        s = queue.front();
        cout << s << " ";
        queue.pop_front();
 
        // Get all adjacent vertices of the dequeued vertex s
        // If a adjacent has not been visited, then mark it visited
        // and enqueue it
        for(i = adj[s].begin(); i != adj[s].end(); ++i)
        {
            if(!visited[*i])
            {
                visited[*i] = true;
                queue.push_back(*i);
            }
        }
    }
}
int main()
{
    Graph g(4);
    g.addEdge(0, 1);
    g.addEdge(0, 2);
    g.addEdge(1, 2);
    g.addEdge(2, 0);
    g.addEdge(2, 3);
    g.addEdge(3, 3);
 
    cout << "Following is Breadth First Traversal "
         << "(starting from vertex 2) n";
    g.BFS(2);
 
    return 0;
}


================================================
FILE: algorithms/bubble_sort/README.md
================================================
# Bubble Sort

This folder contains examples of the bubble sort algorithm in the following programming languages:

* bash
* C
* C++
* Crystal
* C#
* Elixir
* Go
* Haskell
* Java
* JavaScript
* Kotlin
* Objective-C
* Power Shell
* Python
* Ruby
* Swift
* Visual Basic


================================================
FILE: algorithms/bubble_sort/assembly_mips/bubble_sort.asm
================================================
## Data declaration section 
.data
# these are globals
  # array of word long ints
  myarray:    .word 23, 4, 34, 55, 87, 24, 99, 12, 233, 45, 43245, 23, 45, 68, 69
  mysize:     .word 15

.text ## Assembly language instructions go in text segment 
j main # very first, goto main.

bubblesort:
   # inputs:
   # ra must be set before calling this and contain the location to where this will return after execution
   # a0 must be the base address of the array of integers to print
   # a1 must be the size of the array to print (or the number of elements in the array to print)
   # outputs: only output is the system "display", no return values
   # saved registers: no need as this internally only uses t registers
   #
   # internal register uses
   # t0 = address of base of myarray from input $a0
   # t1 = value of mysize from input $a1
   # t2 is used to put address, once calculated of array[index]
   # t3 is used to put address, once calculated of array[index + 1]
   # t4 is used to put the value of array[index]
   # t5 is used to put the value of array[index + 1]
   # t6 bool hold comparison result between t2 and t3
   # t7 bool hasChanged. Keep track of if changes have been made in array
   # t8 is used to hold comparison result
   # t9 = index into array 
  add $t0 $0 $a0  # move a0 to t0 via an add statement
  move $t1 $a1    # move a1 to t1 via the move command
  # either of the above commands work. Before you choose, look at the 
  #   assembled version of each command
  
  #################################################################################
  #print array (unsorted)
  add $t9 $0 $0   # initialize the counter before the loop
  printunsorted:
    #do stuff
    sll $t2 $t9 2   # multiply index by 4
    add $t2 $t0 $t2 # add base address of array to 4*index
    lw $a0 0($t2) # put value of myarray[index] into a0
    
    li $v0, 1 # load instruction 1 (print an int whose value is in a0)
    syscall
    
    li $v0, 11        #load instruction 11 (print single char whose value is in a0)
    addi $a0, $0, 0x20  #load ascii char 32 = 0x20 = 'space'
    syscall
    
    addi $t9 $t9 1  # increment counter 
    slt $t8 $t9 $t1  # compare counter t9 to size t1
    bne $t8 $0 printunsorted # loop if $t9 < size
  #end printsorted
  li $v0, 11        #load instruction 11 (print single char whose value is in a0)
    addi $a0, $0, 0x0A  #load ascii char 32 = 0x0A = 'new line'
    syscall
  #################################################################################
  addi $t1 $t1 -1 #loop for (size - 1)
  outer:
    move $t7 $0   # set default value of register inside beginning of outer do-while loop     
    
    add $t9 $0 $0   # initialize the counter before the loop
    inner:
      #do stuff
      sll $t2 $t9 2   # multiply index by 4
    
      add $t2 $t0 $t2 # add base address of array to 4*index
      addi $t3 $t2 4 #place address of myarray[index + 1] in t3
    
      lw $t4 0($t2) # put value of myarray[index] into t2 ### change from    lw $a0 0($t2) # put value of myarray[index] into t2 #which is used to be able to call print syscall, which uses $a0
      lw $t5 0($t3) #put value of myarray[index + 1] into t3
    
      slt $t6 $t5 $t4 #compare myarray[index + 1] < myarray[index]
      beq $t6 $0 noswap # don't swap if in correct relative location 
      #swap
      sw $t5 0($t2) # myarray[index] = myarray[index + 1]
      sw $t4 0($t3) # myarray[index + 1] = myarray[index] (value before swap)
      addi $t7 $t7 1   # set default value of register inside beginning of outer do-while loop
      noswap:#skipped past swap operations
    
      addi $t9 $t9 1  # increment counter
      slt $t8 $t9 $t1  # compare counter t9 to size t1
      bne $t8 $0 inner # loop if $t9 < size
    #end inner
    bne $t7 $0 outer # loop if $t0 != 0 (hasChanged)
  #end outer
  #################################################################################
  addi $t1 $t1 1 #reset size of loop counter
  #print array (sorted)
  add $t9 $0 $0   # initialize the counter before the loop
  printsorted:
   #do stuff
    sll $t2 $t9 2   # multiply index by 4
    add $t2 $t0 $t2 # add base address of array to 4*index
    move $a3 $a0
    lw $a0 0($t2) # put value of myarray[index] into a0
    
    li $v0, 1 # load instruction 1 (print an int whose value is in a0)
    syscall
    
    li $v0, 11        #load instruction 11 (print single char whose value is in a0)
    addi $a0, $0, 0x20  #load ascii char 32 = 0x20 = 'space'
    syscall
    
    addi $t9 $t9 1  # increment counter  
    slt $t8 $t9 $t1  # compare counter t9 to size t1
    bne $t8 $0 printsorted # loop if $t9 < size
  #################################################################################
  jr $ra #leave function


main: ## Start of code section
  la $a0 myarray
  lw $a1 mysize
  jal bubblesort # jump to bubblesort and put current address in $ra so that it can come 
    #  back (ie return to here after function call)

leave:
  li $v0, 10         # load system instruction 10 (terminate program) into v0 register
  syscall


================================================
FILE: algorithms/bubble_sort/bash/bubblesort.sh
================================================
#!/bin/bash
echo "enter maximum number"
read n


echo "enter Numbers in array:"
for (( i = 0; i < $n; i++ ))
do
read nos[$i]
done

for (( i = 0; i < $n ; i++ ))
do
	for (( j = $i; j < $n; j++ ))
	do
		if [ ${nos[$i]} -gt ${nos[$j]}  ]; then
		t=${nos[$i]}
		nos[$i]=${nos[$j]}
		nos[$j]=$t
		fi
	done
done

# Printing the sorted number
echo -e "\nSorted Numbers "
for (( i=0; i < $n; i++ ))
	do
	echo ${nos[$i]}
done


================================================
FILE: algorithms/bubble_sort/c/bubble_sort.c
================================================
//algorithm of bubble sort in c
//start from the first elemnent 
/*1. start comparing it with the next element
  2. swap the element with the first smaller element it encounters.
  3. every traversal pushes the largest element towards the end.
*/
  



void bubbleSort(int arr[], int n)
{
   int i, j;
   for (i = 0; i < n-1; i++)      
 
       // Last i elements are already in place   
       for (j = 0; j < n-i-1; j++) 
           if (arr[j] > arr[j+1])
              swap(&arr[j], &arr[j+1]);
}

int main()
{
int i,j,k;
int a[5];
for(i=0;i<5;i++)
scanf("%d",&a[i]);
bubblesort(a,5);
for(i=0;i<5;i++)
printf("%d\n",a[i]);

return 0;
}


================================================
FILE: algorithms/bubble_sort/cpp/bubble_sort_1.cpp
================================================
#include<iostream>
using namespace std;

//global variables for ease of use
long long int array[1000],n,temp;

//function for bubble sort
void bubble_sort()
{

	for(register long long int i=0;i<n;i++)
	{
		for(register long long int j=0;j<n-i-1;j++)
		{
			if(array[j]>array[j+1])
			{
				temp=array[j];
				array[j]=array[j+1];
				array[j+1]=temp;
			}
		}	
	}
}
int main()
{
	// Enter the number of elements 
	cin>>n;

	//Entering the elements
	for(register long long int i=0;i<n;i++)
	{
		cin>>array[i];
	}

	//buuble sort
	bubble_sort();

	//Sorted order
	for(register long long int i=0;i<n;i++)
	{
		cout<<array[i]<<" ";
	}
}


================================================
FILE: algorithms/bubble_sort/cpp/bubblesort.cpp
================================================
/* C++ Program - Bubble Sort */

#include<iostream.h>
#include<conio.h>
void main()
{
	clrscr();
	int n, i, arr[50], j, temp;
	cout<<"Enter total number of elements :";
	cin>>n;
	cout<<"Enter "<<n<<" numbers :";
	for(i=0; i<n; i++)
	{
		cin>>arr[i];
	}
	cout<<"Sorting array using bubble sort technique...\n";
	for(i=0; i<(n-1); i++)
	{
		for(j=0; j<(n-i-1); j++)
		{
			if(arr[j]>arr[j+1])
			{
				temp=arr[j];
				arr[j]=arr[j+1];
				arr[j+1]=temp;
			}
		}
	}
	cout<<"Elements sorted successfully..!!\n";
	cout<<"Sorted list in ascending order :\n";
	for(i=0; i<n; i++)
	{
		cout<<arr[i]<<" ";
	}
	getch();
}


================================================
FILE: algorithms/bubble_sort/crystal/bubble_sort.cr
================================================
def bubbleSort(array)
  count = 0
  while true
    swapped = false
    i = 0

    while true
      if array[i] > array[i + 1]
        array[i], array[i + 1] = array[i + 1], array[i]
        swapped = true
      end

      i += 1
      break if i == array.size - 1
    end

    break if !swapped

    count += 1
    break if count == array.size - 1
  end

  array
end

numbers = [4, 2, 8, 1, 0, 10]

puts "Unsorted: #{numbers}"

puts "Sorted: #{bubbleSort(numbers)}"


================================================
FILE: algorithms/bubble_sort/csharp/BubbleSort.cs
================================================
using System;
using System.Collections.Generic;


public class BubbleSort {
    private static void Main(string[] args) {
         Console.WriteLine("Input the elements of the array");
            var isNumber = true;
            var userInput = new List<int>();
            while (isNumber) {
                var input = Console.ReadLine();
                if (int.TryParse(input, out var temp )) {
                    userInput.Add(temp);
                } else {
                    isNumber = false;
                }
            }
            Console.Write('\n');
            Console.WriteLine("Array before Sorting with Bubble Sort");
            foreach (var entry in userInput) {
                Console.Write(entry + "   ");
            }
            BubbleSort(userInput);
            Console.Write('\n');
            Console.WriteLine("Array after Sorting with Bubble Sort");
            foreach (var entry in userInput) {
                Console.Write(entry + "   ");
            }
            Console.Read();
        }
        
        private static void BubbleSort(IList<int> list) {
            var n = list.Count;
            do {
                var newn = 1;
                for (var i = 0; i < n - 1; i++) {
                    if (list[i] <= list[i + 1]) {
                        continue;
                    }
                    var temp = list[i];
                    list[i] = list[i + 1];
                    list[i + 1] = temp;
                    newn = i + 1;
                }
                n = newn;
            } while (n > 1);
        }
    }


================================================
FILE: algorithms/bubble_sort/elixir/README.md
================================================
# Elixir BubbleSort

A simple implementation of the bubble sort algorithm in Elixir.

Example of usage:

```
iex(1)> c("bubblesort.ex")
[BubbleSort]
iex(2)> BubbleSort.sort(1..1_000 |> Enum.reverse)
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
 43, 44, 45, 46, 47, 48, 49, 50, ...]
```


================================================
FILE: algorithms/bubble_sort/elixir/bubblesort.ex
================================================
defmodule BubbleSort do
  def sort([]),  do: []
  def sort(list) do
    round = swap(list)
    cond do
      round == list -> list
      true -> sort(round)
    end
  end

  defp swap([head | []]), do: [head]
  defp swap([head | [second | tail]]) do
    cond do
      head < second -> [head | swap([second | tail])]
      true  -> [second | swap([head | tail])]
    end
  end
end


================================================
FILE: algorithms/bubble_sort/go/bubble-sort-algorithm.go
================================================
package main

import "fmt"

func main() {
	var numbers []int = []int{5, 4, 2, 3, 1, 0}
	fmt.Println("Unsorted:", numbers)

	bubbleSort(numbers)
	fmt.Println("Sorted:", numbers)
}

func bubbleSort(numbers []int) {
	var N int = len(numbers)
	var i int
	for i = 0; i < N; i++ {
		sweep(numbers)
	}
}

func sweep(numbers []int) {
	var N int = len(numbers)
	var firstIndex int = 0
	var secondIndex int = 1

	for secondIndex < N {
		var firstNumber int = numbers[firstIndex]
		var secondNumber int = numbers[secondIndex]

		if firstNumber > secondNumber {
			numbers[firstIndex] = secondNumber
			numbers[secondIndex] = firstNumber
		}

		firstIndex++
		secondIndex++
	}
}


================================================
FILE: algorithms/bubble_sort/haskell/bubble_sort.hs
================================================
import Debug.Trace

main :: IO()
main = do
  let sorted = bubbleSort [6, 5, 3, 1, 8, 7, 2, 4] :: [Integer]
  print sorted

bubbleSort :: (Ord a, Show a) => [a] -> [a]
--bubbleSort lst | trace ("sorting: " ++ show lst) False = undefined
bubbleSort [] = []
bubbleSort [x] = [x]
bubbleSort (x:y:rest) =
  bubbleSort (init bubbled) ++ [last bubbled]
  where
    (first, second) = if x > y then (y,x) else (x,y)
    bubbled = first : bubbleSort (second:rest)


================================================
FILE: algorithms/bubble_sort/java/BubbleSortExample.java
================================================
import java.util.Scanner;

public class BubbleSortExample {

    private static void bubbleSort(int[] arr) {
        int n = arr.length;
        int temp = 0;
        for(int i=0; i < n; i++){
            for(int j=1; j < (n-i); j++){
                if(arr[j-1] > arr[j]){
                    //swap elements
                    temp = arr[j-1];
                    arr[j-1] = arr[j];
                    arr[j] = temp;
                }

            }
        }

    }
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        System.out.println("Input the size of array");
        int n = in.nextInt();
        int[] arr = new int[n];

        System.out.println("Input the elements of array");
        for(int i=0; i<n; i++){
            arr[i] = in.nextInt();
        }

        System.out.println("Array Before Bubble Sort");
        for (int anArr : arr) {
            System.out.print(anArr + " ");
        }
        System.out.println();

        bubbleSort(arr);//sorting array elements using bubble sort

        System.out.println("Array After Bubble Sort");
        for (int anArr : arr) {
            System.out.print(anArr + " ");
        }

    }
}


================================================
FILE: algorithms/bubble_sort/java/GenericBubbleSort.java
================================================

class GenericBubbleSort {

    public static <T extends Comparable<T>> void bubble_sort(T array[]){
        boolean swapped;
        int indexOfLastUnsortedElement =  array.length;
        do{
            swapped = false;
            for(int i=0; i < indexOfLastUnsortedElement - 1; i++){
                if(array[i].compareTo(array[i+1]) > 0){
                    swap(i, array);
                    swapped = true;
                }
            }
            indexOfLastUnsortedElement--;
            printArray(array);
        }while(swapped);
    }

    private static <T> void swap(int index, T[] array){
        T temp = array[index];
        array[index] = array[index + 1];
        array[index + 1] = temp;
    }

    private static <T> void printArray(T[] input){
        for(int i  = 0; i < input.length; i++){
            System.out.print(input[i] + " ");
        }
        System.out.print("\n");
    }

    public static void main(String[] args){
        bubble_sort(new Integer[] {4, 2, 9, 6, 23, 12, 34, 0, 1});
        bubble_sort(new String[] { "c", "a", "e", "d", "b" });
    }
}

================================================
FILE: algorithms/bubble_sort/javascript/bubble-sort.js
================================================
function bubbleSort(a)
{
    let swapped;
    do {
        swapped = false;
        for (let i=0; i < a.length-1; i++) {
            if (a[i] > a[i+1]) {
                let temp = a[i];
                a[i] = a[i+1];
                a[i+1] = temp;
                swapped = true;
            }
        }
    } while (swapped);
    return a;
}


================================================
FILE: algorithms/bubble_sort/javascript/bubbleSort.js
================================================
function bubbleSort(array) {
    let len = array.length;
    let temp;

    for (let i = 0; i < len; i++) {
        for (let j = 0; j < len; j++) {
            if (array[i] < array[j]) {
                temp = array[i];
                array[i] = array[j];
                array[j] = temp;
            }
        }
    }
}
// export default bubbleSort;
module.exports = bubbleSort;


================================================
FILE: algorithms/bubble_sort/javascript/main_bs.js
================================================
let bubbleSort = require('./bubbleSort');
// import bubbleSort from './bubbleSort';
let rl = require('readline');
// import rl from 'readline';
// allow input through console
let prompt = rl.createInterface(process.stdin,
                                 process.stdout);

let array = [];
let flag = true;
console.log('Enter all the values. Press q to stop input');

function readInput() {
    prompt.question('>>', function(inp) {
        if (inp == 'q') {
            console.log('initial array: ', array);
            bubbleSort(array);
            console.log('final array: ', array);            

            return prompt.close();
        }

        array.push(Number(inp));
        readInput();
    });
}

readInput();


================================================
FILE: algorithms/bubble_sort/kotlin/bubblesort.kt
================================================
public class bubbleSort : Algorithm{

    public override fun sort(arr: Array<Long>): Array<Long> {
        var swappedElements : Boolean;
        do {
            swappedElem = false;
            for (i in 0..arr.size - 2){
                if (arr[i] > arr[i + 1]){
                    swap(arr, i, i + 1);
                    swappedElem = true;
                }
            }
        } while (swappedElem);
        return arr;
    }

    public override fun getName(): String {
        return "BubbleSort Algorithm";
    }
}


================================================
FILE: algorithms/bubble_sort/objetive-c/BubbleSort.m
================================================
- (NSArray *)bubbleSort:(NSArray *)unsortedArray {
    //create mutable copy of the array
    NSMutableArray *unsortedMutableArray = [unsortedArray mutableCopy];
    
    for (int i = 0; i < unsortedMutableArray.count; ++i) {
        for (int j = 0; j < (unsortedMutableArray.count - i - 1); ++j) {
            //reading integer values of the current and the next elements in the array
            NSInteger currElement = [unsortedMutableArray[j] integerValue];
            NSInteger nextElement = [unsortedMutableArray[j + 1] integerValue];
            
            //comparing the elements
            if (currElement > nextElement) {
                NSNumber *temp = unsortedMutableArray[j]; //keeping the current element in a temp
                //swapping the elements
                unsortedMutableArray[j] = unsortedMutableArray[j + 1];
                unsortedMutableArray[j + 1] = temp;
            }
        }
    }
    //return the sorted array
    return [NSArray arrayWithArray:unsortedMutableArray];
}


================================================
FILE: algorithms/bubble_sort/perl/BubbleSort.pl
================================================
my @array = ( 5, 6, 3, 1, 7, 3, 2, 9, 10, 4 );

for my $x ( reverse 1 .. $#array ) {
    for my $y ( 0 .. $x - 1 ) {
        @array[ $y, $y + 1 ] = @array[ $y + 1, $y ]
            if $array[$y] > $array[ $y + 1 ];
    }
}

print "@array\n";

================================================
FILE: algorithms/bubble_sort/power_shell/bubble_sort.ps1
================================================
function bubblesort ($a) {
    $l = $a.Length
    $hasChanged = $true
    while ($hasChanged) {
        $hasChanged = $false
        $l--
        for ($i = 0; $i -lt $l; $i++) {
            if ($a[$i] -gt $a[$i+1]) {
                $a[$i], $a[$i+1] = $a[$i+1], $a[$i]
                $hasChanged = $true
            }
        }
    }
}


================================================
FILE: algorithms/bubble_sort/python/bubble_sort.py
================================================
def bubbleSort(a):
    n = len(a)
    sorted = False
    while not sorted:
        sorted = True
        for i in range(0, n - 1):
            if a[i] > a[i + 1]:
                sorted = False
                a[i], a[i + 1] = a[i + 1], a[i]

a = [12, 33, 1, 3, 54, 32, 78, 54, 99, 6]
print(a)
bubbleSort(a)
print(a)


================================================
FILE: algorithms/bubble_sort/ruby/bubble_sort.rb
================================================
def bubble_sort(array)
  n = array.length
  loop do
    swapped = false

    (n-1).times do |i|
      next unless array[i] > array[i+1]
      array[i], array[i+1] = array[i+1], array[i]
      swapped = true
    end

    break if not swapped
  end

  array
end

arr = [1,4,5,2,6,7,8,3]
bubble_sort(arr)
# => [1, 2, 3, 4, 5, 6, 7, 8]


================================================
FILE: algorithms/bubble_sort/swift/bubble_sort.swift
================================================
func bubbleSort(unsortedArray: Array<NSNumber>) -> Array<NSNumber> {
    //mutable copy of the initial array
    var mutableArray = unsortedArray
    //double looping through the array
    for i in 0..<mutableArray.count {
        for j in 0..<(mutableArray.count - i - 1) {
            //checking the elements
            if (mutableArray[j] as! Int > mutableArray[j + 1] as! Int) {
                let temp = mutableArray[j] //storing into a temp value
                //swapping the elements
                mutableArray[j] = mutableArray[j + 1]
                mutableArray[j + 1] = temp
            }
        }
    }
    //returning the sorted array
    let sortedArray = mutableArray
    return sortedArray
}


================================================
FILE: algorithms/bubble_sort/vb/bubble_sort.bas
================================================
Option Explicit
'VB6 Specific
Private Sub bubble_sort()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim array_unsorted(1001) As String
Dim array_sorted(1001) As String
Dim temp As String
Dim swapped As Boolean
    i = 1000
    j = 0
    Do
        swapped = False
        For j = 1 To i - 1
            If LCase(array_unsorted(j)) > LCase(array_unsorted(j + 1)) Then
                temp = array_unsorted(j)
                array_unsorted(j) = array_unsorted(j + 1)
                array_unsorted(j + 1) = temp
                swapped = True
            End If
        Next j
        i = i - 1
    Loop Until Not swapped
    For k = 1 To 1000
        array_sorted(k) = array_unsorted(k)
    Next k
End Sub




================================================
FILE: algorithms/bucket_sort/bucket_sort.cpp
================================================
// C++ program to sort an array using bucket sort
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
// Function to sort arr[] of size n using bucket sort
void bucketSort(float arr[], int n)
{
    // 1) Create n empty buckets
    vector<float> b[n];
    
    // 2) Put array elements in different buckets
    for (int i=0; i<n; i++)
    {
       int bi = n*arr[i]; // Index in bucket
       b[bi].push_back(arr[i]);
    }
 
    // 3) Sort individual buckets
    for (int i=0; i<n; i++)
       sort(b[i].begin(), b[i].end());
 
    // 4) Concatenate all buckets into arr[]
    int index = 0;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < b[i].size(); j++)
          arr[index++] = b[i][j];
}
 
/* Driver program to test above funtion */
int main()
{
    float arr[] = {0.897, 0.565, 0.656, 0.1234, 0.665, 0.3434};
    int n = sizeof(arr)/sizeof(arr[0]);
    bucketSort(arr, n);
 
    cout << "Sorted array is \n";
    for (int i=0; i<n; i++)
       cout << arr[i] << " ";
    return 0;
}

================================================
FILE: algorithms/bucket_sort/bucket_sort.java
================================================
//This is a java program to sort numbers using bucket sort
import java.util.Random;
 
public class Bucket_Sort 
{
    static int[] sort(int[] sequence, int maxValue) 
    {
        // Bucket Sort
        int[] Bucket = new int[maxValue + 1];
        int[] sorted_sequence = new int[sequence.length];
 
        for (int i = 0; i < sequence.length; i++)
            Bucket[sequence[i]]++;
 
        int outPos = 0;
        for (int i = 0; i < Bucket.length; i++)
            for (int j = 0; j < Bucket[i]; j++)
                sorted_sequence[outPos++] = i;
 
        return sorted_sequence;
    }
 
    static void printSequence(int[] sorted_sequence) 
    {
        for (int i = 0; i < sorted_sequence.length; i++)
            System.out.print(sorted_sequence[i] + " ");
    }
 
    static int maxValue(int[] sequence) 
    {
        int maxValue = 0;
        for (int i = 0; i < sequence.length; i++)
            if (sequence[i] > maxValue)
                maxValue = sequence[i];
        return maxValue;
    }
 
    public static void main(String args[]) 
    {
        System.out
                .println("Sorting of randomly generated numbers using BUCKET SORT");
        Random random = new Random();
        int N = 20;
        int[] sequence = new int[N];
 
        for (int i = 0; i < N; i++)
            sequence[i] = Math.abs(random.nextInt(100));
 
        int maxValue = maxValue(sequence);
 
        System.out.println("\nOriginal Sequence: ");
        printSequence(sequence);
 
        System.out.println("\nSorted Sequence: ");
        printSequence(sort(sequence, maxValue));
    }
}

================================================
FILE: algorithms/bucket_sort/bucket_sort.py
================================================
def bucketsort( A ):
  # get hash codes
  code = hashing( A )
  buckets = [list() for _ in range( code[1] )]
  # distribute data into buckets: O(n)
  for i in A:
    x = re_hashing( i, code )
    buck = buckets[x]
    buck.append( i )
 
  # Sort each bucket: O(n).
  # I mentioned above that the worst case for bucket sort is counting
  # sort. That's because in the worst case, bucket sort may end up
  # with one bucket per key. In such case, sorting each bucket would
  # take 1^2 = O(1). Even after allowing for some probabilistic
  # variance, to sort each bucket would still take 2-1/n, which is
  # still a constant. Hence, sorting all the buckets takes O(n).
 
  for bucket in buckets:
    insertionsort( bucket )
 
  ndx = 0
  # merge the buckets: O(n)
  for b in range( len( buckets ) ):
    for v in buckets[b]:
      A[ndx] = v
      ndx += 1
 
import math
 
def hashing( A ):
  m = A[0]
  for i in range( 1, len( A ) ):
    if ( m < A[i] ):
      m = A[i]
  result = [m, int( math.sqrt( len( A ) ) )]
  return result
 
 
def re_hashing( i, code ):
  return int( i / code[0] * ( code[1] - 1 ) )

================================================
FILE: algorithms/bucket_sort/c/bucket_sort.c
================================================
    /*

     * C Program to Sort Array using Bucket Sort

     */

    #include <stdio.h>

     

    /* Function for bucket sort */

    void Bucket_Sort(int array[], int n)

    {  

        int i, j;  

        int count[n]; 

        for (i = 0; i < n; i++)

            count[i] = 0;

     

        for (i = 0; i < n; i++)

            (count[array[i]])++;

     

        for (i = 0, j = 0; i < n; i++)  

            for(; count[i] > 0; (count[i])--)

                array[j++] = i;

    }   

    /* End of Bucket_Sort() */

     

    /* The main() begins */

    int main()

    {

        int array[100], i, num; 

     

        printf("Enter the size of array : ");   

        scanf("%d", &num);   

        printf("Enter the %d elements to be sorted:\n",num); 

        for (i = 0; i < num; i++)

            scanf("%d", &array[i]); 

        printf("\nThe array of elements before sorting : \n");

        for (i = 0; i < num; i++)

            printf("%d ", array[i]);  

        printf("\nThe array of elements after sorting : \n"); 

        Bucket_Sort(array, num); 

        for (i = 0; i < num; i++)

            printf("%d ", array[i]);   

        printf("\n");     

        return 0;

    }


================================================
FILE: algorithms/caesar_cipher/java/caesar.java
================================================
/**
Author : FAHRI YARDIMCI
A Java implementation of Caesar Cipher.
/It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. /
**/
import java.util.Scanner;
public class Caesar {
public static String encode (String message,int shift)
{
	String encoded = "";
	for(int i = 0 ; i<message.length() ;i++)
	{
		int current = message.charAt(i); //using char to shift characters because ascii is in-order latin alphabet
		if(current==32)
		{
			encoded += " ";
			continue;

		}
		else if (current>=65 && current<= 90)
		{
			int numAlphabet = message.charAt(i);
			if(shift + numAlphabet > 90)
			{
				int j = 90 - numAlphabet;
				char nextKey = (char)(65 + (shift - j - 1));
				encoded += nextKey;
				
			}
			else
			{
				char nextKey = (char)(current + shift);
				encoded += nextKey;
			}
		}
		else if (current>=97 && current <= 122)
		{
			int numAlphabet = message.charAt(i);
			if(shift + numAlphabet > 122)
			{
				int j = 122 - numAlphabet;
				char nextKey = (char)(97 + (shift - j - 1));
				encoded += nextKey;
			}
			else
			{
				char nextKey = (char)(current + shift);
				encoded += nextKey;
			}
		}
	}
	return encoded;
}
public static String decode (String message,int shift)
{
	String decoded = "";
	for(int i = 0 ; i<message.length() ;i++)
	{
		int current = message.charAt(i);
		if(current==32)
		{
			decoded += " ";
			continue;

		}
		else if (current>=65 && current<= 90)
		{
			int numAlphabet = message.charAt(i);
			if(numAlphabet - shift < 65)
			{
				int j = numAlphabet - 65;
				char nextKey = (char)(90 - (shift - j - 1));
				decoded += nextKey;
				
			}
			else
			{
				char nextKey = (char)(current - shift);
				decoded += nextKey;
			}
		}
		else if (current>=97 && current <= 122)
		{
			int numAlphabet = message.charAt(i);
			if(numAlphabet - shift < 97)
			{
				int j = numAlphabet - 97;
				char nextKey = (char)(122 - (shift - j - 1));
				decoded += nextKey;
			}
			else
			{
				char nextKey = (char)(current - shift);
				decoded += nextKey;
			}
		}
	}
	return decoded;
}
public static void main(String[] args)
{
	Scanner input = new Scanner(System.in);
	System.out.println("Please enter the message (Latin Alphabet)");
	String message = input.nextLine();
	System.out.println(message);
	System.out.println("Please enter the shift number");
	int shift = input.nextInt() % 26;
	System.out.println("(E)ncode or (D)ecode ?");
	char choice = input.next().charAt(0);
	if(choice == 'E' || choice=='e')
		System.out.println("ENCODED MESSAGE IS \n" + encode(message,shift)); //send our function to handle
	if(choice =='D' || choice =='d')
		System.out.println("DECODED MESSAGE IS \n" + decode(message,shift));
}

}


================================================
FILE: algorithms/caesar_cipher/javascript/caesarCipher.js
================================================
const LEGAL_VALUES = 'abcdefghijklmnopqrstuvwxyz';
const START_CODE = 'a'.charCodeAt(0);
const END_CODE = 'z'.charCodeAt(0);

class CaesarCipher {
  constructor(key) {
    if (key === undefined) {
      this.generateKey();

    } else {
      this.key = key;
      this.validateKey();
    }
  }

  generateKey() {
    this.key = '';

    for (let i = 0; i < 100; i++) {
      let randomIdx = Math.floor(Math.random() * 26);
      this.key += LEGAL_VALUES.charAt(randomIdx);
    }
  }

  validateKey() {
    const emptyKey = this.key.length < 1;
    const hasInvalidChars = this.key.split('').some(letter => {
      return LEGAL_VALUES.indexOf(letter) === -1;
    });

    if (emptyKey || hasInvalidChars) {
      throw new Error('Bad key');
    }
  }

  encode(decodedMessage) {
    let longKey = this.key;
    let encodedMessage = "";

    while (longKey.length < decodedMessage.length) {
      longKey += longKey;
    }

    decodedMessage.split('').forEach((letter, idx) => {
      const currentKeyCode = longKey.charCodeAt(idx);
      const offset = (currentKeyCode - START_CODE);
      let newCharCode = letter.charCodeAt(0) + offset;

      if (newCharCode > END_CODE) {
        newCharCode -= LEGAL_VALUES.length;
      }

      encodedMessage += String.fromCharCode(newCharCode);
    });

    return encodedMessage;
  }

  decode(encodedMessage) {
    let longKey = this.key;
    let decodedMessage = "";

    while (longKey.length < encodedMessage.length) {
      longKey += longKey;
    }

    encodedMessage.split('').forEach((letter, idx) => {
      const currentKeyCode = longKey.charCodeAt(idx);
      const offset = (currentKeyCode - START_CODE);
      let newCharCode = letter.charCodeAt(0) - offset;

      if (newCharCode < START_CODE) {
        newCharCode += LEGAL_VALUES.length;
      }

      decodedMessage += String.fromCharCode(newCharCode);
    });

    return decodedMessage;
  }
}

module.exports = CaesarCipher;


================================================
FILE: algorithms/check_pallindrome_number/c/checkPalindrome.c
================================================
#include <stdio.h>
#include <stdlib.h>

int checkPall(char str[])
{
	for(int i = 0; i < strlen(str); i++)
	{
		if(str[i] != str[strlen(str)-i-1])
		{
			return 0;
		}
	}
	return 1;
}
int main()
{
	char str[10000];
	gets(str);
	if(checkPall(str))
	{
		printf("YES");
	}
	else
	{
		printf("NO");
	}
	return 0;
}


================================================
FILE: algorithms/check_pallindrome_number/cpp/checkPall.cpp
================================================
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int checkPall(char str[])
{
	for(int i = 0; i < strlen(str); i++)
	{
		if(str[i] != str[strlen(str)-i-1])
		{
			return 0;
		}
	}
	return 1;
}
int main()
{
	char str[10000];
	cin >> str;
	if(checkPall(str))
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	return 0;
}


================================================
FILE: algorithms/closest/java/Closest.java
================================================
package algorithms.closest.java;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

/*
This algorithm searches through a list of integers and finds the distance between
the two closest element. It then prints this integer.
 */
public class Closest {
    public static void main(String[] args) {
        //get input
        Scanner sc = new Scanner(System.in).useDelimiter(" ");
        ArrayList<Integer> input = new ArrayList<>();
        //add input to ArrayList
        while (sc.hasNextInt()) {
            input.add(sc.nextInt());
        }
        //sort the list
        Collections.sort(input);
        //initialize closest values, with the first two elements in the list
        int closest = input.get(1)-input.get(0);
        //check all elements in the list
        for(int i = 2; i < input.size(); i++) {
            //change closest if we find two elements with a shorter distance.
            closest = Math.min(closest, input.get(i)-input.get(i-1));
        }
        //print the shortest distance
        System.out.println(closest);
    }
}


================================================
FILE: algorithms/count_sort/javascript/count_sort.js
================================================
"use strict";
var countSort = (arr, range)=>{
    /**
     * Consider the input is in range of 1 to 9
      */
    // this can vary depending on your input array
    let countArr = [];
    //Initialise count array to 0;
    for(let i=0; i <= range; i++){
        countArr[i] = 0;
    }
    for(let i=0; i < arr.length; i++){
        ++countArr[arr[i]];
    }
    for(let i=1; i<= countArr.length-1; i++){
        countArr[i] += countArr[i-1];
    }
    //Take the sorted array and insert the data of input array based on the count array and
    // decrease the value by 1 every time the element is inserted in sorted array

    let sortedArray = new Array(arr.length -1);
    for(let i=0; i<arr.length; i++){
        sortedArray[countArr[arr[i]]-1] = arr[i];
        --countArr[arr[i]];
    }
 return sortedArray;    
}
let arr = [2,1,3,4,5,4,6,7,6];
let range = 9;
let sortedArray = countSort(arr, range);
console.log(sortedArray);

================================================
FILE: algorithms/cycle_sort/java/cycleSort.java
================================================
// Java program to impleament cycle sort

import java.util.*;
import java.lang.*;

class GFG
{
// Function sort the array using Cycle sort
	public static void cycleSort (int arr[], int n)
	{
		// count number of memory writes
		int writes = 0;

		// traverse array elements and put it to on
		// the right place
		for (int cycle_start=0; cycle_start<=n-2; cycle_start++)
		{
			// initialize item as starting point
			int item = arr[cycle_start];

			// Find position where we put the item. We basically
			// count all smaller elements on right side of item.
			int pos = cycle_start;
			for (int i = cycle_start+1; i<n; i++)
				if (arr[i] < item)
					pos++;

			// If item is already in correct position
			if (pos == cycle_start)
				continue;

			// ignore all duplicate elements
			while (item == arr[pos])
				pos += 1;

			// put the item to it's right position
			if (pos != cycle_start)
			{
				int temp = item;
				item = arr[pos];
				arr[pos] = temp;
				writes++;
			}

			// Rotate rest of the cycle
			while (pos != cycle_start)
			{
				pos = cycle_start;

				// Find position where we put the element
				for (int i = cycle_start+1; i<n; i++)
					if (arr[i] < item)
						pos += 1;

				// ignore all duplicate elements
				while (item == arr[pos])
					pos += 1;

				// put the item to it's right position
				if (item != arr[pos])
				{
					int temp = item;
					item = arr[pos];
					arr[pos] = temp;
					writes++;
				}
			}
		}
	}

// Driver program to test above function
	public static void main(String[] args)
	{
		int arr[] = {1, 8, 3, 9, 10, 10, 2, 4 };
		int n = arr.length;
		cycleSort(arr, n) ;

		System.out.println("After sort : ");
		for (int i =0; i<n; i++)
			System.out.print(arr[i] + " ");
	}
}


================================================
FILE: algorithms/decoding/c/base64_decoder.c
================================================
// C implementation of base64 decoder for converting radix-64 representation into ASCII string format
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>


static char b64_arr[] = {
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
    'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
    'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
    'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
    'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
    'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
    'w', 'x', 'y', 'z', '0', '1', '2', '3',
    '4', '5', '6', '7', '8', '9', '+', '/'};

int val(char x){
    for (int i = 0; i < 64; ++i){
        if(x == b64_arr[i]) return i;
    }
    return -1;
}

int main() {
    char *str = "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
    int in = -1;
    int len = strlen(str);
    int outlen = (int)ceil(len/4.0)*3;
    char *result = (char *)malloc(sizeof(char)*outlen);
    for (int i = 0; i < len; i += 4) {
        int x = 0;
        if(str[i+2] != '=' && str[i+3] != '='){
            x |= (val(str[i]) << 18);
            x |= (val(str[i+1]) << 12);
            x |= (val(str[i+2]) << 6);
            x |= (val(str[i+3]));
            result[++in] = (x >> 16) & (0xFF);
            result[++in] = (x >> 8) & (0xFF);
            result[++in] = (x) & (0xFF);
        }
        else if(str[i+2] != '='){
            x |= (val(str[i]) << 18);
            x |= (val(str[i+1]) << 12);
            x |= (val(str[i+2]) << 6);
            result[++in] = (x >> 16) & (0xFF);
            result[++in] = (x >> 8) & (0xFF);
        }
        else{
            x |= (val(str[i]) << 18);
            x |= (val(str[i+1]) << 12);
            result[++in] = (x >> 16) & (0xFF);
        }
    }
    if(in < outlen) result[++in] = '\0';
    printf("%s\n", result);
    return 0;
}


================================================
FILE: algorithms/dfs/cpp/dfs.cpp
================================================


#import <vector>
#import <queue>
#import <iostream>


class Vertex {
public:
    Vertex(std::string n);

    bool visited;
    Vertex * prev; //predecessor
    int dist;
    std::string name;
    std::vector <Vertex *> neighbours;
};

Vertex::Vertex(std::string n) {
    prev = nullptr;
    dist = -1;
    name = n;
}

void VisitVertex(Vertex *v, Vertex * predecessor){
    v->prev = predecessor;
    v->visited = true;
    for (Vertex * successor : v->neighbours) {
        if (!successor->visited)
            VisitVertex(successor,v);
    }
}

void DFS(std::vector <Vertex *> graph){
    Vertex * predecessor = nullptr;
    for (Vertex * v: graph ) {
        v->visited = false;
    }
    for (Vertex * v: graph ) {
        if (!v->visited)
            VisitVertex(v, predecessor);
        predecessor = v;
    }

}

int main() {

    //testing

    Vertex v1("v1");
    Vertex v2("v2");
    Vertex v3("v3");
    Vertex v4("v4");
    v1.neighbours.emplace_back(&v2);
    v1.neighbours.emplace_back(&v3);
    v4.neighbours.emplace_back(&v3);
    v3.neighbours.emplace_back(&v4);
    v1.neighbours.emplace_back(&v4);

    std::vector <Vertex *> graph;
    graph.emplace_back(&v1);
    graph.emplace_back(&v2);
    graph.emplace_back(&v3);
    graph.emplace_back(&v4);

    DFS(graph);
    std::cout << "v1 prev: " << v1.prev <<std::endl;
    std::cout << "v2 prev: " << v2.prev->name <<std::endl;
    std::cout << "v3 prev: " << v3.prev->name <<std::endl;
    std::cout << "v4 prev: " << v4.prev->name <<std::endl;
    return 0;
}

================================================
FILE: algorithms/dfs/java/Graph.java
================================================
import java.util.*;

/**
 * Represents a directed graph using adjacency list
 */
class Graph {
    private int vertexNumber;
    private LinkedList<Integer> adj[];

    /**
     *
     * @param v number of vertex
     */
    Graph(int v) {
        vertexNumber = v;
        adj = new LinkedList[v];
        for (int i=0; i<v; ++i)
            adj[i] = new LinkedList();
    }

    /**
     * Add edge into graph
     * @param v vertex
     * @param w vertex
     */
    public void addEdge(int v, int w)  {
        adj[v].add(w);
    }

    /**
     *
     * @param v
     * @param visited
     */
    private void DFSUtil(int v, boolean visited[])  {
        visited[v] = true;
        System.out.print(v + " ");

        for (Integer n : adj[v]) {
            if (!visited[n])
                DFSUtil(n, visited);
        }
    }

    /**
     * To do DFS traversal. It uses recursive DFSUtil()
     * @param source source vertex
     */
    void DFS(int source) {
        boolean[] visited = new boolean[vertexNumber];

        DFSUtil(source, visited);
    }

    /**
     * Test
     * @param args
     */
    public static void main(String args[]) {
        Graph g = new Graph(4);

        g.addEdge(0, 1);
        g.addEdge(0, 2);
        g.addEdge(1, 2);
        g.addEdge(2, 0);
        g.addEdge(2, 3);
        g.addEdge(3, 3);

        g.DFS(2);
    }
}

================================================
FILE: algorithms/dfs/python/Dfs.py
================================================
__author__ = 'mittr'
   # Python program to print DFS traversal from a
# given given graph
from collections import defaultdict

# This class represents a directed graph using
# adjacency list representation
class Graph:

    # Constructor
    def __init__(self):

        # default dictionary to store graph
        self.graph = defaultdict(list)

    # function to add an edge to graph
    def addEdge(self,u,v):
        self.graph[u].append(v)

    # A function used by DFS
    def DFSUtil(self,v,visited):

        # Mark the current node as visited and print it
        visited[v]= True
        print (v),

        # Recur for all the vertices adjacent to this vertex
        for i in self.graph[v]:
            if visited[i] == False:
                self.DFSUtil(i, visited)


    # The function to do DFS traversal. It uses
    # recursive DFSUtil()
    def DFS(self,v):

        # Mark all the vertices as not visited
        visited = [False]*(len(self.graph))

        # Call the recursive helper function to print
        # DFS traversal
        self.DFSUtil(v,visited)


# Driver code
# Create a graph given in the above diagram
g = Graph()
g.addEdge(0, 1)
g.addEdge(0, 2)
g.addEdge(1, 2)
g.addEdge(2, 0)
g.addEdge(2, 3)
g.addEdge(3, 3)

print("Following is DFS from (starting from vertex 2)")
g.DFS(2)


================================================
FILE: algorithms/dijkstra/cpp/Dijkstras.cpp
================================================
// A C / C++ program for Dijkstra's single source shortest path algorithm.
// The program is for adjacency matrix representation of the graph

#include <stdio.h>
#include <limits.h>

// Number of vertices in the graph
#define V 9

// A utility function to find the vertex with minimum distance value, from
// the set of vertices not yet included in shortest path tree
int minDistance(int dist[], bool sptSet[])
{
// Initialize min value
int min = INT_MAX, min_index;

for (int v = 0; v < V; v++)
	if (sptSet[v] == false && dist[v] <= min)
		min = dist[v], min_index = v;

return min_index;
}

// A utility function to print the constructed distance array
int printSolution(int dist[], int n)
{
printf("Vertex Distance from Sourcen");
for (int i = 0; i < V; i++)
	printf("%d tt %dn", i, dist[i]);
}

// Funtion that implements Dijkstra's single source shortest path algorithm
// for a graph represented using adjacency matrix representation
void dijkstra(int graph[V][V], int src)
{
	int dist[V];	 // The output array. dist[i] will hold the shortest
					// distance from src to i

	bool sptSet[V]; // sptSet[i] will true if vertex i is included in shortest
					// path tree or shortest distance from src to i is finalized

	// Initialize all distances as INFINITE and stpSet[] as false
	for (int i = 0; i < V; i++)
		dist[i] = INT_MAX, sptSet[i] = false;

	// Distance of source vertex from itself is always 0
	dist[src] = 0;

	// Find shortest path for all vertices
	for (int count = 0; count < V-1; count++)
	{
	// Pick the minimum distance vertex from the set of vertices not
	// yet processed. u is always equal to src in first iteration.
	int u = minDistance(dist, sptSet);

	// Mark the picked vertex as processed
	sptSet[u] = true;

	// Update dist value of the adjacent vertices of the picked vertex.
	for (int v = 0; v < V; v++)

		// Update dist[v] only if is not in sptSet, there is an edge from
		// u to v, and total weight of path from src to v through u is
		// smaller than current value of dist[v]
		if (!sptSet[v] && graph[u][v] && dist[u] != INT_MAX
									&& dist[u]+graph[u][v] < dist[v])
			dist[v] = dist[u] + graph[u][v];
	}

	// print the constructed distance array
	printSolution(dist, V);
}

// driver program to test above function
int main()
{
/* Let us create the example graph discussed above */
int graph[V][V] = {{0, 4, 0, 0, 0, 0, 0, 8, 0},
					{4, 0, 8, 0, 0, 0, 0, 11, 0},
					{0, 8, 0, 7, 0, 4, 0, 0, 2},
					{0, 0, 7, 0, 9, 14, 0, 0, 0},
					{0, 0, 0, 9, 0, 10, 0, 0, 0},
					{0, 0, 4, 14, 10, 0, 2, 0, 0},
					{0, 0, 0, 0, 0, 2, 0, 1, 6},
					{8, 11, 0, 0, 0, 0, 1, 0, 7},
					{0, 0, 2, 0, 0, 0, 6, 7, 0}
					};

	dijkstra(graph, 0);

	return 0;
}


================================================
FILE: algorithms/dijkstra/java/ShortestPath.java
================================================
/**
 * A Java program for Dijkstra's single source shortest path algorithm.
 * The program is for adjacency matrix representation of the graph
 */
public class ShortestPath {
    private static final int vertexNumber = 9;

    private int minDistance(int dist[], Boolean sptSet[]) {
        int min = Integer.MAX_VALUE;
        int minIndex = -1;

        for (int v = 0; v < vertexNumber; v++) {
            if (!sptSet[v] && dist[v] <= min) {
                min = dist[v];
                minIndex = v;
            }
        }

        return minIndex;
    }

    private void printSolution(int dist[]) {
        System.out.println("Vertex   Distance from Source");
        for (int i = 0; i < vertexNumber; i++)
            System.out.println(i + " \t\t " + dist[i]);
    }

    /**
     * Dijkstra's single source shortest path
     *
     * @param graph The graph represented using adjacency matrix
     * @param source Source vertex
     */
    public void dijkstra(int graph[][], int source) {
        int dist[] = new int[vertexNumber];

        Boolean sptSet[] = new Boolean[vertexNumber];

        for (int i = 0; i < vertexNumber; i++) {
            dist[i] = Integer.MAX_VALUE;
            sptSet[i] = false;
        }

        dist[source] = 0;

        for (int count = 0; count < vertexNumber-1; count++) {
            int u = minDistance(dist, sptSet);

            sptSet[u] = true;

            for (int v = 0; v < vertexNumber; v++) {
                if (!sptSet[v] && graph[u][v] != 0 &&
                        dist[u] != Integer.MAX_VALUE &&
                        dist[u] + graph[u][v] < dist[v]) {
                    dist[v] = dist[u] + graph[u][v];
                }
            }
        }

        printSolution(dist);
    }

    /**
     * Usage
     * @param args
     */
    public static void main (String[] args) {
        int graph[][] = new int[][]{{0, 4, 0, 0, 0, 0, 0, 8, 0},
                {4, 0, 8, 0, 0, 0, 0, 11, 0},
                {0, 8, 0, 7, 0, 4, 0, 0, 2},
                {0, 0, 7, 0, 9, 14, 0, 0, 0},
                {0, 0, 0, 9, 0, 10, 0, 0, 0},
                {0, 0, 4, 14, 10, 0, 2, 0, 0},
                {0, 0, 0, 0, 0, 2, 0, 1, 6},
                {8, 11, 0, 0, 0, 0, 1, 0, 7},
                {0, 0, 2, 0, 0, 0, 6, 7, 0}
        };

        ShortestPath t = new ShortestPath();
        t.dijkstra(graph, 0);
    }
}

================================================
FILE: algorithms/dijkstra/python/djikstra.py
================================================
class Graph:
  def __init__(self):
    self.nodes = set()
    self.edges = defaultdict(list)
    self.distances = {}

  def add_node(self, value):
    self.nodes.add(value)

  def add_edge(self, from_node, to_node, distance):
    self.edges[from_node].append(to_node)
    self.edges[to_node].append(from_node)
    self.distances[(from_node, to_node)] = distance


def dijsktra(graph, initial):
  visited = {initial: 0}
  path = {}

  nodes = set(graph.nodes)

  while nodes: 
    min_node = None
    for node in nodes:
      if node in visited:
        if min_node is None:
          min_node = node
        elif visited[node] < visited[min_node]:
          min_node = node

    if min_node is None:
      break

    nodes.remove(min_node)
    current_weight = visited[min_node]

    for edge in graph.edges[min_node]:
      weight = current_weight + graph.distances[(min_node, edge)]
      if edge not in visited or weight < visited[edge]:
        visited[edge] = weight
        path[edge] = min_node

  return visited, path


================================================
FILE: algorithms/doomsday/java/doomsday.java
================================================
/**
 * Determines the day of the week.
 * 
 * @author Atom
 *
 */
public class Doomsday {
	
	/**
	 * Determines the day of the week using Tomohiko Sakamoto's Algorithm
	 * to calculate Day of Week based on Gregorian calendar.
	 * 
	 * @param y year
	 * @param m month
	 * @param d day
	 * @return day of the week (0 = sunday, 6 = saturday)
	 */
	public static int dow(int y, int m, int d) {
		final int[] t = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 };
		y -= (m < 3) ? 1 : 0;
	    return (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7;
	}
	
	/**
	 * Determines the day of the week using Tomohiko Sakamoto's Algorithm
	 * to calculate Day of Week based on Gregorian calendar.
	 * 
	 * @param y year
	 * @param m month
	 * @param d day
	 * @return day of the week
	 */
	public static String dowS(int y, int m, int d) {
		switch (dow(y, m, d)) {
			case 0: return "Sunday";
			case 1: return "Monday";
			case 2: return "Tuesday";
			case 3: return "Wednesday";
			case 4: return "Thursday";
			case 5: return "Friday";
			case 6: return "Saturday";
			default:
				System.out.println("Unknown dow");
		}
		return null;
	}
	
	public static void main(String[] args) {
		System.out.println(dow(1886, 5, 1) + ": " + dowS(1886, 5, 1));
		System.out.println(dow(1948, 12, 10) + ": " + dowS(1948, 12, 10));
		System.out.println(dow(2001, 1, 15) + ": " + dowS(2001, 1, 15));
		System.out.println(dow(2017, 10, 10) + ": " + dowS(2017, 10, 10));
		System.out.println(dow(2018, 1, 1) + ": " + dowS(2018, 1, 1));
		System.out.println(dow(2018, 2, 16) + ": " + dowS(2018, 2, 16));
		System.out.println(dow(2018, 5, 17) + ": " + dowS(2018, 5, 17));
	}

}


================================================
FILE: algorithms/doomsday/javascript/doomsday.js
================================================
function dayOfTheWeek(y, m, d) {
    const t = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4]
    y -= m < 3;
    return (y + Math.floor(y/4) - Math.floor(y/100) + Math.floor(y/400) + t[m-1] + d) % 7;
}

const dayMapping = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']

const tests = [
    [1886, 5, 1],
    [1948, 12, 10],
    [2001, 1, 15],
    [2017, 10, 10],
    [2018, 1, 1],
    [2018, 2, 16],
    [2018, 5, 17],
]

tests.forEach(test => console.log(test.join('/') + ': ' + dayMapping[dayOfTheWeek(...test)]))


================================================
FILE: algorithms/dynamic_programming/c/0_1_knapsack_problem.c
================================================
// A Dynamic Programming based solution for 0-1 Knapsack problem
#include<stdio.h>

// A utility function that returns maximum of two integers
int max(int a, int b) { return (a > b)? a : b; }

// Returns the maximum value that can be put in a knapsack of capacity W
int knapSack(int W, int wt[], int val[], int n)
{
   int i, w;
   int K[n+1][W+1];

   // Build table K[][] in bottom up manner
   for (i = 0; i <= n; i++)
   {
       for (w = 0; w <= W; w++)
       {
           if (i==0 || w==0)
               K[i][w] = 0;
           else if (wt[i-1] <= w)
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]);
           else
                 K[i][w] = K[i-1][w];
       }
   }

   return K[n][W];
}

int main()
{
    int val[] = {60, 100, 120};
    int wt[] = {10, 20, 30};
    int  W = 50;
    int n = sizeof(val)/sizeof(val[0]);
    printf("%d", knapSack(W, wt, val, n));
    return 0;
}


================================================
FILE: algorithms/dynamic_programming/c/Coin_change_DP.c
================================================
//Coin change problem : 
/*
Given a value N, if we want to make change for N cents, and we have infinite supply of each of S = { S1, S2, .. , Sm} valued coins, how many ways can we make the change? 
The order of coins doesn’t matter.

For example, for N = 4 and S = {1,2,3}, there are four solutions: 
{1,1,1,1},{1,1,2},{2,2},{1,3}. 
So output should be 4. 

For N = 10 and S = {2, 5, 3, 6}, there are five solutions: {2,2,2,2,2}, {2,2,3,3}, {2,2,6}, {2,3,5} and {5,5}. 
So the output should be 5.
*/


#include<stdio.h>
 
int count( int S[], int m, int n )
{
    int i, j, x, y;
 
    // We need n+1 rows as the table is consturcted in bottom up manner using 
    // the base case 0 value case (n = 0)
    int table[n+1][m];
    
    // Fill the enteries for 0 value case (n = 0)
    for (i=0; i<m; i++)
        table[0][i] = 1;
 
    // Fill rest of the table enteries in bottom up manner  
    for (i = 1; i < n+1; i++)
    {
        for (j = 0; j < m; j++)
        {
            // Count of solutions including S[j]
            x = (i-S[j] >= 0)? table[i - S[j]][j]: 0;
 
            // Count of solutions excluding S[j]
            y = (j >= 1)? table[i][j-1]: 0;
 
            // total count
            table[i][j] = x + y;
        }
    }
    return table[n][m-1];
}
 
// Driver program to test above function
int main()
{
    int arr[] = {1, 2, 3};
    int m = sizeof(arr)/sizeof(arr[0]);
    int n = 4;
    printf(" %d ", count(arr, m, n));
    return 0;
}

================================================
FILE: algorithms/dynamic_programming/c/coinChange.c
================================================
#include<stdio.h>
int count( int S[], int m, int n )
{
    // table[i] will be storing the number of solutions for
    // value i. We need n+1 rows as the table is consturcted
    // in bottom up manner using the base case (n = 0)
    int table[n+1];
 
    // Initialize all table values as 0
    memset(table, 0, sizeof(table));
 
    // Base case (If given value is 0)
    table[0] = 1;
 
    // Pick all coins one by one and update the table[] values
    // after the index greater than or equal to the value of the
    // picked coin
    for(int i=0; i<m; i++)
        for(int j=S[i]; j<=n; j++)
            table[j] += table[j-S[i]];
 
    return table[n];
}
int main()
{
    int arr[] = {1, 2, 3};
    int m = sizeof(arr)/sizeof(arr[0]);
    int n = 4;
    printf(" %d ", count(arr, m, n));
    return 0;
}

================================================
FILE: algorithms/dynamic_programming/c/count_no_of_ways_to_reach_nth_stair.c
================================================
// A C program to count number of ways to reach n't stair when
// a person can climb 1, 2, ..m stairs at a time
#include<stdio.h>

// A recursive function used by countWays
int countWaysUtil(int n, int m)
{
    int res[n];
    res[0] = 1; res[1] = 1;
    for (int i=2; i<n; i++)
    {
       res[i] = 0;
       for (int j=1; j<=m && j<=i; j++)
         res[i] += res[i-j];
    }
    return res[n-1];
}

// Returns number of ways to reach s'th stair
int countWays(int s, int m)
{
    return countWaysUtil(s+1, m);
}

// Driver program to test above functions
int main ()
{
    int s = 4, m = 2;
    printf("Nuber of ways = %d", countWays(s, m));
    return 0;
}


================================================
FILE: algorithms/dynamic_programming/c/longestIncreasingSubsequence.c
================================================
/* Dynamic Programming C/C++ implementation of LIS problem */
#include<stdio.h>
#include<stdlib.h>
 
/* lis() returns the length of the longest increasing
  subsequence in arr[] of size n */
int lis( int arr[], int n )
{
    int *lis, i, j, max = 0;
    lis = (int*) malloc ( sizeof( int ) * n );
 
    /* Initialize LIS values for all indexes */
    for (i = 0; i < n; i++ )
        lis[i] = 1;
 
    /* Compute optimized LIS values in bottom up manner */
    for (i = 1; i < n; i++ )
        for (j = 0; j < i; j++ ) 
            if ( arr[i] > arr[j] && lis[i] < lis[j] + 1)
                lis[i] = lis[j] + 1;
 
    /* Pick maximum of all LIS values */
    for (i = 0; i < n; i++ )
        if (max < lis[i])
            max = lis[i];
 
    /* Free memory to avoid memory leak */
    free(lis);
 
    return max;
}
 
/* Driver program to test above function */
int main()
{
    int arr[] = { 10, 22, 9, 33, 21, 50, 41, 60 };
    int n = sizeof(arr)/sizeof(arr[0]);
    printf("Length of lis is %dn", lis( arr, n ) );
    return 0;
}

================================================
FILE: algorithms/dynamic_programming/c/longestRepeatedSequence.c
================================================
// C++ program to find the longest repeated
// subsequence
#include <bits/stdc++.h>
using namespace std;
 
// This function mainly returns LCS(str, str)
// with a condition that same characters at
// same index are not considered.
string longestRepeatedSubSeq(string str)
{
    // THIS PART OF CODE IS SAME AS BELOW POST. 
    // IT FILLS dp[][]
    // http://www.geeksforgeeks.org/longest-repeating-subsequence/
    // OR the code mentioned above.
    int n = str.length();
    int dp[n+1][n+1];
    for (int i=0; i<=n; i++)
        for (int j=0; j<=n; j++)
            dp[i][j] = 0;
    for (int i=1; i<=n; i++)
        for (int j=1; j<=n; j++)
            if (str[i-1] == str[j-1] && i != j)
                dp[i][j] =  1 + dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
 
 
    // THIS PART OF CODE FINDS THE RESULT STRING USING DP[][]
    // Initialize result
    string res = "";
 
    // Traverse dp[][] from bottom right
    int i = n, j = n;
    while (i > 0 && j > 0)
    {
        // If this cell is same as diagonally
        // adjacent cell just above it, then 
        // same characters are present at 
        // str[i-1] and str[j-1]. Append any 
        // of them to result.
        if (dp[i][j] == dp[i-1][j-1] + 1)
        {
           res = res + str[i-1];
           i--;
           j--;
        }
 
        // Otherwise we move to the side
        // that that gave us maximum result
        else if (dp[i][j] == dp[i-1][j])
            i--;
        else
            j--;
    }
 
    // Since we traverse dp[][] from bottom,
    // we get result in reverse order.
    reverse(res.begin(), res.end());
 
    return res;
}
 
// Driver Program
int main()
{
    string str = "AABEBCDD";
    cout << longestRepeatedSubSeq(str);
    return 0;
}

================================================
FILE: algorithms/dynamic_programming/c/longest_pallindrome_sequence.c
================================================
# A Dynamic Programming based Python program for LPS problem
# Returns the length of the longest palindromic subsequence in seq
#include<stdio.h>
#include<string.h>

// A utility function to get max of two integers
int max (int x, int y) { return (x > y)? x : y; }

// Returns the length of the longest palindromic subsequence in seq
int lps(char *str)
{
   int n = strlen(str);
   int i, j, cl;
   int L[n][n];  // Create a table to store results of subproblems


   // Strings of length 1 are palindrome of lentgh 1
   for (i = 0; i < n; i++)
      L[i][i] = 1;

    // Build the table. Note that the lower diagonal values of table are
    // useless and not filled in the process. The values are filled in a
    // manner similar to Matrix Chain Multiplication DP solution (See
    // http://www.geeksforgeeks.org/archives/15553). cl is length of
    // substring
    for (cl=2; cl<=n; cl++)
    {
        for (i=0; i<n-cl+1; i++)
        {
            j = i+cl-1;
            if (str[i] == str[j] && cl == 2)
               L[i][j] = 2;
            else if (str[i] == str[j])
               L[i][j] = L[i+1][j-1] + 2;
            else
               L[i][j] = max(L[i][j-1], L[i+1][j]);
        }
    }

    return L[0][n-1];
}

/* Driver program to test above functions */
int main()
{
    char seq[] = "GEEKS FOR GEEKS";
    int n = strlen(seq);
    printf ("The lnegth of the LPS is %d", lps(seq));
    getchar();
    return 0;
}


================================================
FILE: algorithms/dynamic_programming/c/maxSumIncSequence.c
================================================
/* Dynamic Programming implementation of Maximum Sum Increasing
Subsequence (MSIS) problem */
#include<stdio.h>
 
/* maxSumIS() returns the maximum sum of increasing subsequence
    in arr[] of size n */
int maxSumIS( int arr[], int n )
{
    int i, j, max = 0;
    int msis[n];
 
    /* Initialize msis values for all indexes */
    for ( i = 0; i < n; i++ )
        msis[i] = arr[i];
 
    /* Compute maximum sum values in bottom up manner */
    for ( i = 1; i < n; i++ )
        for ( j = 0; j < i; j++ )
            if ( arr[i] > arr[j] && msis[i] < msis[j] + arr[i])
                msis[i] = msis[j] + arr[i];
 
    /* Pick maximum of all msis values */
    for ( i = 0; i < n; i++ )
        if ( max < msis[i] )
            max = msis[i];
 
    return max;
}
 
/* Driver program to test above function */
int main()
{
    int arr[] = {1, 101, 2, 3, 100, 4, 5};
    int n = sizeof(arr)/sizeof(arr[0]);
    printf("Sum of maximum sum increasing subsequence is %dn",
           maxSumIS( arr, n ) );
    return 0;
}

================================================
FILE: algorithms/dynamic_programming/c/subsetSum.c
================================================
// A recursive solution for subset sum problem
#include <stdio.h>
 
// Returns true if there is a subset of set[] with sun equal to given sum
bool isSubsetSum(int set[], int n, int sum)
{
   // Base Cases
   if (sum == 0)
     return true;
   if (n == 0 && sum != 0)
     return false;
 
   // If last element is greater than sum, then ignore it
   if (set[n-1] > sum)
     return isSubsetSum(set, n-1, sum);
 
   /* else, check if sum can be obtained by any of the following
      (a) including the last element
      (b) excluding the last element   */
   return isSubsetSum(set, n-1, sum) || 
                        isSubsetSum(set, n-1, sum-set[n-1]);
}
 
// Driver program to test above function
int main()
{
  int set[] = {3, 34, 4, 12, 5, 2};
  int sum = 9;
  int n = sizeof(set)/sizeof(set[0]);
  if (isSubsetSum(set, n, sum) == true)
     printf("Found a subset with given sum");
  else
     printf("No subset with given sum");
  return 0;
}

================================================
FILE: algorithms/dynamic_programming/cpp/kadens.cpp
================================================
// C++ program to print largest contiguous array sum
#include<iostream>
#include<climits>
using namespace std;
 
int maxSubArraySum(int a[], int size)
{
    int max_so_far = INT_MIN, max_ending_here = 0;
 
    for (int i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;
 
        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
 
/*Driver program to test maxSubArraySum*/
int main()
{
    int a[] = {-2, -3, 4, -1, -2, 1, 5, -3};
    int n = sizeof(a)/sizeof(a[0]);
    int max_sum = maxSubArraySum(a, n);
    cout << "Maximum contiguous sum is " << max_sum;
    return 0;
}

================================================
FILE: algorithms/dynamic_programming/cpp/nCr.cpp
================================================
#include<bits/stdc++.h>
using namespace std;
 
// Returns nCr % p
int nCrModp(int n, int r, int p)
{
    // The array C is going to store last row of
    // pascal triangle at the end. And last entry
    // of last row is nCr
    int C[r+1];
    memset(C, 0, sizeof(C));
 
    C[0] = 1; // Top row of Pascal Triangle
 
    // One by constructs remaining rows of Pascal
    // Triangle from top to bottom
    for (int i = 1; i <= n; i++)
    {
        // Fill entries of current row using previous
        // row values
        for (int j = min(i, r); j > 0; j--)
 
            // nCj = (n-1)Cj + (n-1)C(j-1);
            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}
 
// Driver program
int main()
{
    int n = 10, r = 2, p = 13;
    cout << "Value of nCr % p is " << nCrModp(n, r, p);
    return 0;
}

================================================
FILE: algorithms/dynamic_programming/cpp/subset_sum.cpp
================================================
#include<bits/stdc++.h>
using namespace std;
int arr[1000];
int sum=0;
int cache[100][100];
int m_diff(int idx,int sub_sum)
{
	if(cache[idx][sub_sum])
		return cache[idx][sub_sum];

	if(idx==0)
	{
		cache[0][sub_sum]=abs((sum-sub_sum)-sub_sum);
		return cache[0][sub_sum];
	}
	cache[idx][sub_sum]=min(m_diff(idx-1,sub_sum-arr[idx]),m_diff(idx-1,sub_sum));
	return cache[idx][sub_sum];
}
int main()
{
	memset(cache,0,sizeof cache);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		{
			cin>>arr[i];
			sum+=arr[i];
		}
		cout<<m_diff(n,sum)<<endl;
}

================================================
FILE: algorithms/dynamic_programming/java/MinCostPath.java
================================================
import java.util.Scanner;

public class MinCostPath {

	public static int minCostPathDP(int arr[][],int row, int column) {
		int m = row;
		int n = column;
		int storage[][] = new int[m][n];

		storage[m - 1][n - 1] = arr[m - 1][n - 1];
		// Last Row
		for (int j = n - 2; j >= 0; j--) {
			storage[m - 1][j] = storage[m - 1][j + 1] + arr[m - 1][j];
		}
		// Last Column
		for (int i = m - 2; i >= 0; i--) {
			storage[i][n - 1] = storage[i + 1][n - 1] + arr[i][n - 1];
		}

		for (int i = m - 2; i >= 0; i--) {
			for (int j = n - 2; j >= 0; j--) {
				storage[i][j] = arr[i][j]
						+ Math.min(storage[i][j + 1], Math.min(
								storage[i + 1][j + 1], storage[i + 1][j]));
			}
		}
		return storage[0][0]+arr[row][column];
	}

	public static void main(String args[]) {
		Scanner s = new Scanner(System.in);
		int rows = s.nextInt();
		int columns = s.nextInt();
		int arr[][] = new int[rows][columns];
		for (int i = 0; i < rows; i++) {
			for (int j = 0; j < columns; j++) {
				arr[i][j] = s.nextInt();
			}
		}
		int row = s.nextInt();
		int column = s.nextInt();
		System.out.println(minCostPathDP(arr,row,column));
		s.close();
	}
}



================================================
FILE: algorithms/encoding/base64_encoder.c
================================================
// C implementation of base64 encoder for converting ASCII string format into radix-64 representation.
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>


static char b64_arr[] = {
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
    'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
    'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
    'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
    'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
    'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
    'w', 'x', 'y', 'z', '0', '1', '2', '3',
    '4', '5', '6', '7', '8', '9', '+', '/'};

int main() {
    char *str = "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.";
    int in = -1;
    int len = strlen(str);
    int outlen = (int)ceil(len/3.0)*4;
    char *result = (char *)malloc(sizeof(char)*outlen);
    for (int i = 0; i < len; i += 3) {
        int x = 0;
        if(str[i+1] != '\0' && str[i+2] != '\0'){
            x |= (str[i] << 16);
            x |= (str[i+1] << 8);
            x |= (str[i+2]);
            result[++in] = b64_arr[(x >> 18) & (0x3F)];
            result[++in] = b64_arr[(x >> 12) & (0x3F)];
            result[++in] = b64_arr[(x >> 6) & (0x3F)];
            result[++in] = b64_arr[(x) & (0x3F)];
        }
        else if(str[i+1] != '\0'){
            x |= (str[i] << 16);
            x |= (str[i+1] << 8);
            result[++in] = b64_arr[(x >> 18) & (0x3F)];
            result[++in] = b64_arr[(x >> 12) & (0x3F)];
            result[++in] = b64_arr[(x >> 6) & (0x3F)];
            result[++in] = '=';
        }
        else{
            x |= (str[i] << 16);
            result[++in] = b64_arr[(x >> 18) & (0x3F)];
            result[++in] = b64_arr[(x >> 12) & (0x3F)];
            result[++in] = '=';
            result[++in] = '=';
        }
    }
    if(in < outlen) result[++in] = '\0';
    printf("%s\n", result);
    return 0;
}


================================================
FILE: algorithms/fibonacci/cpp/constexpr-fibonacci.cpp
================================================
// Computes a specific index of the Fibonacci sequence
// Can be computed at compile-time under certain conditions

constexpr unsigned int fibonacci(unsigned int index) {

    constexpr auto gr = (1 + std::sqrt(5)) / 2;

    if(index == 0) {
        return 0;
    } else if(index == 1) {
        return 1;
    }

    return static_cast<unsigned int>(
            (std::pow(gr, index) - std::pow(1 - gr, index)) / sqrt(5)
    );
}


================================================
FILE: algorithms/floyd_warshall/java/ShortestPath.java
================================================
/**
 * A Java program for Floyd Warshall All Pairs Shortest
 * Path algorithm.
 */
public class ShortestPath {
    private final static int VERTEX_NUMBER = 4;
    private final static int MAX_VALUE = 999999;

    public void floydWarshall(int graph[][]) {
        int dist[][] = new int[VERTEX_NUMBER][VERTEX_NUMBER];
        int i, j, k;

        for (i = 0; i < VERTEX_NUMBER; i++)
            for (j = 0; j < VERTEX_NUMBER; j++)
                dist[i][j] = graph[i][j];

        for (k = 0; k < VERTEX_NUMBER; k++) {
            for (i = 0; i < VERTEX_NUMBER; i++) {
                for (j = 0; j < VERTEX_NUMBER; j++) {
                    if (dist[i][k] + dist[k][j] < dist[i][j]) {
                        dist[i][j] = dist[i][k] + dist[k][j];
                    }
                }
            }
        }

        printSolution(dist);
    }

    private void printSolution(int dist[][]) {
        for (int i = 0; i < VERTEX_NUMBER; ++i) {
            for (int j = 0; j < VERTEX_NUMBER; ++j) {
                if (dist[i][j] == MAX_VALUE) {
                    System.out.print("INF ");
                } else {
                    System.out.print(dist[i][j] + "   ");
                }
            }
            System.out.println();
        }
    }

    /**
     * Test
     * @param args
     */
    public static void main (String[] args) {
        int graph[][] = {
                {0,         5,          MAX_VALUE,  10},
                {MAX_VALUE, 0,          3,          MAX_VALUE},
                {MAX_VALUE, MAX_VALUE,  0,          1},
                {MAX_VALUE, MAX_VALUE,  MAX_VALUE,  0}
        };

        ShortestPath a = new ShortestPath();

        a.floydWarshall(graph);
    }
}


================================================
FILE: algorithms/greedy_search/cpp/prims_algorithm.cpp
================================================
#include <bits/stdc++.h>
using namespace std;

int minkey(int key[], bool mstset[],int n)
{
	int min_index;
	int Min = INT_MAX;
	for(int i=0;i<n;i++)
	{
		if(mstset[i]==false and key[i]<Min)
		{	
			Min= key[i];
			min_index = i;
		}
	}
	return min_index;
}
int main()
{
	int n;
	cout<<"enter the number of vertices in the graph\n";
	cin>>n;
	int cost[n][n];
	memset(cost,0,sizeof(cost));
	int m;
	cout<<"enter the number of edges in the graph\n";
	cin>>m;
	vector<pair<int,int> > edgelist(m);
	for(int i=0;i<m;i++)
	{
		int a,b,c;
		cout<<"enter the "<<i+1<<" edge and the weight\n";
		cin>>a>>b>>c;
		edgelist[i] = make_pair(a,b);
		cost[a][b] =c;
		cost[b][a] =c;
	}
	bool mstset[n];
	pair<int,int> edge[n];
	int key[n];
	for(int i=0;i<n;i++)
	{
		key[i]= INT_MAX;
		mstset[i] = false;
	}
	key[0] =0;
	for(int i=0;i<n-1;i++)
	{
		int u = minkey(key,mstset,n);
		mstset[u] = true;
		for(int v=0;v<n;v++)
		{
			if(cost[u][v] and mstset[v]==false and cost[u][v] < key[v])
			{
				key[v] = cost[u][v];
				edge[v] = make_pair(u,v);
			}
		}
	}
	cout<<"the edges of the  minimum spanning tree are\n";
	for(int i=1;i<n;i++)
		cout<<edge[i].first<<"--"<<edge[i].second<<endl;
	for(int i=0;i<m;)
	{
		int j;
		for(j=0;j<n;j++)
		{
			if((edgelist[i].first== edge[j].first and edgelist[i].second == edge[j].second) or (edgelist[i].first== edge[j].second and edgelist[i].second == edge[j].first))
			{
				edgelist.erase(edgelist.begin()+i);
				break;
			}
		}
		if(j==n)
			++i;
	}
	 cout<<"the edges not in minimum spanning tree are \n";
	cout<<"edge"<<"  "<<endl;
	for(int i=0;i<edgelist.size();i++)
		cout<<edgelist[i].first<<"--"<<edgelist[i].second<<"\n";
	return 0;
}


================================================
FILE: algorithms/heap_sort/crystal/heap_sort.cr
================================================
def heap_sort(array)
  to_heap(array)
  bottom = array.size - 1

  while bottom > 0
    array[0], array[bottom] = array[bottom], array[0]
    sift_down(array, 0, bottom)
    bottom -= 1
  end

  array
end

def to_heap(array)
  i = (array.size/2) - 1

  while i >= 0
    sift_down(array, i, array.size)
    i -= 1
  end

  array
end

def sift_down(array, i, max)
  i_big, c1, c2 = 0, 0, 0

  while i < max
    i_big = i
    c1 = (2*i) + 1
    c2 = c1 + 1

    if c1 < max && array[c1] > array[i_big]
      i_big = c1
    end

    if c2 < max && array[c2] > array[i_big]
      i_big = c2
    end

    break if i_big == i

    array[i], array[i_big] = array[i_big], array[i]

    i = i_big
  end

  array
end

numbers = [4, 2, 8, 1, 30, 0, 10, 16]

puts "Unsorted: #{numbers}"

puts "Sorted: #{heap_sort(numbers)}"


================================================
FILE: algorithms/heap_sort/java/heap_sort.java
================================================
/*
 * Java Program to Implement Heap Sort
 */
 
import java.util.Scanner;
 
/* Class HeapSort */
public class HeapSort 
{    
    private static int N;
    /* Sort Function */
    public static void sort(int arr[])
    {       
        heapify(arr);        
        for (int i = N; i > 0; i--)
        {
            swap(arr,0, i);
            N = N-1;
            maxheap(arr, 0);
        }
    }     
    /* Function to build a heap */   
    public static void heapify(int arr[])
    {
        N = arr.length-1;
        for (int i = N/2; i >= 0; i--)
            maxheap(arr, i);        
    }
    /* Function to swap largest element in heap */        
    public static void maxheap(int arr[], int i)
    { 
        int left = 2*i ;
        int right = 2*i + 1;
        int max = i;
        if (left <= N && arr[left] > arr[i])
            max = left;
        if (right <= N && arr[right] > arr[max])        
            max = right;
 
        if (max != i)
        {
            swap(arr, i, max);
            maxheap(arr, max);
        }
    }    
    /* Function to swap two numbers in an array */
    public static void swap(int arr[], int i, int j)
    {
        int tmp = arr[i];
        arr[i] = arr[j];
        arr[j] = tmp; 
    }    
    /* Main method */
    public static void main(String[] args) 
    {
        Scanner scan = new Scanner( System.in );        
        System.out.println("Heap Sort Test\n");
        int n, i;    
        /* Accept number of elements */
        System.out.println("Enter number of integer elements");
        n = scan.nextInt();    
        /* Make array of n elements */
        int arr[] = new int[ n ];
        /* Accept elements */
        System.out.println("\nEnter "+ n +" integer elements");
        for (i = 0; i < n; i++)
            arr[i] = scan.nextInt();
        /* Call method sort */
        sort(arr);
        /* Print sorted Array */
        System.out.println("\nElements after sorting ");        
        for (i = 0; i < n; i++)
            System.out.print(arr[i]+" ");            
        System.out.println();            
    }    
}


================================================
FILE: algorithms/heap_sort/java/heapsort.java
================================================
//Java program for Heap Sort

class heapsort
{
    public void sort(int arr[])
    {
        int n = arr.length;
 
        // Build heap (rearrange array)
        for (int i = n / 2 - 1; i >= 0; i--)
            heapify(arr, n, i);
 
        // One by one extract an element from heap
        for (int i=n-1; i>=0; i--)
        {
            // Move current root to end
            int temp = arr[0];
            arr[0] = arr[i];
            arr[i] = temp;
 
            // call max heapify on the reduced heap
            heapify(arr, i, 0);
        }
    }
 
    // To heapify a subtree rooted with node i which is
    // an index in arr[]. n is size of heap
    void heapify(int arr[], int n, int i)
    {
        int largest = i;  // Initialize largest as root
        int l = 2*i + 1;  // left = 2*i + 1
        int r = 2*i + 2;  // right = 2*i + 2
 
        // If left child is larger than root
        if (l < n && arr[l] > arr[largest])
            largest = l;
 
        // If right child is larger than largest so far
        if (r < n && arr[r] > arr[largest])
            largest = r;
 
        // If largest is not root
        if (largest != i)
        {
            int swap = arr[i];
            arr[i] = arr[largest];
            arr[largest] = swap;
 
            // Recursively heapify the affected sub-tree
            heapify(arr, n, largest);
        }
    }
 
    /* A utility function to print array of size n */
    static void printArray(int arr[])
    {
        int n = arr.length;
        for (int i=0; i<n; ++i)
            System.out.print(arr[i]+" ");
        System.out.println();
    }
 
    // Driver program
    public static void main(String args[])
    {
        int arr[] = {12, 11, 13, 5, 6, 7};
        int n = arr.length;
 
        HeapSort ob = new HeapSort();
        ob.sort(arr);
 
        System.out.println("Sorted array is");
        printArray(arr);
    }
}


================================================
FILE: algorithms/heap_sort/javascript/heap_sort.js
================================================
  var array_length;
/* to create MAX  array */  
function heap_root(input, i) {
    var left = 2 * i + 1;
    var right = 2 * i + 2;
    var max = i;

    if (left < array_length && input[left] > input[max]) {
        max = left;
    }

    if (right < array_length && input[right] > input[max])     {
        max = right;
    }

    if (max != i) {
        swap(input, i, max);
        heap_root(input, max);
    }
}

function swap(input, index_A, index_B) {
    var temp = input[index_A];

    input[index_A] = input[index_B];
    input[index_B] = temp;
}

function heapSort(input) {
    
    array_length = input.length;

    for (var i = Math.floor(array_length / 2); i >= 0; i -= 1)      {
        heap_root(input, i);
      }

    for (i = input.length - 1; i > 0; i--) {
        swap(input, 0, i);
        array_length--;
      
      
        heap_root(input, 0);
    }
}

var arr = [3, 0, 2, 5, -1, 4, 1];
heapSort(arr);
console.log(arr);


================================================
FILE: algorithms/heap_sort/python/heap_sort.py
================================================
from heapq import heappush, heappop

def heap_sort(heap_iterable):
    '''
    Heap sort implementation
    '''
    heap = []
    for val in heap_iterable:
        heappush(heap, val)
    return [heappop(heap) for _ in range(len(heap))]

# Test
if __name__ == '__main__':
    test_cases = (
        [1, 3, 5, 7, 9, 2, 4, 6, 8, 0],
        [3, 15, 68, 34, 39, 85, 85, 71, 47, 84], 
        [3, 10, 68, 34, 15, 85, 85, 71, 47, 84, 39], 
        [2, 10, 3, 34, 15, 68, 85, 71, 47, 84, 39, 85],
        [1, 10, 2, 34, 15, 3, 85, 71, 47, 84, 39, 85, 68],
        range(50)
    )
    for iterable in test_cases:
        assert heap_sort(iterable) == sorted(iterable)


================================================
FILE: algorithms/histogram_equalization/java/HistogramEqualization.java
================================================
/*
* This file has been created by github user vn17.
* Feel free to use it for any purpose.
*
* This file makes extensive use of Java 8 lambdas.
*
* For more details on the algorithm,
* refer to @see <a href=https://en.wikipedia.org/wiki/Histogram_equalization>https://en.wikipedia.org/wiki/Histogram_equalization</a>
*/
package Java;

import java.util.Arrays;
import java.util.HashMap;
import java.util.stream.IntStream;

import static java.util.stream.Collectors.joining;


public class HistogramEqualization {

    public static void main(String[] args) {
        ImageMatrix imageMatrix = new ImageMatrix(new int[][]{{2, 3, 1}, {3, 4, 6}, {7, 3, 6}});
        System.out.println("Input Matrix: \n" + imageMatrix);
        System.out.println("Frequency: \t" + imageMatrix.frequency() + "\nCDF: \t\t" + imageMatrix.cdf() + "\n");
        ImageMatrix equalizedImageMatrix = imageMatrix.equalize();
        System.out.println("Histogram Equalized Matrix: \n" + equalizedImageMatrix);
    }
}

class ImageMatrix {
    private static final int NUMBER_OF_LEVELS = 8;//This is the intensity range.
    // Eg. For a 3 bit per pixel image, the intensity value is 8.

    private int cdfMin = -1;//This is the cdf of the minimum intensity value

    private int size;//Size of the image. 3 x 3 = 9 in this case

    private int[][] imageArray;//3 x 3 Array to store intensity values at each pixel

    private HashMap<Integer, Integer> frequency;//HashMap to store the frequency of each intensity value i.e.
    // the number of times each value has appeared in the 3 x 3 array.

    private HashMap<Integer, Integer> cdf;//HashMap to store the CDF of each intensity value i.e.
    // the sum of the frequency values of all intensities lesser than the current intensity level.

    public ImageMatrix(int[][] arr) {
        this.imageArray = arr;
        this.size = (int) Arrays.stream(arr).flatMapToInt(IntStream::of).count();
    }

    public int getFrequency(int key) {
        if (frequency == null) calculateFrequency();
        return frequency().get(key);
    }

    public int getCdf(int key) {
        if (cdf == null) calculateCdf();
        return cdf().get(key);
    }

    public HashMap<Integer, Integer> frequency() {
        if (frequency == null) calculateFrequency();
        return frequency;
    }

    public HashMap<Integer, Integer> cdf() {
        if (cdf == null) calculateCdf();
        return cdf;
    }

    /**
     * This method calculates the frequency of each intensity value in the given intensity range.
     */
    private void calculateFrequency() {
        this.frequency = new HashMap<>();
        Arrays.stream(imageArray)//Get the 2D array
                .flatMapToInt(IntStream::of)//Convert it to a 1D array
                .forEach(intensity -> {//Increment the frequency value for intensity by 1
                    if (frequency.containsKey(intensity)) frequency.put(intensity, frequency.get(intensity) + 1);
                    else frequency.put(intensity, 1);
                });
    }

    /**
     * This method calculates the CDF by adding all the intensity values lesser than the current value.
     */
    private void calculateCdf() {
        if (frequency == null) calculateFrequency();
        cdf = (HashMap) frequency().clone();
        cdf.keySet().stream()
                .sorted().mapToInt(Integer::intValue)
                .reduce(0, (previousSum, currentKey) -> {
                    int sum = previousSum + cdf.get(currentKey);
                    cdf.put(currentKey, sum);
                    if (cdfMin == -1)//To store the cdf of the minimum intensity value
                        cdfMin = sum;
                    return sum;
                });
    }

    /**
     * This method applies the equalization formula to each element in the matrix.
     * @return
     */
    public ImageMatrix equalize() {
        int[][] equalizedArray = Arrays.stream(imageArray)
                .map(p -> Arrays.stream(p).map(q -> (getCdf(q) - cdfMin) * (NUMBER_OF_LEVELS - 2) / (size - 1) + 1).toArray())
                .toArray(int[][]::new);
        return new ImageMatrix(equalizedArray);
    }

    /**
     * Prints a 2D array line by line for each array.
     * @return
     */
    @Override
    public String toString() {
        return Arrays.stream(imageArray).map(s -> String.format("%s\n", Arrays.toString(s))).collect(joining());
    }
}



================================================
FILE: algorithms/huffmann_algorithm/java/Huffman.java
================================================
package Lecture25;

import java.util.HashMap;
import java.util.Set;

import Lecture19.BinaryTree;
import Lecture21.Heap;

public class Huffman {
	private HashMap<Character, String> encoder;
	private HashMap<String, Character> decoder;
	

	public Huffman(String sourceString){
		// 1. prepare freq map
		HashMap<Character, Integer> freqMap = new HashMap<>();
		for(int i = 0; i < sourceString.length(); i++){
			char ch = sourceString.charAt(i);
			
			if(freqMap.containsKey(ch)){
				freqMap.put(ch, freqMap.get(ch) + 1);
			} else {
				freqMap.put(ch, 1);
			}
		}
		
		
		// 2. Prepare bt's for each key freqmap and add to a min heap
		Heap<Integer, Pair> minHeap = new Heap<>(true);
		
		Set<Character> allChars = freqMap.keySet();
		for(Character ch: allChars){
			BinaryTree bt = new BinaryTree(ch, null, null);
			Pair pair = new Pair(freqMap.get(ch), bt);
			
			minHeap.add(pair.cost, pair);
		}
		
		// 3. till the heap is empty, we pull out two, create a new and enter it back
		while(minHeap.size() != 1){
			Pair p1 = minHeap.removeHP();
			Pair p2 = minHeap.removeHP();
			
			BinaryTree bt = new BinaryTree(0, p1.bt, p2.bt);
			Pair p = new Pair(p1.cost + p2.cost, bt);
			
			minHeap.add(p.cost, p);
		}
		
		// 4. Get final tree out of heap
		Pair fp = minHeap.removeHP();
		BinaryTree ft = fp.bt;
		
		// 5. Get enc, dec filled
		this.encoder = new HashMap<>();
		this.decoder = new HashMap<>();
		
		ft.traversalForHC(encoder, decoder);
	}
	
	// input - aaaaaaaaaaaaaaaaafadsfaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbccccccccc
	// output - 11110101010101111100001101010101010101
	public String encode(String str){
		String rv = "";
		
		for(int i = 0; i < str.length(); i++){
			rv += encoder.get(str.charAt(i));
		}
		
		return rv;
	}
	
	// input - 11110101010101111100001101010101010101
	// output - aaaaaaaaaaaaaaaaafadsfaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbccccccccc
	public String decode(String str){
		String rv = "";
		
		String key = "";
		for(int i = 0; i < str.length(); i++){
			key += str.charAt(i);
			
			if(decoder.containsKey(key)){
				rv += decoder.get(key);
				key = "";
			}
		}
		
		return rv;
	}
	
	private class Pair {
		int cost;
		BinaryTree bt;
		
		Pair(int cost, BinaryTree bt){
			this.cost = cost;
			this.bt = bt;
		}
	}
}


================================================
FILE: algorithms/insertion_sort/ada/insertion_sort.adb
================================================
with Ada.Containers.Vectors;
with Ada.Numerics.Discrete_Random;
with Ada.Text_IO;
with Ada.Integer_Text_IO;

use Ada.Text_IO;
use Ada.Integer_Text_IO;

procedure Insertion_Sort is

   ------------------------------
   -- Constant, types, package --
   ------------------------------

   ARRAY_SIZE : constant Natural := 10;
   RANGE_MIN  : constant Integer := 1;
   RANGE_MAX  : constant Integer := 100;

   package P_Vectors is new Ada.Containers.Vectors (Positive, Integer);
   use P_Vectors;

   -----------------------
   --  Method prototype --
   -----------------------

   --  Initializing an array with default values
   function Init_Vector return Vector;

   procedure Put (Tab : Vector);

   procedure Swap (a : in out Integer; b : in out Integer);

   function Sort (T : Vector) return Vector;

   -----------------------------
   --  Declaration of methods --
   -----------------------------

   function Init_Vector return Vector
   is
      subtype T_Interval is Integer range RANGE_MIN .. RANGE_MAX;
      package P_Random is new Ada.numerics.discrete_random (T_Interval);
      use P_Random;

      seed : Generator;
      T    : Vector;
   begin
      Reset (seed);

      for i in 1 .. ARRAY_SIZE loop
         Append (T, Random (seed));
      end loop;

      return T;
   end Init_Vector;

   procedure Put (Tab : Vector)
   is
   begin
      for e of Tab loop
         Put (e, Width => 0);
         Put (";");
      end loop;
   end Put;

   procedure Swap (a : in out Integer; b : in out Integer)
   is
      c : constant Integer := a;
   begin
      a := b;
      b := c;
   end Swap;

   function Sort (T : Vector) return Vector is
      Tab : Vector := T;
   begin
      for i in First_Index (T) + 1 .. Last_Index (T) loop
         for j in reverse First_Index (T) + 1 .. i loop
            exit when Tab (j - 1) <= Tab (j);
            Swap (Tab (j - 1), Tab (j));
         end loop;
      end loop;
      return Tab;
   end Sort;

   ---------------
   -- Variables --
   ---------------

   T : Vector := Init_Vector;
begin
   Put ("Array        : ");
   Put (T);
   New_Line;

   T := Sort (T);

   Put ("Sorted array : ");
   Put (T);
end Insertion_Sort;


================================================
FILE: algorithms/insertion_sort/c/InsertionSort.c
================================================
// C program for insertion sort
#include <stdio.h> 
/* Function to sort an array using insertion sort */
void insertionSort(int ar[], int n)
{
   int i, key, j;
   for (i = 1; i < n; i++)
   {
       key = ar[i];
       j = i-1;
       /* Move elements with indices from 0 to i-1 that are greater 
       than key, to one position ahead of their current position */
       while (j >= 0 && ar[j] > key)
       {
           ar[j+1] = ar[j];
           j = j-1;
       }
       ar[j+1] = key;
   }
}
// method to print array
void print(int ar[], int n)
{
   for (int  i=0; i < n; i++){
       printf("%d ", ar[i]);
   }
}
/* To test insertion sort function */
int main()
{
    int arr[] = {10, 29, 1, 9, 37, 24, 6, 3, 11};
    // Calculates array size
    int n = sizeof(arr) / sizeof(arr[0]);
    insertionSort(arr, n);
    print(arr, n);
    return 0;
}


================================================
FILE: algorithms/insertion_sort/cpp/insertion_sort.cpp
================================================
//
// Created by radligna on 05.10.17.
//


// C++ program for insertion sort

//needed to print the sorted array
#include <iostream>

/* Function to sort an array using insertion sort */
void insertionSort( int tab[], int arraySize ) {
    int temp, iter2;
    for( int iter1 = 1; iter1 < arraySize; iter1++ ) {
        temp = tab[iter1];
        for( iter2 = iter1 - 1; iter2 >= 0 and tab[iter2] > temp; iter2-- )
            tab[ iter2 + 1 ] = tab[ iter2 ];
        tab[ iter2 + 1 ] = temp;
    }
}
// method to print array
void printArray(int arr[], int arraySize) {
    for (int  i=0; i < arraySize; i++)
        std::cout<<arr[i]<<" ";
}
/* To test insertion sort function */
int main() {
    int arr[] = {10, 29, 1, 9, 37, 24, 6, 3, 11};
    int arraySize = (sizeof(arr)/sizeof(*arr));
    insertionSort(arr, arraySize);
    printArray(arr, arraySize);
    return 0;
}

================================================
FILE: algorithms/insertion_sort/crystal/insertion_sort.cr
================================================
def insertion_sort(array)
  x = 1
  loop do
    i = x

    while i > 0 && array[i-1] > array[i]
      array[i], array[i - 1] = array[i - 1], array[i]
      i -= 1
    end

    x += 1
    break if x == array.size
  end

  array
end

numbers = [4, 2, 8, 1, 30, 0, 10, 16]

puts "Unsorted: #{numbers}"

puts "Sorted: #{insertion_sort(numbers)}"


================================================
FILE: algorithms/insertion_sort/java/InsertionSort.java
================================================
class InsertionSort {

    /*
    This class sorts an array using insertion sort
     */

    public static int[] insertionSort(int[] array) {
        int key,
                previousIndex;

        for (int index = 1; index < array.length; index++) {
            key = array[index];
            previousIndex = index - 1;

            while(previousIndex >= 0 && array[previousIndex] > key){
                array[previousIndex + 1] = array[previousIndex];
                previousIndex -= 1;
                array[previousIndex + 1] = key;
            }
        }
        return array;
    }

    public static void main(String[] args) {
        int[] array = new int[10];


        for (int i = 10; i > 0 ; i--) {
            array[10 - i] = i;
        }

        int[] sortedArray = insertionSort(array);

        for (int i: sortedArray) {
            System.out.print(i + " ");
        }
    }
}


================================================
FILE: algorithms/insertion_sort/javascript/insertionSort.js
================================================
function insertionSort(array) {
  for (let i = 0; i < array.length; i++) 
Download .txt
gitextract_z9vtg38d/

├── .gitignore
├── .vscode/
│   └── settings.json
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── algorithms/
│   ├── EuclideanAlgorithm/
│   │   ├── c/
│   │   │   └── euclid.c
│   │   └── python/
│   │       └── euclideanAlgorithm.py
│   ├── Graph/
│   │   └── connected_components_in_undirected_graph/
│   │       └── python/
│   │           └── ConnectedComponents.py
│   ├── a_search/
│   │   └── cpp/
│   │       └── a_star.cpp
│   ├── backtracking/
│   │   └── c/
│   │       ├── n_queens_problem.c
│   │       ├── rat_in_a_maze_problem.c
│   │       ├── sudoku_problem.c
│   │       └── the_knight_tour_problem.c
│   ├── bellman_ford/
│   │   ├── cpp/
│   │   │   └── bellman_ford.cpp
│   │   └── java/
│   │       └── BellmanFord.java
│   ├── bfs/
│   │   ├── cpp/
│   │   │   └── bfs.cpp
│   │   └── java/
│   │       └── Graph.java
│   ├── binary_search/
│   │   ├── PHP/
│   │   │   └── binarysearch.php
│   │   ├── binary_search.md
│   │   ├── c/
│   │   │   └── binary_search.c
│   │   ├── cpp/
│   │   │   └── binary_search.cpp
│   │   ├── java/
│   │   │   └── binarysearch.java
│   │   ├── javascript/
│   │   │   └── binary_search.js
│   │   ├── python/
│   │   │   └── binary_search.py
│   │   └── ruby/
│   │       └── binary_search.rb
│   ├── bipartite_check/
│   │   └── cpp/
│   │       └── bipartite.cpp
│   ├── bitwise/
│   │   ├── cpp/
│   │   │   └── generating_subsets.cpp
│   │   └── java/
│   │       ├── AddTwoNumbersWithoutPlusOperator.java
│   │       ├── BinaryPalidrome.java
│   │       ├── NegateANumberWithoutPlusOperator.java
│   │       ├── Optimized_permutation
│   │       └── Subsets.java
│   ├── bogo_sort/
│   │   ├── java/
│   │   │   └── BogoSort.java
│   │   ├── python/
│   │   │   └── bogo.py
│   │   └── ruby/
│   │       └── bogo_sort.rb
│   ├── breadth_first_search/
│   │   └── cpp/
│   │       └── bfs.cpp
│   ├── bubble_sort/
│   │   ├── README.md
│   │   ├── assembly_mips/
│   │   │   └── bubble_sort.asm
│   │   ├── bash/
│   │   │   └── bubblesort.sh
│   │   ├── c/
│   │   │   └── bubble_sort.c
│   │   ├── cpp/
│   │   │   ├── bubble_sort_1.cpp
│   │   │   └── bubblesort.cpp
│   │   ├── crystal/
│   │   │   └── bubble_sort.cr
│   │   ├── csharp/
│   │   │   └── BubbleSort.cs
│   │   ├── elixir/
│   │   │   ├── README.md
│   │   │   └── bubblesort.ex
│   │   ├── go/
│   │   │   └── bubble-sort-algorithm.go
│   │   ├── haskell/
│   │   │   └── bubble_sort.hs
│   │   ├── java/
│   │   │   ├── BubbleSortExample.java
│   │   │   └── GenericBubbleSort.java
│   │   ├── javascript/
│   │   │   ├── bubble-sort.js
│   │   │   ├── bubbleSort.js
│   │   │   └── main_bs.js
│   │   ├── kotlin/
│   │   │   └── bubblesort.kt
│   │   ├── objetive-c/
│   │   │   └── BubbleSort.m
│   │   ├── perl/
│   │   │   └── BubbleSort.pl
│   │   ├── power_shell/
│   │   │   └── bubble_sort.ps1
│   │   ├── python/
│   │   │   └── bubble_sort.py
│   │   ├── ruby/
│   │   │   └── bubble_sort.rb
│   │   ├── swift/
│   │   │   └── bubble_sort.swift
│   │   └── vb/
│   │       └── bubble_sort.bas
│   ├── bucket_sort/
│   │   ├── bucket_sort.cpp
│   │   ├── bucket_sort.java
│   │   ├── bucket_sort.py
│   │   └── c/
│   │       └── bucket_sort.c
│   ├── caesar_cipher/
│   │   ├── java/
│   │   │   └── caesar.java
│   │   └── javascript/
│   │       └── caesarCipher.js
│   ├── check_pallindrome_number/
│   │   ├── c/
│   │   │   └── checkPalindrome.c
│   │   └── cpp/
│   │       └── checkPall.cpp
│   ├── closest/
│   │   └── java/
│   │       └── Closest.java
│   ├── count_sort/
│   │   └── javascript/
│   │       └── count_sort.js
│   ├── cycle_sort/
│   │   └── java/
│   │       └── cycleSort.java
│   ├── decoding/
│   │   └── c/
│   │       └── base64_decoder.c
│   ├── dfs/
│   │   ├── cpp/
│   │   │   └── dfs.cpp
│   │   ├── java/
│   │   │   └── Graph.java
│   │   └── python/
│   │       └── Dfs.py
│   ├── dijkstra/
│   │   ├── cpp/
│   │   │   └── Dijkstras.cpp
│   │   ├── java/
│   │   │   └── ShortestPath.java
│   │   └── python/
│   │       └── djikstra.py
│   ├── doomsday/
│   │   ├── java/
│   │   │   └── doomsday.java
│   │   └── javascript/
│   │       └── doomsday.js
│   ├── dynamic_programming/
│   │   ├── c/
│   │   │   ├── 0_1_knapsack_problem.c
│   │   │   ├── Coin_change_DP.c
│   │   │   ├── coinChange.c
│   │   │   ├── count_no_of_ways_to_reach_nth_stair.c
│   │   │   ├── longestIncreasingSubsequence.c
│   │   │   ├── longestRepeatedSequence.c
│   │   │   ├── longest_pallindrome_sequence.c
│   │   │   ├── maxSumIncSequence.c
│   │   │   └── subsetSum.c
│   │   ├── cpp/
│   │   │   ├── kadens.cpp
│   │   │   ├── nCr.cpp
│   │   │   └── subset_sum.cpp
│   │   └── java/
│   │       └── MinCostPath.java
│   ├── encoding/
│   │   └── base64_encoder.c
│   ├── fibonacci/
│   │   └── cpp/
│   │       └── constexpr-fibonacci.cpp
│   ├── floyd_warshall/
│   │   └── java/
│   │       └── ShortestPath.java
│   ├── greedy_search/
│   │   └── cpp/
│   │       └── prims_algorithm.cpp
│   ├── heap_sort/
│   │   ├── crystal/
│   │   │   └── heap_sort.cr
│   │   ├── java/
│   │   │   ├── heap_sort.java
│   │   │   └── heapsort.java
│   │   ├── javascript/
│   │   │   └── heap_sort.js
│   │   └── python/
│   │       └── heap_sort.py
│   ├── histogram_equalization/
│   │   └── java/
│   │       └── HistogramEqualization.java
│   ├── huffmann_algorithm/
│   │   └── java/
│   │       └── Huffman.java
│   ├── insertion_sort/
│   │   ├── ada/
│   │   │   └── insertion_sort.adb
│   │   ├── c/
│   │   │   └── InsertionSort.c
│   │   ├── cpp/
│   │   │   └── insertion_sort.cpp
│   │   ├── crystal/
│   │   │   └── insertion_sort.cr
│   │   ├── java/
│   │   │   └── InsertionSort.java
│   │   ├── javascript/
│   │   │   ├── insertionSort.js
│   │   │   └── insertion_sort.js
│   │   ├── python/
│   │   │   └── insertionsort.py3
│   │   └── ruby/
│   │       └── insertion_sort.rb
│   ├── inversion_count/
│   │   └── cpp/
│   │       └── inversion_count.cpp
│   ├── jarvis/
│   │   └── cpp/
│   │       └── jarvis.cpp
│   ├── johnson_algorithm/
│   │   └── cpp/
│   │       └── johnson_algorithm.cpp
│   ├── kmp_search/
│   │   ├── cpp/
│   │   │   └── KMPSearch.cpp
│   │   ├── java/
│   │   │   └── KMPSearch.java
│   │   └── python/
│   │       └── KMPSearch.py
│   ├── linear_search/
│   │   ├── c/
│   │   │   └── linearsearch.C
│   │   ├── cpp/
│   │   │   └── linearSearch.cpp
│   │   ├── java/
│   │   │   └── LinearSearch.java
│   │   ├── javascript/
│   │   │   └── linear_search.js
│   │   └── python/
│   │       └── linear_search.py
│   ├── longest_common_subsequence/
│   │   ├── cpp/
│   │   │   └── LongestCommonSubsequence.cpp
│   │   ├── javaj/
│   │   │   └── LCS.java
│   │   ├── javascript/
│   │   │   └── longest_common_subsequence.js
│   │   └── python/
│   │       └── LCS.py
│   ├── longest_common_substring/
│   │   └── java/
│   │       └── LongestCommonSubString.java
│   ├── matrix_chain_multiplication/
│   │   ├── cpp/
│   │   │   └── MCM.cpp
│   │   ├── java/
│   │   │   └── MCM.java
│   │   └── python/
│   │       └── MCM.py
│   ├── merge_sort/
│   │   ├── c#/
│   │   │   └── MergeSort.cs
│   │   ├── cpp/
│   │   │   └── merge_sort.cpp
│   │   ├── haskell/
│   │   │   └── merge_sort.hs
│   │   ├── java/
│   │   │   └── merge_sort.java
│   │   ├── javascript/
│   │   │   └── MergeSort.js
│   │   ├── python/
│   │   │   └── merge_sort.py
│   │   └── ruby/
│   │       └── merge_sort.rb
│   ├── minimum_spanning_tree/
│   │   └── cpp/
│   │       └── MST.cpp
│   ├── optimal_binary_search_tree/
│   │   └── java/
│   │       └── OptimalBst.java
│   ├── parse_tree/
│   │   └── python/
│   │       └── parse_tree.py
│   ├── permutations/
│   │   ├── java/
│   │   │   └── Permutation.java
│   │   └── javascript/
│   │       └── permutations.js
│   ├── quick_sort/
│   │   ├── ada/
│   │   │   └── quick_sort.adb
│   │   ├── c/
│   │   │   └── quick_sort.c
│   │   ├── cpp/
│   │   │   └── quickSort.cpp
│   │   ├── csharp/
│   │   │   ├── QuickSort.cs
│   │   │   └── quicksort.cs
│   │   ├── haskell/
│   │   │   └── quicksort.hs
│   │   ├── java/
│   │   │   └── QuickSort.java
│   │   ├── javascript/
│   │   │   └── quick_sort.js
│   │   ├── kotlin/
│   │   │   └── quicksort.kt
│   │   ├── python/
│   │   │   └── quicksort.py
│   │   └── ruby/
│   │       └── quick_sort.rb
│   ├── rabin_karp/
│   │   └── java/
│   │       └── RabinKarp.java
│   ├── radixsort/
│   │   ├── c++/
│   │   │   └── radixsort.cpp
│   │   └── python/
│   │       └── lsd_radixsort.py
│   ├── selection_sort/
│   │   ├── c/
│   │   │   └── SelectionSort.c
│   │   ├── crystal/
│   │   │   └── selection_sort.cr
│   │   ├── java/
│   │   │   └── SelectionSort.java
│   │   ├── javascript/
│   │   │   └── selection_sort.js
│   │   ├── python/
│   │   │   └── selection_sort.py
│   │   └── ruby/
│   │       └── selection_sort.rb
│   ├── shell_sort/
│   │   ├── C/
│   │   │   └── ShellSort.c
│   │   ├── C++/
│   │   │   └── ShellSort.cpp
│   │   ├── Java/
│   │   │   └── ShellSort.java
│   │   └── python/
│   │       └── shellsort.py
│   ├── sieve_of_eratosthenes/
│   │   ├── cpp/
│   │   │   └── sieve_of_eratosthenes.cpp
│   │   ├── java/
│   │   │   └── sieve.java
│   │   ├── javascript/
│   │   │   └── sieve.js
│   │   └── python/
│   │       └── sieve.py
│   ├── sort/
│   │   └── heap_sort/
│   │       └── java/
│   │           └── heap_sort.java
│   ├── strings/
│   │   └── cpp/
│   │       └── anagrams.cpp
│   └── tower_of_hanoi/
│       ├── cpp/
│       │   └── tower_of_hanoi.cpp
│       ├── java/
│       │   └── towers_of_hanoi.java
│       ├── javascript/
│       │   └── tower_of_hanoi.js
│       ├── php/
│       │   └── towers_of_hanoi.php
│       └── python/
│           └── tower_of_hanoi.py
├── data_structures/
│   ├── arraylist/
│   │   └── java/
│   │       └── arraylist.java
│   ├── avl_tree/
│   │   ├── java/
│   │   │   └── AVL.java
│   │   └── javascript/
│   │       └── avl.js
│   ├── bag/
│   │   └── java/
│   │       └── Bag.java
│   ├── binary_search_tree/
│   │   ├── binary_search_tree.md
│   │   ├── c/
│   │   │   └── BSTtraversal.c
│   │   ├── cpp/
│   │   │   └── BST.h
│   │   ├── java/
│   │   │   ├── binary_search_tree.java
│   │   │   └── bst_operations/
│   │   │       ├── CheckBST.java
│   │   │       ├── CorrectBST.java
│   │   │       ├── FindAncestor.java
│   │   │       ├── InorderSuccessor.java
│   │   │       ├── LargestBST.java
│   │   │       ├── LevelOrder.java
│   │   │       ├── MorrisTraversal.java
│   │   │       ├── Node.java
│   │   │       └── PathFromRootToNode.java
│   │   ├── javascript/
│   │   │   ├── binary_tree.js
│   │   │   ├── binary_tree_search.js
│   │   │   ├── breadth_first_search.js
│   │   │   └── depth_first_search.js
│   │   └── python/
│   │       ├── bst.py
│   │       ├── bst1.py
│   │       └── bst2.py
│   ├── binary_tree/
│   │   ├── c/
│   │   │   └── diameterBT.c
│   │   ├── cpp/
│   │   │   ├── binary_tree.cpp
│   │   │   └── boundaryTraversal.cpp
│   │   ├── csharp/
│   │   │   └── BinaryTree.cs
│   │   ├── java/
│   │   │   ├── binary_tree_bfs.java
│   │   │   └── binary_tree_dfs.java
│   │   └── python/
│   │       └── binary_tree.py
│   ├── bloom_filter/
│   │   └── python/
│   │       └── bloom_filter.py
│   ├── circular_queue/
│   │   ├── circular_queue.md
│   │   ├── cpp/
│   │   │   └── circular queue.cpp
│   │   ├── java/
│   │   │   └── circular_queue.java
│   │   └── python/
│   │       └── circular_queue.py
│   ├── d_heap/
│   │   └── c/
│   │       └── d_heap.c
│   ├── dimaeter_of_a_tree/
│   │   ├── cpp/
│   │   │   └── Diameter.cpp
│   │   ├── diameter_of_a_tree.md
│   │   └── java/
│   │       └── Diameter.java
│   ├── double_linked_list/
│   │   └── cpp/
│   │       └── doublelinkedlist.cpp
│   ├── doubly_linked_list/
│   │   ├── java/
│   │   │   └── DoublyLinkedList.java
│   │   └── python/
│   │       └── DoublyLinkedList.py
│   ├── generic_tree/
│   │   └── java/
│   │       └── gt.java
│   ├── graph/
│   │   ├── cpp/
│   │   │   └── graph.cpp
│   │   └── python/
│   │       └── graph.py
│   ├── hash_table/
│   │   ├── cpp/
│   │   │   └── hashtable.h
│   │   ├── csharp/
│   │   │   └── hash_table.cs
│   │   ├── java/
│   │   │   └── Hash_table.java
│   │   └── python/
│   │       └── hashTable.py
│   ├── hashmap/
│   │   └── java/
│   │       └── hashmap.java
│   ├── hashset/
│   │   └── java/
│   │       └── hashset.java
│   ├── heap/
│   │   ├── cpp/
│   │   │   └── MinHeap.h
│   │   ├── java/
│   │   │   ├── Heap.java
│   │   │   └── heaps.java
│   │   ├── python/
│   │   │   └── minheap.py
│   │   └── ruby/
│   │       └── heap.rb
│   ├── heapify_insert_extract_min/
│   │   └── cpp/
│   │       └── max-heap_functions.cpp
│   ├── left_learning_red_black_tree/
│   │   ├── c/
│   │   │   └── llrb_tree.c
│   │   └── java/
│   │       └── left_leaning_red_black_tree.java
│   ├── linked_list/
│   │   ├── c/
│   │   │   └── linked_list.c
│   │   ├── cpp/
│   │   │   ├── LinkedList.cpp
│   │   │   └── singly_linked_list.cpp
│   │   ├── csharp/
│   │   │   └── LinkedList.cs
│   │   ├── go/
│   │   │   └── linked_list.go
│   │   ├── java/
│   │   │   ├── LinkedList.java
│   │   │   ├── LinkedListLinkedList.java
│   │   │   └── LinkedListTest.java
│   │   ├── kotlin/
│   │   │   └── LinkedList.kt
│   │   ├── linked_list.md
│   │   ├── python/
│   │   │   └── linked_list.py
│   │   └── ruby/
│   │       └── linked_list.rb
│   ├── linked_list_queue/
│   │   └── cpp/
│   │       └── queue_linked_list.cpp
│   ├── min_heap/
│   │   └── cpp/
│   │       ├── impl_minHeap.cpp
│   │       ├── minHeap.cpp
│   │       └── minHeap.hpp
│   ├── mirror_of_a_tree.java/
│   │   └── java/
│   │       └── Mirror.java
│   ├── mirrot_of_a_tree.cpp/
│   │   └── mirror.cpp
│   ├── mst/
│   │   ├── cpp/
│   │   │   └── mst.cpp
│   │   └── java/
│   │       └── prims.java
│   ├── priority_queue/
│   │   └── c/
│   │       └── priority_queue.cpp
│   ├── queue/
│   │   ├── c/
│   │   │   └── queue.c
│   │   ├── cpp/
│   │   │   ├── Queue.cpp
│   │   │   └── Queue.h
│   │   ├── csharp/
│   │   │   └── Queue.cs
│   │   ├── go/
│   │   │   └── queue.go
│   │   ├── java/
│   │   │   └── IterableQueue.java
│   │   ├── javascript/
│   │   │   ├── queue_ES5.js
│   │   │   └── queue_ES6.js
│   │   ├── kotlin/
│   │   │   └── IterableQueue.kt
│   │   ├── php/
│   │   │   └── queue.php
│   │   ├── python/
│   │   │   └── queue_two_stacks.py
│   │   └── ruby/
│   │       └── queue.rb
│   ├── simple_queue/
│   │   ├── java/
│   │   │   ├── QueueImplementation.java
│   │   │   ├── arrayQueue.java
│   │   │   └── queue.java
│   │   ├── python/
│   │   │   └── queue.py
│   │   └── simple_queue.md
│   ├── stack/
│   │   ├── c/
│   │   │   └── stack1.c
│   │   ├── c#/
│   │   │   ├── main.cs
│   │   │   └── stack.cs
│   │   ├── cpp/
│   │   │   ├── celement.h
│   │   │   ├── cstack.cpp
│   │   │   ├── cstack.h
│   │   │   ├── cstack.test.cpp
│   │   │   ├── stack_balanced_paranthesis.cpp
│   │   │   ├── templated_stack.cpp
│   │   │   └── templated_stack.hpp
│   │   ├── crystal/
│   │   │   └── stack.cr
│   │   ├── csharp/
│   │   │   └── Stack.cs
│   │   ├── go/
│   │   │   └── stack.go
│   │   ├── java/
│   │   │   ├── Node.java
│   │   │   ├── Stack.java
│   │   │   └── integer_stack.java
│   │   ├── javascript/
│   │   │   ├── stack.js
│   │   │   └── usingstack.js
│   │   ├── lisp/
│   │   │   ├── Stack.bak
│   │   │   └── Stack.rkt
│   │   ├── php/
│   │   │   └── stack.php
│   │   ├── python/
│   │   │   └── stack.py
│   │   └── ruby/
│   │       └── stack.rb
│   ├── treemap/
│   │   └── java/
│   │       └── treemap.java
│   ├── treeset/
│   │   └── java/
│   │       └── treeset.java
│   ├── trie/
│   │   ├── Trie.md
│   │   ├── java/
│   │   │   └── Trie.java
│   │   └── javascript/
│   │       └── Trie.js
│   └── union_find/
│       ├── cpp/
│       │   └── UnionFind.cpp
│       ├── java/
│       │   └── UnionFind.java
│       ├── python/
│       │   └── UnionFind.py
│       └── union_find.md
├── design_patterns/
│   └── behavioral/
│       └── javascript/
│           ├── mediator-example.js
│           └── mediator.js
└── package.json
Download .txt
SYMBOL INDEX (1293 symbols across 261 files)

FILE: algorithms/EuclideanAlgorithm/c/euclid.c
  function gcd (line 3) | int gcd(int x, int y){
  function main (line 9) | void main(){

FILE: algorithms/EuclideanAlgorithm/python/euclideanAlgorithm.py
  function euclidean (line 1) | def euclidean(a,b):#for natural numbers a,b

FILE: algorithms/Graph/connected_components_in_undirected_graph/python/ConnectedComponents.py
  function countComponents (line 9) | def countComponents( n, edges):

FILE: algorithms/a_search/cpp/a_star.cpp
  type cell (line 15) | struct cell
  function isValid (line 26) | bool isValid(int row, int col)
  function isUnBlocked (line 36) | bool isUnBlocked(int grid[][COL], int row, int col)
  function isDestination (line 47) | bool isDestination(int row, int col, Pair dest)
  function calculateHValue (line 56) | double calculateHValue(int row, int col, Pair dest)
  function tracePath (line 65) | void tracePath(cell cellDetails[][COL], Pair dest)
  function aStarSearch (line 97) | void aStarSearch(int grid[][COL], Pair src, Pair dest)
  function main (line 636) | int main()

FILE: algorithms/backtracking/c/n_queens_problem.c
  function printSolution (line 7) | void printSolution(int board[N][N])
  function isSafe (line 23) | bool isSafe(int board[N][N], int row, int col)
  function solveNQUtil (line 47) | bool solveNQUtil(int board[N][N], int col)
  function solveNQ (line 89) | bool solveNQ()
  function main (line 108) | int main()

FILE: algorithms/backtracking/c/rat_in_a_maze_problem.c
  function printSolution (line 11) | void printSolution(int sol[N][N])
  function isSafe (line 22) | bool isSafe(int maze[N][N], int x, int y)
  function solveMaze (line 36) | bool solveMaze(int maze[N][N])
  function solveMazeUtil (line 55) | bool solveMazeUtil(int maze[N][N], int x, int y, int sol[N][N])
  function main (line 89) | int main()

FILE: algorithms/backtracking/c/sudoku_problem.c
  function SolveSudoku (line 19) | bool SolveSudoku(int grid[N][N])
  function FindUnassignedLocation (line 51) | bool FindUnassignedLocation(int grid[N][N], int &row, int &col)
  function UsedInRow (line 62) | bool UsedInRow(int grid[N][N], int row, int num)
  function UsedInCol (line 72) | bool UsedInCol(int grid[N][N], int col, int num)
  function UsedInBox (line 82) | bool UsedInBox(int grid[N][N], int boxStartRow, int boxStartCol, int num)
  function isSafe (line 93) | bool isSafe(int grid[N][N], int row, int col, int num)
  function printGrid (line 103) | void printGrid(int grid[N][N])
  function main (line 114) | int main()

FILE: algorithms/backtracking/c/the_knight_tour_problem.c
  function isSafe (line 10) | bool isSafe(int x, int y, int sol[N][N])
  function printSolution (line 17) | void printSolution(int sol[N][N])
  function solveKT (line 34) | bool solveKT()
  function solveKTUtil (line 67) | int solveKTUtil(int x, int y, int movei, int sol[N][N],
  function main (line 94) | int main()

FILE: algorithms/bellman_ford/cpp/bellman_ford.cpp
  function main (line 13) | int main()

FILE: algorithms/bellman_ford/java/BellmanFord.java
  class Graph (line 3) | class Graph
    class Edge (line 5) | private class Edge {
      method Edge (line 7) | private Edge(int src, int dest, int weight) {
    method Graph (line 16) | public Graph(int v)
    method bellmanFord (line 22) | public void bellmanFord(int src) {
    method printArr (line 61) | private void printArr(int dist[], int V)
    method addEdge (line 68) | public boolean addEdge(int src, int dest, int weight) {
    method main (line 78) | public static void main(String[] args)

FILE: algorithms/bfs/cpp/bfs.cpp
  class Vertex (line 6) | class Vertex {
  class Queue (line 24) | class Queue{
    method Queue (line 26) | Queue(Vertex *first){
    method Enqueue (line 31) | void Enqueue(Vertex *pred_, Vertex * cur) {
    method Vertex (line 41) | Vertex * Dequeue(){
    method isEmpty (line 47) | bool isEmpty(){
    method isInQueue (line 51) | bool isInQueue(Vertex v){
  function BFS (line 66) | void BFS(Vertex *root) {
  function main (line 85) | int main() {

FILE: algorithms/bfs/java/Graph.java
  class Graph (line 6) | public class Graph {
    method Graph (line 14) | public Graph(int v) {
    method addEdge (line 26) | public void addEdge(int v, int w)  {
    method BFS (line 34) | public void BFS(int source) {
    method main (line 59) | public static void main(String args[]) {

FILE: algorithms/binary_search/PHP/binarysearch.php
  function binary_search (line 7) | function binary_search( $sourceArr, $keyword )

FILE: algorithms/binary_search/c/binary_search.c
  function binarySearch (line 3) | int binarySearch(int arr[], int l, int r, int key) {
  function main (line 20) | int main(void) {

FILE: algorithms/binary_search/cpp/binary_search.cpp
  function binarySearchIterative (line 5) | bool binarySearchIterative(int list[], int first, int end, int item){
  function binarySearchRecursive (line 23) | bool binarySearchRecursive(int list[], int first, int end, int item){
  function main (line 41) | int main(int argc, char const *argv[]){

FILE: algorithms/binary_search/java/binarysearch.java
  class BinarySearch (line 2) | class BinarySearch
    method binarySearch (line 5) | int binarySearch(int ar[], int l, int r, int x){
    method main (line 27) | public static void main(String args[])

FILE: algorithms/binary_search/javascript/binary_search.js
  function binarySearch (line 1) | function binarySearch(ar, el, compare_fn) {

FILE: algorithms/binary_search/python/binary_search.py
  function b_search (line 3) | def b_search(a,s,start,end):

FILE: algorithms/binary_search/ruby/binary_search.rb
  function binary_search (line 1) | def binary_search(an_array, item)

FILE: algorithms/bipartite_check/cpp/bipartite.cpp
  function bipartite (line 6) | bool bipartite(int src)
  function main (line 30) | int main()

FILE: algorithms/bitwise/cpp/generating_subsets.cpp
  function main (line 8) | int main(void)

FILE: algorithms/bitwise/java/AddTwoNumbersWithoutPlusOperator.java
  class AddTwoNumbersWithoutPlusOperator (line 2) | public class AddTwoNumbersWithoutPlusOperator {
    method main (line 3) | public static void main(String[] args) {
    method add (line 9) | private static void add(int a, int b) {

FILE: algorithms/bitwise/java/BinaryPalidrome.java
  class BinaryPalidrome (line 1) | public class BinaryPalidrome {
    method main (line 3) | public static void main(String[] args) {
    method isPalidrome (line 12) | private boolean isPalidrome(int n) {
    method kthBit (line 25) | private int kthBit(int n, int kthBit) {
    method getTotalBits (line 29) | private int getTotalBits(int n) {

FILE: algorithms/bitwise/java/NegateANumberWithoutPlusOperator.java
  class NegateANumberWithoutPlusOperator (line 1) | public class NegateANumberWithoutPlusOperator {
    method main (line 2) | public static void main(String[] args) {
    method negate (line 8) | private int negate(int n) {
    method add (line 12) | private int add(int a, int b) {

FILE: algorithms/bitwise/java/Subsets.java
  class Subsets (line 7) | public class Subsets {
    method main (line 8) | public static void main(String[] args) {
    method printSubsets (line 14) | private void printSubsets(char[] set) {

FILE: algorithms/bogo_sort/java/BogoSort.java
  class BogoSort (line 5) | public class BogoSort {
    method bogoSort (line 7) | public static List<Integer> bogoSort(List<Integer> nums) {
    method isSorted (line 23) | public static boolean isSorted(List<Integer> x) {

FILE: algorithms/bogo_sort/python/bogo.py
  function inorder (line 8) | def inorder(x):
  function bogo (line 17) | def bogo(x):

FILE: algorithms/bogo_sort/ruby/bogo_sort.rb
  function bogosort (line 1) | def bogosort(arr)

FILE: algorithms/breadth_first_search/cpp/bfs.cpp
  class Graph (line 7) | class Graph
  function main (line 65) | int main()

FILE: algorithms/bubble_sort/c/bubble_sort.c
  function bubbleSort (line 11) | void bubbleSort(int arr[], int n)
  function main (line 22) | int main()

FILE: algorithms/bubble_sort/cpp/bubble_sort_1.cpp
  function bubble_sort (line 8) | void bubble_sort()
  function main (line 24) | int main()

FILE: algorithms/bubble_sort/cpp/bubblesort.cpp
  function main (line 5) | void main()

FILE: algorithms/bubble_sort/csharp/BubbleSort.cs
  class BubbleSort (line 5) | public class BubbleSort {
    method Main (line 6) | private static void Main(string[] args) {
    method BubbleSort (line 32) | private static void BubbleSort(IList<int> list) {

FILE: algorithms/bubble_sort/elixir/bubblesort.ex
  class BubbleSort (line 1) | defmodule BubbleSort
    method sort (line 2) | def sort([]),  do: []
    method sort (line 3) | def sort(list) do
    method swap (line 11) | defp swap([head | []]), do: [head]
    method swap (line 12) | defp swap([head | [second | tail]]) do

FILE: algorithms/bubble_sort/go/bubble-sort-algorithm.go
  function main (line 5) | func main() {
  function bubbleSort (line 13) | func bubbleSort(numbers []int) {
  function sweep (line 21) | func sweep(numbers []int) {

FILE: algorithms/bubble_sort/java/BubbleSortExample.java
  class BubbleSortExample (line 3) | public class BubbleSortExample {
    method bubbleSort (line 5) | private static void bubbleSort(int[] arr) {
    method main (line 21) | public static void main(String[] args) {

FILE: algorithms/bubble_sort/java/GenericBubbleSort.java
  class GenericBubbleSort (line 2) | class GenericBubbleSort {
    method bubble_sort (line 4) | public static <T extends Comparable<T>> void bubble_sort(T array[]){
    method swap (line 20) | private static <T> void swap(int index, T[] array){
    method printArray (line 26) | private static <T> void printArray(T[] input){
    method main (line 33) | public static void main(String[] args){

FILE: algorithms/bubble_sort/javascript/bubble-sort.js
  function bubbleSort (line 1) | function bubbleSort(a)

FILE: algorithms/bubble_sort/javascript/bubbleSort.js
  function bubbleSort (line 1) | function bubbleSort(array) {

FILE: algorithms/bubble_sort/javascript/main_bs.js
  function readInput (line 13) | function readInput() {

FILE: algorithms/bubble_sort/python/bubble_sort.py
  function bubbleSort (line 1) | def bubbleSort(a):

FILE: algorithms/bubble_sort/ruby/bubble_sort.rb
  function bubble_sort (line 1) | def bubble_sort(array)

FILE: algorithms/bucket_sort/bucket_sort.cpp
  function bucketSort (line 8) | void bucketSort(float arr[], int n)
  function main (line 32) | int main()

FILE: algorithms/bucket_sort/bucket_sort.java
  class Bucket_Sort (line 4) | public class Bucket_Sort
    method sort (line 6) | static int[] sort(int[] sequence, int maxValue)
    method printSequence (line 23) | static void printSequence(int[] sorted_sequence)
    method maxValue (line 29) | static int maxValue(int[] sequence)
    method main (line 38) | public static void main(String args[])

FILE: algorithms/bucket_sort/bucket_sort.py
  function bucketsort (line 1) | def bucketsort( A ):
  function hashing (line 31) | def hashing( A ):
  function re_hashing (line 40) | def re_hashing( i, code ):

FILE: algorithms/bucket_sort/c/bucket_sort.c
  function Bucket_Sort (line 13) | void Bucket_Sort(int array[], int n)
  function main (line 47) | int main()

FILE: algorithms/caesar_cipher/java/caesar.java
  class Caesar (line 7) | public class Caesar {
    method encode (line 8) | public static String encode (String message,int shift)
    method decode (line 54) | public static String decode (String message,int shift)
    method main (line 100) | public static void main(String[] args)

FILE: algorithms/caesar_cipher/javascript/caesarCipher.js
  constant LEGAL_VALUES (line 1) | const LEGAL_VALUES = 'abcdefghijklmnopqrstuvwxyz';
  constant START_CODE (line 2) | const START_CODE = 'a'.charCodeAt(0);
  constant END_CODE (line 3) | const END_CODE = 'z'.charCodeAt(0);
  class CaesarCipher (line 5) | class CaesarCipher {
    method constructor (line 6) | constructor(key) {
    method generateKey (line 16) | generateKey() {
    method validateKey (line 25) | validateKey() {
    method encode (line 36) | encode(decodedMessage) {
    method decode (line 59) | decode(encodedMessage) {

FILE: algorithms/check_pallindrome_number/c/checkPalindrome.c
  function checkPall (line 4) | int checkPall(char str[])
  function main (line 15) | int main()

FILE: algorithms/check_pallindrome_number/cpp/checkPall.cpp
  function checkPall (line 5) | int checkPall(char str[])
  function main (line 16) | int main()

FILE: algorithms/closest/java/Closest.java
  class Closest (line 11) | public class Closest {
    method main (line 12) | public static void main(String[] args) {

FILE: algorithms/cycle_sort/java/cycleSort.java
  class GFG (line 6) | class GFG
    method cycleSort (line 9) | public static void cycleSort (int arr[], int n)
    method main (line 72) | public static void main(String[] args)

FILE: algorithms/decoding/c/base64_decoder.c
  function val (line 18) | int val(char x){
  function main (line 25) | int main() {

FILE: algorithms/dfs/cpp/dfs.cpp
  class Vertex (line 8) | class Vertex {
  function VisitVertex (line 25) | void VisitVertex(Vertex *v, Vertex * predecessor){
  function DFS (line 34) | void DFS(std::vector <Vertex *> graph){
  function main (line 47) | int main() {

FILE: algorithms/dfs/java/Graph.java
  class Graph (line 6) | class Graph {
    method Graph (line 14) | Graph(int v) {
    method addEdge (line 26) | public void addEdge(int v, int w)  {
    method DFSUtil (line 35) | private void DFSUtil(int v, boolean visited[])  {
    method DFS (line 49) | void DFS(int source) {
    method main (line 59) | public static void main(String args[]) {

FILE: algorithms/dfs/python/Dfs.py
  class Graph (line 8) | class Graph:
    method __init__ (line 11) | def __init__(self):
    method addEdge (line 17) | def addEdge(self,u,v):
    method DFSUtil (line 21) | def DFSUtil(self,v,visited):
    method DFS (line 35) | def DFS(self,v):

FILE: algorithms/dijkstra/cpp/Dijkstras.cpp
  function minDistance (line 12) | int minDistance(int dist[], bool sptSet[])
  function printSolution (line 25) | int printSolution(int dist[], int n)
  function dijkstra (line 34) | void dijkstra(int graph[V][V], int src)
  function main (line 75) | int main()

FILE: algorithms/dijkstra/java/ShortestPath.java
  class ShortestPath (line 5) | public class ShortestPath {
    method minDistance (line 8) | private int minDistance(int dist[], Boolean sptSet[]) {
    method printSolution (line 22) | private void printSolution(int dist[]) {
    method dijkstra (line 34) | public void dijkstra(int graph[][], int source) {
    method main (line 67) | public static void main (String[] args) {

FILE: algorithms/dijkstra/python/djikstra.py
  class Graph (line 1) | class Graph:
    method __init__ (line 2) | def __init__(self):
    method add_node (line 7) | def add_node(self, value):
    method add_edge (line 10) | def add_edge(self, from_node, to_node, distance):
  function dijsktra (line 16) | def dijsktra(graph, initial):

FILE: algorithms/doomsday/java/doomsday.java
  class Doomsday (line 7) | public class Doomsday {
    method dow (line 18) | public static int dow(int y, int m, int d) {
    method dowS (line 33) | public static String dowS(int y, int m, int d) {
    method main (line 48) | public static void main(String[] args) {

FILE: algorithms/doomsday/javascript/doomsday.js
  function dayOfTheWeek (line 1) | function dayOfTheWeek(y, m, d) {

FILE: algorithms/dynamic_programming/c/0_1_knapsack_problem.c
  function max (line 5) | int max(int a, int b) { return (a > b)? a : b; }
  function knapSack (line 8) | int knapSack(int W, int wt[], int val[], int n)
  function main (line 30) | int main()

FILE: algorithms/dynamic_programming/c/Coin_change_DP.c
  function count (line 17) | int count( int S[], int m, int n )
  function main (line 48) | int main()

FILE: algorithms/dynamic_programming/c/coinChange.c
  function count (line 2) | int count( int S[], int m, int n )
  function main (line 24) | int main()

FILE: algorithms/dynamic_programming/c/count_no_of_ways_to_reach_nth_stair.c
  function countWaysUtil (line 6) | int countWaysUtil(int n, int m)
  function countWays (line 20) | int countWays(int s, int m)
  function main (line 26) | int main ()

FILE: algorithms/dynamic_programming/c/longestIncreasingSubsequence.c
  function lis (line 7) | int lis( int arr[], int n )
  function main (line 34) | int main()

FILE: algorithms/dynamic_programming/c/longestRepeatedSequence.c
  function string (line 9) | string longestRepeatedSubSeq(string str)
  function main (line 64) | int main()

FILE: algorithms/dynamic_programming/c/longest_pallindrome_sequence.c
  function max (line 7) | int max (int x, int y) { return (x > y)? x : y; }
  function lps (line 10) | int lps(char *str)
  function main (line 44) | int main()

FILE: algorithms/dynamic_programming/c/maxSumIncSequence.c
  function maxSumIS (line 7) | int maxSumIS( int arr[], int n )
  function main (line 31) | int main()

FILE: algorithms/dynamic_programming/c/subsetSum.c
  function isSubsetSum (line 5) | bool isSubsetSum(int set[], int n, int sum)
  function main (line 25) | int main()

FILE: algorithms/dynamic_programming/cpp/kadens.cpp
  function maxSubArraySum (line 6) | int maxSubArraySum(int a[], int size)
  function main (line 23) | int main()

FILE: algorithms/dynamic_programming/cpp/nCr.cpp
  function nCrModp (line 5) | int nCrModp(int n, int r, int p)
  function main (line 30) | int main()

FILE: algorithms/dynamic_programming/cpp/subset_sum.cpp
  function m_diff (line 6) | int m_diff(int idx,int sub_sum)
  function main (line 19) | int main()

FILE: algorithms/dynamic_programming/java/MinCostPath.java
  class MinCostPath (line 3) | public class MinCostPath {
    method minCostPathDP (line 5) | public static int minCostPathDP(int arr[][],int row, int column) {
    method main (line 30) | public static void main(String args[]) {

FILE: algorithms/encoding/base64_encoder.c
  function main (line 18) | int main() {

FILE: algorithms/fibonacci/cpp/constexpr-fibonacci.cpp
  function fibonacci (line 4) | constexpr unsigned int fibonacci(unsigned int index) {

FILE: algorithms/floyd_warshall/java/ShortestPath.java
  class ShortestPath (line 5) | public class ShortestPath {
    method floydWarshall (line 9) | public void floydWarshall(int graph[][]) {
    method printSolution (line 30) | private void printSolution(int dist[][]) {
    method main (line 47) | public static void main (String[] args) {

FILE: algorithms/greedy_search/cpp/prims_algorithm.cpp
  function minkey (line 4) | int minkey(int key[], bool mstset[],int n)
  function main (line 18) | int main()

FILE: algorithms/heap_sort/java/heap_sort.java
  class HeapSort (line 8) | public class HeapSort
    method sort (line 12) | public static void sort(int arr[])
    method heapify (line 23) | public static void heapify(int arr[])
    method maxheap (line 30) | public static void maxheap(int arr[], int i)
    method swap (line 47) | public static void swap(int arr[], int i, int j)
    method main (line 54) | public static void main(String[] args)

FILE: algorithms/heap_sort/java/heapsort.java
  class heapsort (line 3) | class heapsort
    method sort (line 5) | public void sort(int arr[])
    method heapify (line 28) | void heapify(int arr[], int n, int i)
    method printArray (line 55) | static void printArray(int arr[])
    method main (line 64) | public static void main(String args[])

FILE: algorithms/heap_sort/javascript/heap_sort.js
  function heap_root (line 3) | function heap_root(input, i) {
  function swap (line 22) | function swap(input, index_A, index_B) {
  function heapSort (line 29) | function heapSort(input) {

FILE: algorithms/heap_sort/python/heap_sort.py
  function heap_sort (line 3) | def heap_sort(heap_iterable):

FILE: algorithms/histogram_equalization/java/HistogramEqualization.java
  class HistogramEqualization (line 19) | public class HistogramEqualization {
    method main (line 21) | public static void main(String[] args) {
  class ImageMatrix (line 30) | class ImageMatrix {
    method ImageMatrix (line 46) | public ImageMatrix(int[][] arr) {
    method getFrequency (line 51) | public int getFrequency(int key) {
    method getCdf (line 56) | public int getCdf(int key) {
    method frequency (line 61) | public HashMap<Integer, Integer> frequency() {
    method cdf (line 66) | public HashMap<Integer, Integer> cdf() {
    method calculateFrequency (line 74) | private void calculateFrequency() {
    method calculateCdf (line 87) | private void calculateCdf() {
    method equalize (line 105) | public ImageMatrix equalize() {
    method toString (line 116) | @Override

FILE: algorithms/huffmann_algorithm/java/Huffman.java
  class Huffman (line 9) | public class Huffman {
    method Huffman (line 14) | public Huffman(String sourceString){
    method encode (line 63) | public String encode(String str){
    method decode (line 75) | public String decode(String str){
    class Pair (line 91) | private class Pair {
      method Pair (line 95) | Pair(int cost, BinaryTree bt){

FILE: algorithms/insertion_sort/c/InsertionSort.c
  function insertionSort (line 4) | void insertionSort(int ar[], int n)
  function print (line 22) | void print(int ar[], int n)
  function main (line 29) | int main()

FILE: algorithms/insertion_sort/cpp/insertion_sort.cpp
  function insertionSort (line 12) | void insertionSort( int tab[], int arraySize ) {
  function printArray (line 22) | void printArray(int arr[], int arraySize) {
  function main (line 27) | int main() {

FILE: algorithms/insertion_sort/java/InsertionSort.java
  class InsertionSort (line 1) | class InsertionSort {
    method insertionSort (line 7) | public static int[] insertionSort(int[] array) {
    method main (line 24) | public static void main(String[] args) {

FILE: algorithms/insertion_sort/javascript/insertionSort.js
  function insertionSort (line 1) | function insertionSort(array) {

FILE: algorithms/insertion_sort/javascript/insertion_sort.js
  function insertionSort (line 1) | function insertionSort(unsortedList) {

FILE: algorithms/insertion_sort/ruby/insertion_sort.rb
  function insertion_sort (line 1) | def insertion_sort(numbers)

FILE: algorithms/inversion_count/cpp/inversion_count.cpp
  function merge (line 4) | long merge(vector<int> &arr, vector<int> &tmp, int left, int mid, int ri...
  function mergeSort (line 26) | long mergeSort(vector<int> &arr, vector<int> &tmp, int left, int right) {
  function countInversions (line 38) | long countInversions(vector<int> arr) {
  function main (line 43) | int main() {

FILE: algorithms/jarvis/cpp/jarvis.cpp
  type Point (line 5) | struct Point
  function orientation (line 15) | int orientation(Point p, Point q, Point r)
  function convexHull (line 25) | void convexHull(Point points[], int n)

FILE: algorithms/johnson_algorithm/cpp/johnson_algorithm.cpp
  function min (line 17) | int min(int a, int b)
  function main (line 33) | int main(int argc, char **argv)

FILE: algorithms/kmp_search/cpp/KMPSearch.cpp
  function main (line 13) | int main(void)
  function Kmp_Search (line 34) | int Kmp_Search()
  function Compute_Prefix_Array (line 57) | void Compute_Prefix_Array()

FILE: algorithms/kmp_search/java/KMPSearch.java
  class KMPSearch (line 2) | public class KMPSearch {
    method main (line 3) | public static void main(String[] args) {
    method demo (line 7) | private void demo() {
    method calculatePrefixArray (line 34) | private void calculatePrefixArray(String s, int[] prefixArray) {

FILE: algorithms/kmp_search/python/KMPSearch.py
  class KMP (line 1) | class KMP:
    method partial (line 2) | def partial(self, pattern):
    method search (line 13) | def search(self, T, P):

FILE: algorithms/linear_search/c/linearsearch.C
  function linear (line 3) | int linear(int a[], int n, int x){
  function main (line 13) | int main(){

FILE: algorithms/linear_search/cpp/linearSearch.cpp
  function linearSearch (line 4) | int linearSearch(int* arr, int size, int num){
  function main (line 12) | int main(){

FILE: algorithms/linear_search/java/LinearSearch.java
  class LinearSearch (line 3) | public class LinearSearch {
    method main (line 5) | public static void main(String args[])

FILE: algorithms/linear_search/python/linear_search.py
  function linear_search (line 1) | def linear_search(a,target):

FILE: algorithms/longest_common_subsequence/cpp/LongestCommonSubsequence.cpp
  function lcs (line 7) | int lcs( char *X, char *Y, int m, int n )
  function max (line 34) | int max(int a, int b)
  function main (line 40) | int main()

FILE: algorithms/longest_common_subsequence/javaj/LCS.java
  method lcs (line 2) | int lcs( char[] X, char[] Y, int m, int n )
  method max (line 24) | int max(int a, int b)
  method main (line 29) | public static void main(String[] args)

FILE: algorithms/longest_common_subsequence/javascript/longest_common_subsequence.js
  function lcs (line 1) | function lcs(a, b) {

FILE: algorithms/longest_common_subsequence/python/LCS.py
  function lcs (line 3) | def lcs(X , Y):

FILE: algorithms/longest_common_substring/java/LongestCommonSubString.java
  class StringManager (line 3) | class StringManager {
    method findLongestCommonSubString (line 5) | public static String findLongestCommonSubString(String str1, String st...
    method main (line 42) | public static void main(String[] args){

FILE: algorithms/matrix_chain_multiplication/cpp/MCM.cpp
  function MatrixChainOrder (line 6) | int MatrixChainOrder(int p[], int n)
  function main (line 44) | int main()

FILE: algorithms/matrix_chain_multiplication/python/MCM.py
  function matrix_chain_multiplication (line 1) | def matrix_chain_multiplication(dimensions):

FILE: algorithms/merge_sort/c#/MergeSort.cs
  class MergeSort (line 5) | class MergeSort
    method Main (line 7) | static void Main(string[] args)
    method Sort (line 17) | static int[] Sort(int[] w)
    method Merge (line 44) | static int[] Merge(int[] u, int[] v)

FILE: algorithms/merge_sort/cpp/merge_sort.cpp
  function merge_sort (line 4) | void merge_sort(int low,int high)
  function merge (line 15) | void merge(int low,int mid,int high)
  function main (line 54) | void main()

FILE: algorithms/merge_sort/java/merge_sort.java
  class MergeSort (line 2) | class MergeSort
    method merge (line 7) | private static void merge(int arr[], int l, int m, int r)
    method sort (line 65) | private static void sort(int arr[], int l, int r)
    method sort (line 83) | public static boolean sort(int[] arr) {
    method printArray (line 96) | public static void printArray(int arr[])
    method main (line 105) | public static void main(String args[])

FILE: algorithms/merge_sort/javascript/MergeSort.js
  function mergeSort (line 3) | function mergeSort(arr)
  function merge (line 15) | function merge(left, right)

FILE: algorithms/merge_sort/python/merge_sort.py
  function merge_sort (line 1) | def merge_sort(li):
  function merge (line 11) | def merge(left, right):

FILE: algorithms/merge_sort/ruby/merge_sort.rb
  function sort (line 1) | def sort(numbers)
  function merge (line 16) | def merge(left, right)

FILE: algorithms/minimum_spanning_tree/cpp/MST.cpp
  function init (line 8) | void init()
  function root (line 16) | int root(int i)
  function unio (line 25) | void unio(int a,int b)
  function ll (line 38) | ll kruskal(){
  function main (line 58) | int main()

FILE: algorithms/optimal_binary_search_tree/java/OptimalBst.java
  class OptimalBst (line 3) | public class OptimalBst {
    method main (line 9) | public static void main(String[] args) {
    method findMinimum (line 53) | public static int findMinimum(int[][] array , int i , int j){

FILE: algorithms/parse_tree/python/parse_tree.py
  class Stack (line 1) | class Stack:
    method __init__ (line 2) | def __init__(self):
    method isEmpty (line 5) | def isEmpty(self):
    method push (line 8) | def push(self, item):
    method pop (line 11) | def pop(self):
    method peek (line 14) | def peek(self):
    method size (line 17) | def size(self):
  class BinaryTree (line 20) | class BinaryTree:
    method __init__ (line 21) | def __init__(self,rootObj):
    method insertLeft (line 26) | def insertLeft(self,newNode):
    method insertRight (line 34) | def insertRight(self,newNode):
    method getRightChild (line 43) | def getRightChild(self):
    method getLeftChild (line 46) | def getLeftChild(self):
    method setRootVal (line 49) | def setRootVal(self,obj):
    method getRootVal (line 52) | def getRootVal(self):
  function buildParseTree (line 56) | def buildParseTree(fpexp):
  function evaluate (line 82) | def evaluate(parseTree):

FILE: algorithms/permutations/java/Permutation.java
  class Permutation (line 2) | public class Permutation
    method permute (line 4) | public void permute(String str, int l, int r)
    method swap (line 22) | public String swap(String a, int i, int j)
    method main (line 32) | public static void main(String[] args)

FILE: algorithms/quick_sort/c/quick_sort.c
  function quicksort (line 2) | void quicksort(int number[25],int first,int last){
  function main (line 31) | int main(){

FILE: algorithms/quick_sort/cpp/quickSort.cpp
  function main (line 9) | int main()
  function quickSort (line 29) | void quickSort(vector<int>& A, int start,int end)
  function partition (line 41) | int partition(vector<int>& A, int start,int end)

FILE: algorithms/quick_sort/csharp/QuickSort.cs
  class QuickSort (line 5) | class QuickSort
    method Main (line 7) | static void Main(string[] args)
    method Sort (line 20) | void Sort(int[] arr, int low, int high)
    method Partition (line 30) | int Partition(int[] arr, int low, int high)

FILE: algorithms/quick_sort/csharp/quicksort.cs
  class QuickSort (line 7) | public class QuickSort
    method Main (line 13) | private static void Main(string[] args)
    method Qsort (line 43) | private static void Qsort(IList<int> list, int left, int right)
    method Partition (line 55) | private static int Partition(IList<int> list, int left, int right)
    method Swap (line 88) | private static void Swap(IList<int> arr, int i, int j)

FILE: algorithms/quick_sort/java/QuickSort.java
  class QuickSort (line 1) | public class QuickSort{
    method quickSort (line 2) | static void quickSort(int[] arr,int start, int end){
    method partition (line 10) | static int partition(int [] arr, int start, int end){
    method swap (line 28) | static void swap(int[] arr,int i, int j){
    method print (line 34) | static void print(int [] arr){
    method main (line 40) | public static void main(String [] args){

FILE: algorithms/quick_sort/javascript/quick_sort.js
  function quicksort (line 3) | function quicksort(arr, p, r) {
  function partition (line 13) | function partition(arr, p, r) {

FILE: algorithms/quick_sort/python/quicksort.py
  function partition (line 1) | def partition(li, start, end):
  function quicksort (line 20) | def quicksort(li, start=0, end=None):

FILE: algorithms/quick_sort/ruby/quick_sort.rb
  function quicksort (line 1) | def quicksort(array)

FILE: algorithms/rabin_karp/java/RabinKarp.java
  class RabinKarp (line 3) | public class RabinKarp {
    method RabinKarp (line 9) | public RabinKarp(String pat)
    method hash (line 20) | private long hash(String key,int M)
    method search (line 29) | public int search(String txt)
    method longPrimeNumber (line 42) | private static long longPrimeNumber()

FILE: algorithms/radixsort/c++/radixsort.cpp
  function getMax (line 5) | int getMax(int arr[], int n)
  function countSort (line 14) | void countSort(int arr[], int n, int exp)
  function radixsort (line 34) | void radixsort(int arr[], int n)
  function print (line 41) | void print(int arr[], int n)
  function main (line 47) | int main()

FILE: algorithms/radixsort/python/lsd_radixsort.py
  function get_digit (line 4) | def get_digit(number, digit):
  function lsd_radix_sort (line 8) | def lsd_radix_sort(array):

FILE: algorithms/selection_sort/c/SelectionSort.c
  function SelectionSort (line 5) | void SelectionSort(int arr[SIZE]){
  function main (line 23) | void main(){

FILE: algorithms/selection_sort/java/SelectionSort.java
  class SelectionSort (line 2) | class SelectionSort
    method sort (line 5) | void sort(int ar[])
    method printArray (line 21) | void printArray(int arr[])
    method main (line 28) | public static void main(String args[])

FILE: algorithms/selection_sort/python/selection_sort.py
  function selectionsort (line 9) | def selectionsort(a):

FILE: algorithms/selection_sort/ruby/selection_sort.rb
  function selection_sort (line 1) | def selection_sort(input_arr)

FILE: algorithms/shell_sort/C++/ShellSort.cpp
  function shellSort (line 6) | int shellSort(int arr[], int n)
  function printArray (line 34) | void printArray(int arr[], int n)
  function main (line 40) | int main()

FILE: algorithms/shell_sort/C/ShellSort.c
  function shellsort (line 3) | void shellsort(int arr[], int num)
  function main (line 26) | int main()

FILE: algorithms/shell_sort/Java/ShellSort.java
  class ShellSort (line 2) | class ShellSort
    method printArray (line 5) | static void printArray(int arr[])
    method sort (line 14) | int sort(int arr[])
    method main (line 47) | public static void main(String args[])

FILE: algorithms/shell_sort/python/shellsort.py
  function shellSort (line 1) | def shellSort(arr):

FILE: algorithms/sieve_of_eratosthenes/cpp/sieve_of_eratosthenes.cpp
  function SieveOfEratosthenes (line 6) | void SieveOfEratosthenes(int n)
  function main (line 32) | int main()

FILE: algorithms/sieve_of_eratosthenes/java/sieve.java
  class sieve (line 5) | public class sieve
    method sievefunction (line 10) | private void sievefunction(int n, boolean primearr[])
    method print (line 34) | private void print(int n, boolean primearr[])
    method main (line 46) | public static void main(String args[]) throws IOException

FILE: algorithms/sieve_of_eratosthenes/python/sieve.py
  function run_sieve (line 1) | def run_sieve(N, isPrime):
  function print_sieve (line 9) | def print_sieve(N, isPrime):
  function sieve (line 15) | def sieve(N):

FILE: algorithms/sort/heap_sort/java/heap_sort.java
  class HeapSort (line 2) | public class HeapSort
    method sort (line 4) | public void sort(int arr[])
    method heapify (line 27) | void heapify(int arr[], int n, int i)
    method printArray (line 54) | static void printArray(int arr[])
    method main (line 63) | public static void main(String args[])

FILE: algorithms/strings/cpp/anagrams.cpp
  function isAnagram (line 4) | bool isAnagram(string a, string b)
  function findAnagrams (line 13) | vector<int> findAnagrams(string arr[], int n)
  function main (line 33) | int main(int argc, char const *argv[])

FILE: algorithms/tower_of_hanoi/cpp/tower_of_hanoi.cpp
  function main (line 5) | int main(){
  function Hanoi (line 15) | void Hanoi(int m, char a, char b, char c)

FILE: algorithms/tower_of_hanoi/java/towers_of_hanoi.java
  class TowersOfHanoi (line 1) | public class TowersOfHanoi {
    method solve (line 3) | public void solve(int n, String start, String auxiliary, String end) {
    method main (line 13) | public static void main(String[] args) {

FILE: algorithms/tower_of_hanoi/javascript/tower_of_hanoi.js
  function moveDisk (line 3) | function moveDisk(from_pole, to_pole) {
  function towerOfHanoi (line 9) | function towerOfHanoi(height, from_pole=1, to_pole=2, aux=3) {

FILE: algorithms/tower_of_hanoi/php/towers_of_hanoi.php
  function move (line 3) | function move($n, $src, $dest, $temp ){

FILE: algorithms/tower_of_hanoi/python/tower_of_hanoi.py
  function move_disk (line 2) | def move_disk(from_pole, to_pole):
  function tower_of_hanoi (line 8) | def tower_of_hanoi(height, from_pole=1, to_pole=2, aux=3):

FILE: data_structures/arraylist/java/arraylist.java
  class arraylist (line 2) | public class arraylist {
    method main (line 4) | public static void main(String args[]) {

FILE: data_structures/avl_tree/java/AVL.java
  class AVL (line 1) | public class AVL {
    class Node (line 2) | class Node {
      method Node (line 5) | public Node(int data, int height) {
    method getHeight (line 13) | private int getHeight(Node root) {
    method getBalance (line 18) | private int getBalance(Node root) {
    method rightRotate (line 23) | private Node rightRotate(Node root) {
    method leftRotate (line 35) | private Node leftRotate(Node root) {
    method insert (line 47) | public void insert(int data) {
    method insert (line 51) | private Node insert(Node root, int data, int height) {
    method preorder (line 77) | public void preorder() {
    method preorder (line 81) | private void preorder(Node root) {
    method main (line 88) | public static void main(String[] args) {

FILE: data_structures/bag/java/Bag.java
  class Bag (line 11) | public class Bag<Element> implements Iterable<Element> {
    class Node (line 16) | private static class Node<Element> {
    method Bag (line 24) | public Bag() {
    method isEmpty (line 32) | public boolean isEmpty() {
    method size (line 39) | public int size() {
    method add (line 46) | public void add(Element element) {
    method contains (line 60) | public boolean contains(Element element) {
    method iterator (line 73) | public Iterator<Element> iterator() {
    class ListIterator (line 77) | @SuppressWarnings("hiding")
      method ListIterator (line 81) | public ListIterator(Node<Element> firstElement) {
      method hasNext (line 85) | public boolean hasNext() {
      method remove (line 92) | @Override
      method next (line 97) | public Element next() {
    method main (line 109) | public static void main(String[] args) {

FILE: data_structures/binary_search_tree/c/BSTtraversal.c
  type node (line 7) | struct node
  type node (line 16) | struct node
  type node (line 18) | struct node
  type node (line 18) | struct node
  type node (line 19) | struct node
  function printPostorder (line 29) | void printPostorder(struct node* node)
  function printInorder (line 45) | void printInorder(struct node* node)
  function printPreorder (line 61) | void printPreorder(struct node* node)
  function main (line 77) | int main()

FILE: data_structures/binary_search_tree/cpp/BST.h
  function insert (line 22) | void insert(T data) { insert(data, root); }
  function findMin (line 25) | int findMin() { return findMin(root); }
  function remove (line 28) | void remove(T data) { remove(data, root); }
  function find (line 32) | bool find(T data)
  function printTree (line 38) | void printTree()
  type Node (line 47) | struct Node {
  function destroy (line 54) | void destroy(Node *n)
  function print (line 66) | void print(Node *ptr)
  function find (line 84) | bool find(T data, Node *n)
  function findMin (line 99) | int findMin(Node *ptr)
  function Node (line 116) | Node *createLeaf(T data)
  function insert (line 127) | void insert(T data, Node *ptr)
  function removeMatch (line 155) | void removeMatch(Node *parent, Node *match, bool left)
  function removeRootMatch (line 197) | void removeRootMatch()
  function remove (line 231) | void remove(T data, Node *parent)
  type BinarySearchTree (line 262) | typedef BinarySearchTree<int> intBST;

FILE: data_structures/binary_search_tree/java/binary_search_tree.java
  class Node (line 28) | class Node {                                                            ...
    method getLeft (line 34) | public Node getLeft() {
    method setLeft (line 38) | public void setLeft(Node e) {
    method getRight (line 42) | public Node getRight() {
    method setRight (line 46) | public void setRight(Node e) {
    method setValue (line 50) | public void setValue(int value) {
    method getValue (line 54) | public int getValue() {
  class BinarySearchTree (line 65) | public class BinarySearchTree {
    method main (line 67) | public static void main(String[] args){
  class Bintree (line 140) | class Bintree {
    method addLeftChild (line 142) | public boolean addLeftChild(Node parent, int newvalue) {              ...
    method addRightChild (line 151) | public boolean addRightChild(Node parent, int newvalue) {             ...
    method createTree (line 160) | public Node createTree(int[] elements) {                              ...
    method expandTree (line 185) | public boolean expandTree(Node root, int[] elements) {             //e...
    method traverse_inorder (line 215) | public void traverse_inorder(Node root) {                      //inord...
    method traverse_preorder (line 223) | public void traverse_preorder(Node root) {                     //inord...
    method traverse_postorder (line 231) | public void traverse_postorder(Node root) {                    //posto...
  class BinSearchTree (line 240) | class BinSearchTree extends Bintree {                                  /...
    method insert (line 242) | public Node insert(Node root, int key) {                    //define a...
    method createTree (line 255) | @Override
    method addValue (line 268) | public boolean addValue(Node root, int newvalue) { //add value to the ...
    method deleteValue (line 283) | public boolean deleteValue(Node root, int value) {                 //d...
    method searchValue (line 351) | public Node searchValue(Node root, int key) {          //find the node...
    method print_tree (line 365) | public void print_tree(Node root) {

FILE: data_structures/binary_search_tree/java/bst_operations/CheckBST.java
  class CheckBST (line 3) | public class CheckBST {
    method main (line 4) | public static void main(String[] args) {
    method demo (line 8) | private void demo() {
    method isBST (line 20) | private boolean isBST(Node n, int min, int max) {

FILE: data_structures/binary_search_tree/java/bst_operations/CorrectBST.java
  class CorrectBST (line 8) | public class CorrectBST {
    method main (line 9) | public static void main(String[] args) {
    method demo (line 13) | private void demo() {
    method display (line 37) | private void display(Node n) {
    method balanceBST (line 45) | private void balanceBST(Node n, ArrayList<Node> list, int min, int max) {

FILE: data_structures/binary_search_tree/java/bst_operations/FindAncestor.java
  class FindAncestor (line 8) | public class FindAncestor {
    method main (line 9) | public static void main(String[] args) {
    method demo (line 13) | private void demo() {
    method findDistance (line 42) | private int findDistance(Node n, Node ancestor) {
    method findDistanceUtil (line 46) | private int findDistanceUtil(Node n, Node ancestor, int level) {
    method lowestAncestor (line 58) | private Node lowestAncestor(Node n, int m1, int m2) {

FILE: data_structures/binary_search_tree/java/bst_operations/InorderSuccessor.java
  class InorderSuccessor (line 3) | public class InorderSuccessor {
    method main (line 4) | public static void main(String[] args) {
    method demo (line 8) | private void demo() {
    method getNextSuccessor (line 32) | private Integer getNextSuccessor(Node root, Node target) {

FILE: data_structures/binary_search_tree/java/bst_operations/LargestBST.java
  class LargestBST (line 7) | public class LargestBST {
    class BSTCount (line 8) | class BSTCount {
    class BST (line 13) | class BST {
      method BST (line 17) | public BST() {
    method main (line 23) | public static void main(String[] args) {
    method demo (line 27) | private void demo() {
    method largestBST (line 51) | private void largestBST(Node n) {
    method largestBSTUtil (line 59) | private void largestBSTUtil(Node n, BST bst, BSTCount bstCount) {
    method isBST (line 72) | private void isBST(Node n, BSTCount bstCount) {
    method isBSTUtil (line 78) | private Boolean isBSTUtil(Node n, int minValue, int maxValue, BSTCount...

FILE: data_structures/binary_search_tree/java/bst_operations/LevelOrder.java
  class LevelOrder (line 9) | public class LevelOrder {
    method main (line 10) | public static void main(String[] args) {
    method demo (line 14) | private void demo() {
    method displayLevelOrder (line 42) | private void displayLevelOrder(Node n, Boolean zigzag) {
    method print (line 66) | private void print(Deque<Node> parents, Boolean flag, Boolean zigzag) {

FILE: data_structures/binary_search_tree/java/bst_operations/MorrisTraversal.java
  class MorrisTraversal (line 8) | public class MorrisTraversal {
    method main (line 9) | public static void main(String[] args) {
    method demo (line 13) | private void demo() {
    method inorderIterative (line 38) | private void inorderIterative(Node n) {
    method getPredecessor (line 57) | private Node getPredecessor(Node n) {

FILE: data_structures/binary_search_tree/java/bst_operations/Node.java
  class Node (line 3) | public class Node {
    method Node (line 8) | public Node(int d) {

FILE: data_structures/binary_search_tree/java/bst_operations/PathFromRootToNode.java
  class PathFromRootToNode (line 9) | public class PathFromRootToNode {
    method main (line 11) | public static void main(String[] args) {
    method demo (line 15) | private void demo() {
    method display (line 42) | private void display(ArrayList<Node> al) {
    method findPath (line 50) | private void findPath(Node n, int data, ArrayList<Node> al) {

FILE: data_structures/binary_search_tree/javascript/binary_tree.js
  function BST (line 5) | function BST(val) {
  function recurse (line 19) | function recurse(bst) {

FILE: data_structures/binary_search_tree/javascript/binary_tree_search.js
  function recurse (line 6) | function recurse(bst) {
  function recurse (line 23) | function recurse(bst) {

FILE: data_structures/binary_search_tree/javascript/breadth_first_search.js
  method enqueue (line 7) | enqueue(val) {
  method dequeue (line 10) | dequeue() {
  method isEmpty (line 13) | isEmpty() {
  method Top (line 16) | Top() {
  function recurse (line 36) | function recurse(bst) {
  function recurse (line 59) | function recurse(bst) {

FILE: data_structures/binary_search_tree/javascript/depth_first_search.js
  method Top (line 7) | Top() {
  method Pop (line 10) | Pop() {
  method Push (line 13) | Push(val) {
  method isEmpty (line 16) | isEmpty() {
  function recurse (line 33) | function recurse(bst) {
  function recurse (line 49) | function recurse(bst) {

FILE: data_structures/binary_search_tree/python/bst.py
  class TreeNode (line 5) | class TreeNode:
    method __init__ (line 6) | def __init__(self,k=None):
    method isleft (line 12) | def isleft(self):
    method isright (line 19) | def isright(self):
    method isleaf (line 25) | def isleaf(self):
  class BST (line 44) | class BST:
    method __init__ (line 46) | def __init__(self):
    method isEmpty (line 49) | def isEmpty(self):
    method insert (line 54) | def insert(self,key1):
    method maximum (line 76) | def maximum(self):
    method minimum (line 87) | def minimum(self):
    method successor (line 98) | def successor(self,node):
    method predecessor (line 115) | def predecessor(self,node):
    method search (line 134) | def search(self,key):
    method delete (line 145) | def delete(self,node):
  function printree (line 180) | def printree(r):

FILE: data_structures/binary_search_tree/python/bst1.py
  class Node (line 4) | class Node:
    method __init__ (line 5) | def __init__(self,key):
  function insert (line 11) | def insert(root,node):
  function inorder (line 27) | def inorder(root):

FILE: data_structures/binary_search_tree/python/bst2.py
  class Node (line 2) | class Node:
    method __init__ (line 3) | def __init__(self,data,left=None,right=None):
  class BST (line 9) | class BST:
    method __init__ (line 10) | def __init__(self,data=None):
    method printSideway (line 13) | def printSideway(root,level):
    method addI (line 19) | def addI(self,data):
    method insertR (line 39) | def insertR(root,data):
    method inOrder (line 55) | def inOrder(root,lamb=None):
    method _search (line 65) | def _search(root,data):
    method search (line 74) | def search(self,data):
    method _path (line 77) | def _path(root,data):
    method path (line 93) | def path(self,data):
    method _del (line 97) | def _del(root,data):
    method dele (line 106) | def dele(self,data):

FILE: data_structures/binary_tree/c/diameterBT.c
  type node (line 4) | struct node
  type node (line 11) | struct node
  type node (line 17) | struct node
  function diameter (line 20) | int diameter(struct node * tree)
  function height (line 46) | int height(struct node* node)
  type node (line 59) | struct node
  type node (line 61) | struct node
  type node (line 61) | struct node
  type node (line 62) | struct node
  function max (line 71) | int max(int a, int b)
  function main (line 77) | int main()

FILE: data_structures/binary_tree/cpp/binary_tree.cpp
  type Node (line 3) | struct Node {
    method Node (line 8) | Node(int tkey, const std::string& tvalue) : leftnode(nullptr), rightno...
  function query_bst (line 12) | std::string query_bst(const int key) {
  function insert_bst (line 27) | void insert_bst(int key, const std::string& value) {
  function main (line 46) | int main() {

FILE: data_structures/binary_tree/cpp/boundaryTraversal.cpp
  type node (line 5) | struct node
    type node (line 8) | struct node
  function printLeaves (line 12) | void printLeaves(struct node* root)
  function printBoundaryLeft (line 28) | void printBoundaryLeft(struct node* root)
  function printBoundaryRight (line 51) | void printBoundaryRight(struct node* root)
  function printBoundary (line 74) | void printBoundary (struct node* root)
  type node (line 93) | struct node
    type node (line 8) | struct node
  type node (line 95) | struct node
    type node (line 8) | struct node
  type node (line 95) | struct node
    type node (line 8) | struct node
  type node (line 95) | struct node
    type node (line 8) | struct node
  function main (line 104) | int main()

FILE: data_structures/binary_tree/csharp/BinaryTree.cs
  class BinaryTree (line 9) | class BinaryTree
    class TreeObject (line 12) | public class TreeObject
      method TreeObject (line 18) | public TreeObject(TreeObject newitem)
      method getRoot (line 23) | public TreeObject getRoot()
      method getLeftChild (line 28) | public TreeObject getLeftChild()
      method getRightChild (line 33) | public TreeObject getRightChild()
      method setRoot (line 38) | public void setRoot(TreeObject newItem)
      method setLeftChild (line 43) | public void setLeftChild(TreeObject newItem)
      method setRightChild (line 48) | public void setRightChild(TreeObject newItem)
    method init (line 55) | public TreeObject init(TreeObject newitem)
    method insertRight (line 61) | public void insertRight(TreeObject self, TreeObject newNode)
    method insertLeft (line 76) | public void insertLeft(TreeObject self, TreeObject newNode)

FILE: data_structures/binary_tree/java/binary_tree_bfs.java
  class bfs (line 6) | public class bfs {
    method levelOrderQueue (line 8) | public void levelOrderQueue(Node root) {
    method main (line 37) | public static void main(String[] args) throws java.lang.Exception {
  class Node (line 60) | class Node {
    method Node (line 65) | public Node(int data) {

FILE: data_structures/binary_tree/java/binary_tree_dfs.java
  class Node (line 3) | class Node{
    method Node (line 7) | public Node(int item){
  class BinaryTree (line 14) | class BinaryTree{
    method BinaryTree (line 17) | BinaryTree(){
    method preorder_rec (line 22) | public void preorder_rec(Node node){
    method inorder_rec (line 35) | public void inorder_rec(Node node){
    method postorder (line 49) | public void postorder(Node node){
    method main (line 62) | public static void main(String[] args){

FILE: data_structures/binary_tree/python/binary_tree.py
  class BinaryTree (line 1) | class BinaryTree:
    method __init__ (line 2) | def __init__(self,rootObj):
    method insertLeft (line 7) | def insertLeft(self,newNode):
    method insertRight (line 15) | def insertRight(self,newNode):
    method getRightChild (line 24) | def getRightChild(self):
    method getLeftChild (line 27) | def getLeftChild(self):
    method setRootVal (line 30) | def setRootVal(self,obj):
    method getRootVal (line 33) | def getRootVal(self):

FILE: data_structures/bloom_filter/python/bloom_filter.py
  class BloomFilter (line 5) | class BloomFilter:
    method SimpleStringEncode (line 8) | def SimpleStringEncode(self, data):
    method FNV (line 14) | def FNV(self, data):
    method Add (line 23) | def Add(self, data):
    method IsPossiblyIn (line 30) | def IsPossiblyIn(self, data):
    method ComputeCollisionRate (line 37) | def ComputeCollisionRate(self):
    method __init__ (line 43) | def __init__(self):

FILE: data_structures/circular_queue/cpp/circular queue.cpp
  class queue1 (line 5) | class queue1
    method element (line 13) | void element()
    method inqueue (line 19) | void inqueue()
    method dequeue (line 47) | void dequeue()
    method display (line 76) | void display()
  function main (line 85) | int main()

FILE: data_structures/circular_queue/java/circular_queue.java
  type queue1 (line 3) | interface queue1
    method insert (line 5) | void insert();
    method delete (line 6) | void delete();
    method display (line 7) | void display();
  class myqueue1 (line 10) | class myqueue1 implements queue1
    method insert (line 15) | public void insert()
    method delete (line 25) | public void delete()
    method display (line 39) | public void display()
  class tut7 (line 48) | class tut7
    method main (line 50) | public static void main(String args[])

FILE: data_structures/circular_queue/python/circular_queue.py
  class CircularQueue (line 1) | class CircularQueue:
    method __init__ (line 3) | def __init__(self):
    method enqueue (line 9) | def enqueue(self, element):
    method dequeue (line 16) | def dequeue(self):
    method size (line 23) | def size(self):

FILE: data_structures/d_heap/c/d_heap.c
  function HEAP (line 6) | HEAP *init(int d){
  function parent_index (line 15) | int parent_index(int n, int d){
  function child_index (line 19) | int child_index(int n, int d, int i){
  function push (line 23) | void push(HEAP *heap, int value){
  function min_heapify (line 38) | void min_heapify(int n, HEAP *heap){
  function pop (line 56) | int pop(HEAP *heap){
  function short_print (line 70) | void short_print(HEAP *heap){
  function print (line 78) | void print(HEAP *heap){
  function destroy (line 93) | void destroy(HEAP *heap){

FILE: data_structures/dimaeter_of_a_tree/cpp/Diameter.cpp
  type tree (line 5) | struct tree{
    type tree (line 7) | struct tree
  type tree (line 9) | struct tree
    type tree (line 7) | struct tree
  function newnode (line 11) | void newnode(int n)
  function max (line 46) | int max(int a,int b)
  function height (line 53) | int height(node* temp)
  function diameter (line 58) | int diameter(node* temp)
  function main (line 72) | int main()

FILE: data_structures/dimaeter_of_a_tree/java/Diameter.java
  class Diameter (line 4) | class Diameter{
    method Diameter (line 7) | public Diameter(Node root){
    method c_diameter (line 11) | public static int c_diameter(Node node){
    method c_height (line 30) | public static int c_height(Node node){
    method main (line 41) | public static void main(String[] args){

FILE: data_structures/double_linked_list/cpp/doublelinkedlist.cpp
  type student (line 5) | struct student{
  function insertion_begin (line 11) | void insertion_begin(int y){
  function insertion_end (line 30) | void insertion_end(int y){
  function insertion_after (line 48) | void insertion_after(int y1){
  function insertion_before (line 65) | void insertion_before(int y2){
  function FindLocation (line 81) | void FindLocation(int k2){
  function display (line 97) | void display()
  function main (line 106) | int main()

FILE: data_structures/doubly_linked_list/java/DoublyLinkedList.java
  class Node (line 4) | class Node{
    method Node (line 10) | public Node() {  // initialize new node
    method Node (line 17) | public Node(int d) {
    method setNextLink (line 24) | public void setNextLink(Node link) {
    method setPrevLink (line 29) | public void setPrevLink(Node link) {
    method getNextLink (line 34) | public Node getNextLink() {
    method getPrevLink (line 39) | public Node getPrevLink() {
    method getData (line 44) | public int getData() {
  class LinkList (line 51) | class LinkList{
    method LinkList (line 58) | public LinkList() {
    method addAtStart (line 65) | public void addAtStart(int data) {
    method addAtEnd (line 85) | public void addAtEnd(int data) {
    method addAtMiddle (line 106) | public void addAtMiddle(int data , int pos) {
    method addAfterData (line 127) | public void addAfterData(int data , int refData) {
    method deleteNode (line 148) | public void deleteNode(int refData) {
    method showDataFromLeft (line 168) | public void showDataFromLeft() {
    method showDataFromRight (line 181) | public void showDataFromRight() {
  class DoublyLinkedList (line 196) | public class DoublyLinkedList {
    method main (line 198) | public static void main(String[] args) {

FILE: data_structures/doubly_linked_list/python/DoublyLinkedList.py
  class Li2st (line 2) | class Li2st:
    method __init__ (line 4) | def __init__(self,data = None):
    method __str__ (line 7) | def __str__(self):
    method isEmpty (line 15) | def isEmpty(self):
    method append (line 18) | def append(self,data):
    method addHead (line 27) | def addHead(self,data):
    method isIn (line 32) | def isIn(self,data):
    method before (line 42) | def before(self,data):
    method remove (line 60) | def remove(self,index):
    method removeTail (line 63) | def removeTail(self):
    method removeHead (line 68) | def removeHead(self):
    method get (line 71) | def get(self,index):
    method insert (line 80) | def insert(self,node,index):

FILE: data_structures/generic_tree/java/gt.java
  class generictree (line 9) | public class generictree {
    class node (line 10) | private class node {
      method node (line 14) | public node(int data) {
    method generictree (line 23) | public generictree() {
    method takeinput (line 28) | private node takeinput(Scanner scn, node parent, int ithchild) {
    method size (line 46) | public int size() {
    method isempty (line 50) | public boolean isempty() {
    method display (line 54) | public void display() {
    method toString (line 58) | @Override
    method toString (line 63) | private String toString(node node) {
    method max (line 76) | public int max (){
    method max (line 79) | private int max (node Node){
    method find (line 89) | public boolean find(int data){
    method find (line 92) | private boolean find(int data,node Node){
    method height (line 104) | public int height(){
    method height (line 107) | private int height(node node){

FILE: data_structures/graph/cpp/graph.cpp
  class graph (line 7) | class graph
    method graph (line 15) | graph()
    method graph (line 21) | graph(int ver,int e)
    method addedge (line 30) | void addedge(int a,int b,int dir)
    method printedges (line 38) | void printedges()
  function main (line 51) | int main()

FILE: data_structures/graph/python/graph.py
  class vertex (line 1) | class vertex:
    method __init__ (line 2) | def __init__(self,key):
    method addNeighbor (line 6) | def addNeighbor(self,neighbour,weight=0):
    method __str__ (line 9) | def __str__(self):
    method getConnections (line 12) | def getConnections(self):
    method getId (line 15) | def getId(self):
    method getWeight (line 18) | def getWeight(self,nbr):
  class Graph (line 23) | class Graph:
    method __init__ (line 24) | def __init__(self):
    method add_vertex (line 28) | def add_vertex(self,key):
    method get_vertex (line 34) | def get_vertex(self,n):
    method __contains__ (line 40) | def __contains__(self,n):
    method add_edge (line 43) | def add_edge(self,f,t,cost=0):
    method get_vertices (line 50) | def get_vertices(self):
    method __iter__ (line 53) | def __iter__(self):
    method __del__ (line 56) | def __del__(self):

FILE: data_structures/hash_table/cpp/hashtable.h
  function insert (line 30) | void insert(Key key, T val)
  function remove (line 47) | void remove(Key key)
  function T (line 63) | T get(Key key)
  function printTable (line 77) | void printTable()
  function isEmpty (line 96) | inline bool isEmpty() { return used == 0; }
  function contains (line 100) | bool contains(Key key) { return !(get(key) == nullptr); }
  function size (line 103) | inline int size() { return used; }
  function hash (line 113) | size_t hash(Key key) { return (prehash(key) & 0x7fffffff) % length; }

FILE: data_structures/hash_table/csharp/hash_table.cs
  class hTable (line 12) | sealed class hTable // a class
    method add (line 17) | internal void add(string value)
    method delete (line 36) | internal void delete(int key)
    method show (line 48) | internal void show()
  class Program (line 57) | class Program
    method Main (line 59) | static void Main(string[] args)

FILE: data_structures/hash_table/java/Hash_table.java
  class HashTable (line 3) | public class HashTable<K, V> {
    class HTPair (line 4) | private class HTPair {
      method HTPair (line 8) | public HTPair(K key, V value) {
      method equals (line 13) | public boolean equals(Object other) {
      method toString (line 18) | public String toString() {
    method HashTable (line 28) | public HashTable() {
    method HashTable (line 32) | public HashTable(int capacity) {
    method size (line 37) | public int size() {
    method HashFunction (line 41) | private int HashFunction(K key) {
    method put (line 48) | public void put(K key, V value) throws Exception {
    method display (line 74) | public void display() {
    method get (line 84) | public V get(K key) throws Exception {
    method remove (line 101) | public V remove(K key) throws Exception {
    method rehash (line 120) | public void rehash() throws Exception {

FILE: data_structures/hash_table/python/hashTable.py
  class hashTable (line 1) | class hashTable:
    method __init__ (line 2) | def __init__(self):
    method hashfunction (line 7) | def hashfunction(self, key, size): # remainder used to define slots
    method rehash (line 10) | def rehash(self, oldhash, size): # just a simple linear probing functi...
    method insert (line 13) | def insert(self, key, data):
    method get (line 28) | def get(self, key):
    method __getitem__ (line 45) | def __getitem__(self,key):
    method __setitem__ (line 48) | def __setitem__(self,key,data):

FILE: data_structures/hashmap/java/hashmap.java
  class hashmap (line 2) | class hashmap {
    method main (line 4) | public static void main(String args[]) {

FILE: data_structures/hashset/java/hashset.java
  class hashset (line 2) | class hashset {
    method main (line 4) | public static void main(String args[]) {

FILE: data_structures/heap/cpp/MinHeap.h
  function class (line 5) | class MinHeap
  function push (line 35) | void MinHeap::push(int element)
  function pop (line 41) | int MinHeap::pop()
  function siftUp (line 51) | void MinHeap::siftUp(int index)
  function siftDown (line 64) | void MinHeap::siftDown(int index)
  function left (line 82) | int MinHeap::left(int parent)
  function right (line 88) | int MinHeap::right(int parent)
  function parent (line 94) | int MinHeap::parent(int child)

FILE: data_structures/heap/java/Heap.java
  class Heap (line 5) | public class Heap<T extends Comparable<T>> {
    method Heap (line 9) | public Heap(){
    method Heap (line 13) | public Heap(boolean isMin){
    method Heap (line 18) | public Heap(T[] arr,boolean isMin){
    method size (line 29) | public int size(){
    method getHP (line 33) | public T getHP(){
    method add (line 37) | public void add(T item){
    method upheapify (line 42) | private void upheapify(int ci){
    method swap (line 55) | private void swap(int i,int j){
    method isLarger (line 61) | private boolean isLarger(int i,int j){
    method remove (line 71) | public T remove(){
    method downheapify (line 79) | private void downheapify(int pi){
    method display (line 95) | public void display(){
    method display (line 99) | private void display(int index){

FILE: data_structures/heap/java/heaps.java
  class heaps (line 5) | public class heaps<k extends Comparable<k>, v> {
    class node (line 6) | private class node implements Comparable<node> {
      method node (line 10) | node(k score, v value) {
      method toString (line 15) | public String toString() {
      method compareTo (line 19) | @Override
    method heaps (line 32) | public heaps() {
    method heaps (line 36) | public heaps(boolean ismin) {
    method size (line 41) | public int size() {
    method isempty (line 45) | public boolean isempty() {
    method add (line 49) | public void add(k score, v value) {
    method upheapify (line 55) | private void upheapify(int ci) {
    method removehp (line 68) | public v removehp() {
    method downheapify (line 76) | private void downheapify(int pi) {
    method gethp (line 91) | public v gethp() {
    method display (line 95) | public void display() {
    method toString (line 99) | public String toString() {
    method displaytree (line 103) | public void displaytree() {
    method treestring (line 108) | private String treestring(int pi) {
    method swap (line 131) | private void swap(int i, int j) {

FILE: data_structures/heap/python/minheap.py
  class Heap (line 3) | class Heap(object):
    method __init__ (line 4) | def __init__(self):
    method push (line 7) | def push(self, priority, item):
    method pop (line 11) | def pop(self):
    method __len__ (line 15) | def __len__(self):
    method __iter__ (line 18) | def __iter__(self):
    method next (line 21) | def next(self):

FILE: data_structures/heap/ruby/heap.rb
  class Heap (line 1) | class Heap
    method initialize (line 2) | def initialize
    method push (line 6) | def push(data)
    method top (line 11) | def top
    method pop (line 15) | def pop
    method size (line 26) | def size
    method tear_up (line 32) | def tear_up(pos)
    method tear_down (line 42) | def tear_down(pos)

FILE: data_structures/heapify_insert_extract_min/cpp/max-heap_functions.cpp
  function main (line 18) | int main()
  function heapify (line 115) | void heapify(int k,int arr[])
  function insert (line 146) | void insert(int t,int arr[])
  function extract_max (line 161) | int extract_max(int arr[])

FILE: data_structures/left_learning_red_black_tree/c/llrb_tree.c
  type treenode (line 6) | struct treenode
  type TREENODE (line 15) | typedef struct treenode TREENODE;
  type TREENODE (line 16) | typedef TREENODE *TREE;
  function main (line 32) | int main()
  function TREE (line 64) | TREE make_tree(int data, TREE left, TREE right)
  function is_red (line 77) | bool is_red(TREE t)
  function is_empty (line 85) | int is_empty(TREE t)
  function TREE (line 90) | TREE left_subtree(TREE t)
  function TREE (line 95) | TREE right_subtree(TREE t)
  function size (line 100) | size_t size(TREE t)
  function max (line 111) | size_t max(size_t x, size_t y)
  function height (line 117) | size_t height(TREE t)
  function preorder (line 127) | void preorder(TREE t)
  function inorder (line 137) | void inorder(TREE t)
  function postorder (line 147) | void postorder(TREE t)
  function print_leaf (line 157) | void print_leaf(TREE t)
  function rotate_left (line 171) | void rotate_left(TREE *t)
  function rotate_right (line 186) | void rotate_right(TREE *t)
  function flip_color (line 201) | void flip_color(TREE *t)
  function insert_RB (line 208) | void insert_RB(TREE *t, int data)
  function search_RB (line 229) | int search_RB(TREE t, int key)

FILE: data_structures/left_learning_red_black_tree/java/left_leaning_red_black_tree.java
  class left_leaning_red_black_tree (line 2) | public class left_leaning_red_black_tree<Key extends Comparable<Key>, Va...
    class Node (line 7) | private class Node {
      method Node (line 12) | Node(Key key, Value val) {
    method search (line 19) | public Value search(Key key) {
    method insert (line 30) | public void insert(Key key, Value value) {
    method insert (line 35) | private Node insert(Node h, Key key, Value value) {
    method isRed (line 47) | private boolean isRed(Node h) {
    method colorFlip (line 52) | void colorFlip(Node h) {
    method rotateLeft (line 58) | private Node rotateLeft(Node h) {
    method rotateRight (line 67) | private Node rotateRight(Node h) {
    method preorder (line 76) | public void preorder() {
    method preorder (line 80) | private void preorder(Node root) {
    method inorder (line 87) | public void inorder() {
    method inorder (line 91) | private void inorder(Node root) {
    method postorder (line 98) | public void postorder() {
    method postorder (line 102) | private void postorder(Node root) {
    method main (line 109) | public static void main(String[] args) {

FILE: data_structures/linked_list/c/linked_list.c
  type node (line 5) | struct node
  function main (line 11) | int main()
  function create (line 41) | void create()
  function insert (line 68) | void insert()
  function delete (line 110) | void delete()
  function search (line 149) | void search()
  function display (line 175) | void display()

FILE: data_structures/linked_list/cpp/LinkedList.cpp
  type node (line 11) | struct node
    type node (line 14) | struct node
  class single_llist (line 20) | class single_llist
    method single_llist (line 33) | single_llist()
  function main (line 42) | main()
  function node (line 123) | node *single_llist::create_node(int value)
    type node (line 14) | struct node
  type node (line 148) | struct node
    type node (line 14) | struct node
  type node (line 172) | struct node
    type node (line 14) | struct node
  type node (line 192) | struct node
    type node (line 14) | struct node
  type node (line 239) | struct node
    type node (line 14) | struct node
  type node (line 275) | struct node
    type node (line 14) | struct node
  type node (line 322) | struct node
    type node (line 14) | struct node
  type node (line 358) | struct node
    type node (line 14) | struct node
  type node (line 379) | struct node
    type node (line 14) | struct node
  type node (line 409) | struct node
    type node (line 14) | struct node

FILE: data_structures/linked_list/cpp/singly_linked_list.cpp
  type std (line 2) | namespace std{
    class Node (line 4) | class Node{
      method Node (line 10) | Node(){}
      method setData (line 12) | void setData(int Data){ _data = Data;}
      method setNext (line 13) | void setNext(Node *Next){
      method Data (line 20) | int Data(){return _data;}
      method Node (line 21) | Node *Next(){return _next;}
    class LinkedList (line 24) | class LinkedList{
      method LinkedList (line 28) | LinkedList(){ head = NULL;}
  function main (line 115) | int main(){

FILE: data_structures/linked_list/csharp/LinkedList.cs
  class LinkedList (line 13) | class LinkedList
    class LinkedListNode (line 19) | public class LinkedListNode
      method LinkedListNode (line 24) | public LinkedListNode(object newitem)
      method LinkedListNode (line 29) | public LinkedListNode(object newitem, LinkedListNode next)
      method getData (line 35) | public object getData()
      method getNextNode (line 40) | public LinkedListNode getNextNode()
      method setNextNode (line 45) | public void setNextNode(LinkedListNode next)
    method LinkedList (line 53) | public LinkedList(object data)
    method addFirst (line 59) | public void addFirst(object data)
    method addLast (line 65) | public void addLast(object data)
    method insertAfter (line 83) | public void insertAfter(object data, object newData)
    method insertBefore (line 98) | public void insertBefore(object data, object newData)
    method remove (line 126) | public void remove(object data)

FILE: data_structures/linked_list/go/linked_list.go
  type Node (line 5) | type Node struct
    method Next (line 10) | func (n *Node) Next() *Node {
  type LinkedList (line 14) | type LinkedList struct
    method Add (line 19) | func (l *LinkedList) Add(v interface{}) {
    method First (line 31) | func (l *LinkedList) First() *Node {
    method ToString (line 35) | func (l *LinkedList) ToString() string {
  function main (line 48) | func main() {

FILE: data_structures/linked_list/java/LinkedList.java
  class Node (line 8) | class Node
    method Node (line 14) | public Node()
    method Node (line 20) | public Node(int d,Node n)
    method setLink (line 26) | public void setLink(Node n)
    method setData (line 31) | public void setData(int d)
    method getLink (line 36) | public Node getLink()
    method getData (line 41) | public int getData()
  class linkedList (line 48) | class linkedList
    method linkedList (line 55) | public linkedList()
    method isEmpty (line 62) | public boolean isEmpty()
    method getSize (line 67) | public int getSize()
    method insertAtStart (line 72) | public void insertAtStart(int val)
    method insertAtEnd (line 88) | public void insertAtEnd(int val)
    method insertAtPos (line 104) | public void insertAtPos(int val , int pos)
    method deleteAtPos (line 123) | public void deleteAtPos(int pos)
    method display (line 161) | public void display()
  class SinglyLinkedList (line 187) | public class SinglyLinkedList
    method main (line 189) | public static void main(String[] args)

FILE: data_structures/linked_list/java/LinkedListLinkedList.java
  class LinkedList (line 7) | public class LinkedList<E> {
    method LinkedList (line 15) | public LinkedList(){
    method add (line 25) | public boolean add(E element){
    method remove (line 50) | public boolean remove(E element){
    method contains (line 68) | public boolean contains(E element) {
    method head (line 83) | public E head(){
    method tail (line 91) | public E tail(){
    method size (line 99) | public int size(){
    class Node (line 108) | private class Node{
      method Node (line 113) | public Node(E element){

FILE: data_structures/linked_list/java/LinkedListTest.java
  class LinkedListTest (line 10) | public class LinkedListTest {
    method testLinkedList (line 11) | @Test

FILE: data_structures/linked_list/python/linked_list.py
  class Node (line 1) | class Node:
    method __init__ (line 2) | def __init__(self, data=None, next_node=None):
    method __repr__ (line 7) | def __repr__(self):
  class LinkedList (line 11) | class LinkedList:
    method __init__ (line 16) | def __init__(self, data_iterable):
    method add (line 21) | def add(self, data):
    method search (line 28) | def search(self, data):
    method remove (line 36) | def remove(self, node):
    method __repr__ (line 44) | def __repr__(self):

FILE: data_structures/linked_list/ruby/linked_list.rb
  class Node (line 1) | class Node
    method initialize (line 5) | def initialize(data, next_node = nil)
  class LinkedList (line 11) | class LinkedList
    method initialize (line 12) | def initialize
    method insertFront (line 17) | def insertFront(data)
    method insertBack (line 23) | def insertBack(data)
    method find (line 30) | def find(data)
    method remove (line 39) | def remove(node)
    method iterate (line 60) | def iterate

FILE: data_structures/linked_list_queue/cpp/queue_linked_list.cpp
  type QueueNode (line 6) | struct QueueNode {
  class CQueue (line 19) | class CQueue {
    method enqueue (line 27) | void enqueue(T value) {
    method T (line 39) | T dequeue() {
    method isEmpty (line 52) | bool isEmpty() {
  function main (line 63) | int main() {

FILE: data_structures/min_heap/cpp/impl_minHeap.cpp
  function main (line 16) | int main(){

FILE: data_structures/min_heap/cpp/minHeap.cpp
  function getLeftIndex (line 15) | int getLeftIndex(int x){
  function getRightIndex (line 19) | int getRightIndex(int x){
  function getParentIndex (line 23) | int getParentIndex(int x){

FILE: data_structures/min_heap/cpp/minHeap.hpp
  class MinHeap (line 10) | class MinHeap{

FILE: data_structures/mirror_of_a_tree.java/java/Mirror.java
  class Mirror (line 1) | class Mirror{
    method mirror (line 5) | public void mirror(Node node){
    method printTree (line 19) | public void printTree(Node node){
    method main (line 30) | public static void main(String[] args){

FILE: data_structures/mirrot_of_a_tree.cpp/mirror.cpp
  type btree (line 7) | struct btree {
    type btree (line 9) | struct btree
    type btree (line 10) | struct btree
  function btree (line 13) | btree *makeTree(btree *root , int d) {
    type btree (line 9) | struct btree
    type btree (line 10) | struct btree
  function btree (line 42) | btree *mirror(btree *root) {
    type btree (line 9) | struct btree
    type btree (line 10) | struct btree
  function printTreeLevelOrder (line 53) | void printTreeLevelOrder(btree *root) {
  function main (line 66) | int main()

FILE: data_structures/mst/cpp/mst.cpp
  function minKey (line 12) | int minKey(int key[], bool mstSet[])
  function printMST (line 25) | int printMST(int parent[], int n, int graph[V][V])
  function primMST (line 34) | void primMST(int graph[V][V])
  function main (line 76) | int main()

FILE: data_structures/mst/java/prims.java
  class PrimMST (line 1) | public class PrimMST {
    method PrimMST (line 13) | public PrimMST(EdgeWeightedGraph G) {
    method prim (line 29) | private void prim(EdgeWeightedGraph G, int s) {
    method scan (line 39) | private void scan(EdgeWeightedGraph G, int v) {
    method edges (line 58) | public Iterable<Edge> edges() {
    method weight (line 73) | public double weight() {
    method check (line 82) | private boolean check(EdgeWeightedGraph G) {
    method main (line 145) | public static void main(String[] args) {

FILE: data_structures/priority_queue/c/priority_queue.cpp
  type node (line 3) | struct node{
    type node (line 5) | struct node
  type node (line 7) | struct node
    type node (line 5) | struct node
  function enque (line 9) | void enque(int data,int priority)
  function deque (line 19) | void deque()
  function display (line 45) | void display()
  function main (line 61) | int main()

FILE: data_structures/queue/c/queue.c
  function main (line 7) | int main()
  function push (line 33) | void push()
  function pop (line 49) | void pop()
  function display (line 61) | void display()

FILE: data_structures/queue/cpp/Queue.cpp
  function T (line 32) | T* Queue<T>::Front()

FILE: data_structures/queue/cpp/Queue.h
  type Node (line 9) | struct Node

FILE: data_structures/queue/csharp/Queue.cs
  class Queue (line 9) | class Queue
    method dequeue (line 14) | public Object dequeue()
    method peek (line 29) | public Object peek()
    method enqueue (line 42) | public void enqueue(Object newItem)
    method isEmpty (line 48) | public bool isEmpty()

FILE: data_structures/queue/go/queue.go
  type queue (line 5) | type queue struct
    method Enqueue (line 13) | func (q *queue) Enqueue(value interface{}) {
    method Dequeue (line 17) | func (q *queue) Dequeue() (interface{}) {
  function NewQueue (line 9) | func NewQueue() queue {
  function main (line 23) | func main() {

FILE: data_structures/queue/java/IterableQueue.java
  class IterableQueue (line 4) | public class IterableQueue<E> implements Iterable<E> {
    class Node (line 10) | private static class Node<E> {
    method IterableQueue (line 18) | public IterableQueue() {
    method isEmpty (line 29) | public boolean isEmpty() {
    method size (line 38) | public int size() {
    method peek (line 48) | public E peek() {
    method enqueue (line 58) | public void enqueue(E element) {
    method dequeue (line 74) | public E dequeue() {
    method toString (line 88) | public String toString() {
    method iterator (line 102) | public Iterator<E> iterator()  {
    class ListIterator (line 107) | private class ListIterator<Item> implements Iterator<Item> {
      method ListIterator (line 110) | public ListIterator(Node<Item> first) {
      method hasNext (line 114) | public boolean hasNext()  { return current != null;                 ...
      method remove (line 115) | public void remove()      { throw new UnsupportedOperationException(...
      method next (line 117) | public Item next() {

FILE: data_structures/queue/javascript/queue_ES5.js
  function Queue (line 1) | function Queue() {

FILE: data_structures/queue/javascript/queue_ES6.js
  class Queue (line 1) | class Queue {
    method constructor (line 2) | constructor() {
    method size (line 8) | size() {
    method enqueue (line 12) | enqueue(data) {
    method dequeue (line 17) | dequeue() {

FILE: data_structures/queue/php/queue.php
  class Queue (line 8) | class Queue {
    method __construct (line 18) | public function __construct($data = null){
    method size (line 29) | public function size(){
    method enqueue (line 36) | public function enqueue($item){
    method dequeue (line 44) | public function dequeue(){

FILE: data_structures/queue/python/queue_two_stacks.py
  function get_command (line 1) | def get_command():
  class Stack (line 15) | class Stack:
    method __init__ (line 16) | def __init__(self):
    method __len__ (line 19) | def __len__(self):
    method push (line 22) | def push(self, data):
    method pop (line 25) | def pop(self):
    method top (line 28) | def top(self):
  class Queue (line 34) | class Queue:
    method __init__ (line 35) | def __init__(self):
    method enqueue (line 39) | def enqueue(self, data):
    method dequeue (line 42) | def dequeue(self):
    method peek (line 48) | def peek(self):
    method _tail_to_head (line 54) | def _tail_to_head(self):
  function main (line 61) | def main():

FILE: data_structures/queue/ruby/queue.rb
  class Queue (line 1) | class Queue
    method initialize (line 2) | def initialize
    method enqueue (line 6) | def enqueue(data)
    method dequeue (line 10) | def dequeue()
    method front (line 15) | def front()
    method back (line 20) | def back()
    method size (line 24) | def size()

FILE: data_structures/simple_queue/java/QueueImplementation.java
  class QueueImplementation (line 4) | public class QueueImplementation
    method main (line 6) | public static void main(String[] args)

FILE: data_structures/simple_queue/java/arrayQueue.java
  class arrayQueue (line 8) | class arrayQueue {
    method arrayQueue (line 13) | public arrayQueue(int n)
    method isEmpty (line 22) | public boolean isEmpty()
    method isFull (line 27) | public boolean isFull()
    method getSize (line 32) | public int getSize()
    method peek (line 37) | public int peek()
    method insert (line 44) | public void insert(int i)
    method remove (line 59) | public int remove()
    method display (line 78) | public void display()

FILE: data_structures/simple_queue/java/queue.java
  type queue (line 2) | interface queue
    method insert (line 4) | void insert();
    method delete (line 5) | void delete();
    method display (line 6) | void display();
  class myqueue (line 9) | class myqueue implements queue
    method insert (line 14) | public void insert()
    method delete (line 27) | public void delete()
    method display (line 39) | public void display()
  class tut6 (line 48) | class tut6
    method main (line 50) | public static void main(String args[])

FILE: data_structures/simple_queue/python/queue.py
  class Queue (line 1) | class Queue:
    method __init__ (line 2) | def __init__(self):
    method enqueue (line 5) | def enqueue(self, item):
    method dequeue (line 8) | def dequeue(self):
    method peek (line 11) | def peek(self):

FILE: data_structures/stack/c#/main.cs
  class main (line 4) | public class main{
    method Main (line 5) | static void Main(){

FILE: data_structures/stack/c#/stack.cs
  class Stack (line 5) | public class Stack<t>  {
    method Stack (line 10) | public Stack(){
    method Push (line 17) | public void Push(t data){
    method Pop (line 22) | public void Pop(){
    method Top (line 25) | public t Top(){

FILE: data_structures/stack/c/stack1.c
  type node (line 5) | struct node{
  type node (line 10) | struct node
  function insertatthebegin (line 11) | void insertatthebegin(int x)
  function print (line 21) | void print()
  function reverse (line 39) | void reverse()
  function main (line 57) | int main()

FILE: data_structures/stack/cpp/celement.h
  type CElement (line 7) | struct CElement {

FILE: data_structures/stack/cpp/cstack.h
  function class (line 8) | class CStack

FILE: data_structures/stack/cpp/cstack.test.cpp
  function main (line 6) | int main()

FILE: data_structures/stack/cpp/stack_balanced_paranthesis.cpp
  function main (line 6) | int main()

FILE: data_structures/stack/cpp/templated_stack.cpp
  function main (line 12) | int main(void) {

FILE: data_structures/stack/cpp/templated_stack.hpp
  class Stack (line 12) | class Stack {
    class Node (line 14) | class Node {
      method Node (line 20) | Node(const Object & d, Node * n):
    method Stack (line 29) | Stack() {  }
    method size (line 33) | int size() {
    method push (line 38) | void push(const Object & value) {
    method Object (line 44) | Object top() {
    method pop (line 51) | void pop() {
    method empty (line 63) | bool empty() {
    method clear (line 68) | void clear() {

FILE: data_structures/stack/csharp/Stack.cs
  class Stack (line 9) | class Stack
    method pop (line 13) | public Object pop()
    method push (line 28) | public void push(Object newItem)
    method isEmpty (line 34) | public bool isEmpty()

FILE: data_structures/stack/go/stack.go
  type stack (line 3) | type stack struct
    method Push (line 7) | func (s *stack) Push(value interface{}) {
    method Pop (line 11) | func (s *stack) Pop() interface{} {

FILE: data_structures/stack/java/Node.java
  class Node (line 3) | public class Node<T>{
    method Node (line 9) | public Node(T data){
    method Node (line 16) | public Node(){
    method getData (line 23) | public T getData(){
    method setData (line 27) | public void setData(T data){
    method getIndex (line 31) | public int getIndex(){
    method setNext (line 35) | public void setNext(Node node){
    method getNext (line 39) | public Node getNext(){
    method setPreview (line 43) | public void setPreview(Node node){
    method getPreview (line 47) | public Node getPreview(){

FILE: data_structures/stack/java/Stack.java
  class Stack (line 3) | public class Stack<T>{
    method Stack (line 7) | public Stack(){
    method isEmpty (line 12) | public boolean isEmpty(){
    method push (line 16) | public void push(T data){
    method top (line 29) | public T top(){
    method pop (line 36) | public void pop(){
    method viewStack (line 51) | public void viewStack(){
    method main (line 63) | public static void main(String[] args) {

FILE: data_structures/stack/java/integer_stack.java
  class Stack (line 4) | public class Stack {
    method Stack (line 7) | public Stack(){
    method Push (line 10) | public void Push(int val){
    method Pop (line 15) | public void Pop(){
    method Top (line 22) | public int Top(){
    method isEmpty (line 25) | private boolean isEmpty(){

FILE: data_structures/stack/javascript/stack.js
  function Stack (line 2) | function Stack(maxSize = null) {

FILE: data_structures/stack/php/stack.php
  class Stack (line 2) | class Stack {
    method Pop (line 5) | public function Pop(){
    method Push (line 12) | public function Push($data) {
    method Top (line 17) | public function Top(){

FILE: data_structures/stack/python/stack.py
  class Stack (line 1) | class Stack:
    method __init__ (line 2) | def __init__(self):
    method push (line 5) | def push(self, item):
    method pop (line 8) | def pop(self):
    method peek (line 11) | def peek(self):

FILE: data_structures/stack/ruby/stack.rb
  class Stack (line 1) | class Stack
    method initialize (line 2) | def initialize
    method push (line 6) | def push(data)
    method pop (line 10) | def pop()
    method top (line 15) | def top()
    method size (line 20) | def size()

FILE: data_structures/treemap/java/treemap.java
  class treemap (line 2) | class treemap {
    method main (line 4) | public static void main(String args[]) {

FILE: data_structures/treeset/java/treeset.java
  class treeset (line 2) | class treeset {
    method main (line 4) | public static void main(String args[]) {

FILE: data_structures/trie/java/Trie.java
  class Trie (line 3) | public class Trie {
    class TrieNode (line 4) | public class TrieNode {
      method TrieNode (line 8) | public TrieNode() {
    method main (line 13) | public static void main(String[] args) {
    method demo (line 17) | private void demo() {
    method displayTree (line 32) | private void displayTree(TrieNode trie) {
    method DFS (line 41) | private void DFS(TrieNode n, StringBuilder sb, int index) {
    method add (line 56) | private void add(TrieNode trie, String s) {
    method getCharacter (line 68) | public Character getCharacter(int index) {
    method getIndex (line 72) | public Integer getIndex(Character c) {

FILE: data_structures/trie/javascript/Trie.js
  class Node (line 1) | class Node {
    method constructor (line 2) | constructor(){
    method setEnd (line 7) | setEnd(isEnd) {
    method addChild (line 11) | addChild(value) {
  class Trie (line 22) | class Trie {
    method constructor (line 23) | constructor() {
    method findPrefix (line 27) | findPrefix(prefix, parent) {
    method addWord (line 42) | addWord(word, parent = this.root) {
    method list (line 54) | list(root = this.root, word = [], words = []) {

FILE: data_structures/union_find/cpp/UnionFind.cpp
  class UnionFind (line 5) | class UnionFind{
    method root (line 11) | int root(int p){
    method UnionFind (line 22) | UnionFind(int N){
    method unionElem (line 31) | void unionElem(int p, int q){
    method connected (line 47) | bool connected(int p, int q){
    method getComponents (line 52) | int getComponents(){
  function main (line 57) | int main(){

FILE: data_structures/union_find/java/UnionFind.java
  class UnionFind (line 2) | class UnionFind{
    method UnionFind (line 8) | public UnionFind(int n){
    method root (line 19) | private int root(int p){
    method union (line 28) | public void union(int p, int q){
    method connected (line 44) | public boolean connected(int p, int q){
    method getComponents (line 49) | public int getComponents(){
  class Main (line 54) | class Main {
    method main (line 55) | public static void main(String[] args){

FILE: data_structures/union_find/python/UnionFind.py
  function find (line 2) | def find(data, i):
  function union (line 8) | def union(data, i, j):
  function connected (line 14) | def connected(data, i, j):
Condensed preview — 313 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (547K chars).
[
  {
    "path": ".gitignore",
    "chars": 35,
    "preview": "*.out\njavascript/node_modules\n.idea"
  },
  {
    "path": ".vscode/settings.json",
    "chars": 53,
    "preview": "{\n  \"files.associations\": {\n    \"vector\": \"cpp\"\n  }\n}"
  },
  {
    "path": "CONTRIBUTING.md",
    "chars": 988,
    "preview": "# Contributing to this repo\n**Implementing new File/Directory Structure**\n* Try to keep things as modular as possible, t"
  },
  {
    "path": "LICENSE",
    "chars": 35141,
    "preview": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
  },
  {
    "path": "README.md",
    "chars": 1295,
    "preview": "# Hacktoberfest-Data-Structure-and-Algorithms\nA repository containing data structures and algorithms, regardless of lang"
  },
  {
    "path": "algorithms/EuclideanAlgorithm/c/euclid.c",
    "chars": 231,
    "preview": "#include<stdio.h>\n\nint gcd(int x, int y){\n\tif(x == 0)\n\t\treturn y;\n\treturn gcd(y % x, x);\n}\n\nvoid main(){\n\tint hcf, a, b;"
  },
  {
    "path": "algorithms/EuclideanAlgorithm/python/euclideanAlgorithm.py",
    "chars": 295,
    "preview": "def euclidean(a,b):#for natural numbers a,b\n  \n  #sanitize the inputs\n  a=int(a)\n  b=int(b)\n  \n  if(not(a and b)):#if ei"
  },
  {
    "path": "algorithms/Graph/connected_components_in_undirected_graph/python/ConnectedComponents.py",
    "chars": 1133,
    "preview": "'''\nQuestion source -- LeetCode\nGiven n nodes labeled from 0 to n - 1 and a list of undirected edges\n(where each edge is"
  },
  {
    "path": "algorithms/a_search/cpp/a_star.cpp",
    "chars": 23992,
    "preview": "// A C++ Program to implement A* Search Algorithm\n#include <bits/stdc++.h>\nusing namespace std;\n \n#define ROW 9\n#define "
  },
  {
    "path": "algorithms/backtracking/c/n_queens_problem.c",
    "chars": 2798,
    "preview": "/* C/C++ program to solve N Queen Problem using\n   backtracking */\n#define N 4\n#include<stdio.h>\n\n/* A utility function "
  },
  {
    "path": "algorithms/backtracking/c/rat_in_a_maze_problem.c",
    "chars": 2419,
    "preview": "/* C/C++ program to solve Rat in a Maze problem using\n   backtracking */\n#include<stdio.h>\n\n// Maze size\n#define N 4\n\nbo"
  },
  {
    "path": "algorithms/backtracking/c/sudoku_problem.c",
    "chars": 4142,
    "preview": "// A Backtracking program  in C++ to solve Sudoku problem\n#include <stdio.h>\n\n// UNASSIGNED is used for empty cells in s"
  },
  {
    "path": "algorithms/backtracking/c/the_knight_tour_problem.c",
    "chars": 2557,
    "preview": "// C program for Knight Tour problem\n#include<stdio.h>\n#define N 8\n\nint solveKTUtil(int x, int y, int movei, int sol[N]["
  },
  {
    "path": "algorithms/bellman_ford/cpp/bellman_ford.cpp",
    "chars": 1015,
    "preview": "/* 1. shortest path from source to vertices\n   2. can be used for negetive weights\n   3.can be used to detect neg cycle."
  },
  {
    "path": "algorithms/bellman_ford/java/BellmanFord.java",
    "chars": 1949,
    "preview": "import java.util.*;\n\nclass Graph\n{\n\tprivate class Edge {\n\t\tint src, dest, weight;\n\t\tprivate Edge(int src, int dest, int "
  },
  {
    "path": "algorithms/bfs/cpp/bfs.cpp",
    "chars": 1912,
    "preview": "\n#import <vector>\n#import <queue>\n#import <iostream>\n\nclass Vertex {\npublic:\n    Vertex(std::string n);\n\n    Vertex * pr"
  },
  {
    "path": "algorithms/bfs/java/Graph.java",
    "chars": 1497,
    "preview": "import java.util.*;\n\n/**\n * Represents a directed graph using adjacency list\n */\npublic class Graph {\n    private int ve"
  },
  {
    "path": "algorithms/binary_search/PHP/binarysearch.php",
    "chars": 779,
    "preview": "<?php\n/*\n * @Author: Sushma Kure\n * @ProblemStatement: Binary search in PHP\n */\n\nfunction binary_search( $sourceArr, $ke"
  },
  {
    "path": "algorithms/binary_search/binary_search.md",
    "chars": 2232,
    "preview": "## ELI5\n**Binary Serch** is a way of searching for a thing in a list of things. The list must be sorted, that is, it mus"
  },
  {
    "path": "algorithms/binary_search/c/binary_search.c",
    "chars": 828,
    "preview": "#include <stdio.h>\n\nint binarySearch(int arr[], int l, int r, int key) {\n  if (r >= l) {\n       int mid = l + (r - l)/2;"
  },
  {
    "path": "algorithms/binary_search/cpp/binary_search.cpp",
    "chars": 2757,
    "preview": "//saru95, cruxiu :)\n#include <iostream> /* cout and cin */\n#include <chrono> /* steady_clock::now */\n\nbool binarySearchI"
  },
  {
    "path": "algorithms/binary_search/java/binarysearch.java",
    "chars": 1306,
    "preview": "// Java implementation of Binary Search\nclass BinarySearch\n{\n    // Returns index of x if it is present in arr[l..r], el"
  },
  {
    "path": "algorithms/binary_search/javascript/binary_search.js",
    "chars": 352,
    "preview": "function binarySearch(ar, el, compare_fn) {\n    var m = 0;\n    var n = ar.length - 1;\n    while (m <= n) {\n        var k"
  },
  {
    "path": "algorithms/binary_search/python/binary_search.py",
    "chars": 540,
    "preview": "#Simple implementation of the binary search\n\ndef b_search(a,s,start,end):\n    target = int((start+end)/2)\n    if start >"
  },
  {
    "path": "algorithms/binary_search/ruby/binary_search.rb",
    "chars": 371,
    "preview": "def binary_search(an_array, item)\n  first = 0\n  last = an_array.length - 1\n\n  while first <= last\n    i = (first + last)"
  },
  {
    "path": "algorithms/bipartite_check/cpp/bipartite.cpp",
    "chars": 617,
    "preview": "#include<bits/stdc++.h>\nusing namespace std;\nint col[100];\nint G[100][100];\nint nodes,edges;\nbool bipartite(int src)\n{\nc"
  },
  {
    "path": "algorithms/bitwise/cpp/generating_subsets.cpp",
    "chars": 507,
    "preview": "#include <iostream>\n#include <vector>\n\n#define pb push_back\n\nusing namespace std;\n\nint main(void)\n{\n    vector<int> v = "
  },
  {
    "path": "algorithms/bitwise/java/AddTwoNumbersWithoutPlusOperator.java",
    "chars": 389,
    "preview": "\npublic class AddTwoNumbersWithoutPlusOperator {\n    public static void main(String[] args) {\n        int a = 10;\n      "
  },
  {
    "path": "algorithms/bitwise/java/BinaryPalidrome.java",
    "chars": 1025,
    "preview": "public class BinaryPalidrome {\n    // check if binary representation of a number is palidrome\n    public static void mai"
  },
  {
    "path": "algorithms/bitwise/java/NegateANumberWithoutPlusOperator.java",
    "chars": 567,
    "preview": "public class NegateANumberWithoutPlusOperator {\n    public static void main(String[] args) {\n        NegateANumberWithou"
  },
  {
    "path": "algorithms/bitwise/java/Optimized_permutation",
    "chars": 122,
    "preview": "//Initial values\nint x = 0;\nint y = 1;\n//Optimzed permutation:\nx = x ^ y;\ny = x ^ y;\nx = x ^ y;\n//Yields: x = 1 and y = "
  },
  {
    "path": "algorithms/bitwise/java/Subsets.java",
    "chars": 695,
    "preview": "/**\n * Subsets of a set:\n * input: array of size of n elements\n * output: 2^n subsets\n */\n\npublic class Subsets {\n    pu"
  },
  {
    "path": "algorithms/bogo_sort/java/BogoSort.java",
    "chars": 504,
    "preview": "import java.util.Arrays;\nimport java.util.List;\nimport java.util.Collections;\n\npublic class BogoSort {\n\t\n\tpublic static "
  },
  {
    "path": "algorithms/bogo_sort/python/bogo.py",
    "chars": 309,
    "preview": "from random import *\n\nseed()\nx = []\nfor i in range(0, 10):\n    x.append(randint(0, 100))\n\ndef inorder(x):\n    i = 0\n    "
  },
  {
    "path": "algorithms/bogo_sort/ruby/bogo_sort.rb",
    "chars": 194,
    "preview": "def bogosort(arr)\n  arr.shuffle! while !arr.each_cons(2).all? do |x, y|\n    x <= y\n  end\nend\narray = [ 0, 5, 4, 3, 2, 8,"
  },
  {
    "path": "algorithms/breadth_first_search/cpp/bfs.cpp",
    "chars": 1832,
    "preview": "#include<iostream>\n#include <list>\n \nusing namespace std;\n \n// This class represents a directed graph using adjacency li"
  },
  {
    "path": "algorithms/bubble_sort/README.md",
    "chars": 267,
    "preview": "# Bubble Sort\n\nThis folder contains examples of the bubble sort algorithm in the following programming languages:\n\n* bas"
  },
  {
    "path": "algorithms/bubble_sort/assembly_mips/bubble_sort.asm",
    "chars": 5074,
    "preview": "## Data declaration section \n.data\n# these are globals\n  # array of word long ints\n  myarray:    .word 23, 4, 34, 55, 87"
  },
  {
    "path": "algorithms/bubble_sort/bash/bubblesort.sh",
    "chars": 417,
    "preview": "#!/bin/bash\necho \"enter maximum number\"\nread n\n\n\necho \"enter Numbers in array:\"\nfor (( i = 0; i < $n; i++ ))\ndo\nread nos"
  },
  {
    "path": "algorithms/bubble_sort/c/bubble_sort.c",
    "chars": 640,
    "preview": "//algorithm of bubble sort in c\n//start from the first elemnent \n/*1. start comparing it with the next element\n  2. swap"
  },
  {
    "path": "algorithms/bubble_sort/cpp/bubble_sort_1.cpp",
    "chars": 633,
    "preview": "#include<iostream>\nusing namespace std;\n\n//global variables for ease of use\nlong long int array[1000],n,temp;\n\n//functio"
  },
  {
    "path": "algorithms/bubble_sort/cpp/bubblesort.cpp",
    "chars": 614,
    "preview": "/* C++ Program - Bubble Sort */\n\n#include<iostream.h>\n#include<conio.h>\nvoid main()\n{\n\tclrscr();\n\tint n, i, arr[50], j, "
  },
  {
    "path": "algorithms/bubble_sort/crystal/bubble_sort.cr",
    "chars": 466,
    "preview": "def bubbleSort(array)\n  count = 0\n  while true\n    swapped = false\n    i = 0\n\n    while true\n      if array[i] > array[i"
  },
  {
    "path": "algorithms/bubble_sort/csharp/BubbleSort.cs",
    "chars": 1580,
    "preview": "using System;\nusing System.Collections.Generic;\n\n\npublic class BubbleSort {\n    private static void Main(string[] args) "
  },
  {
    "path": "algorithms/bubble_sort/elixir/README.md",
    "chars": 402,
    "preview": "# Elixir BubbleSort\n\nA simple implementation of the bubble sort algorithm in Elixir.\n\nExample of usage:\n\n```\niex(1)> c(\""
  },
  {
    "path": "algorithms/bubble_sort/elixir/bubblesort.ex",
    "chars": 380,
    "preview": "defmodule BubbleSort do\n  def sort([]),  do: []\n  def sort(list) do\n    round = swap(list)\n    cond do\n      round == li"
  },
  {
    "path": "algorithms/bubble_sort/go/bubble-sort-algorithm.go",
    "chars": 667,
    "preview": "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tvar numbers []int = []int{5, 4, 2, 3, 1, 0}\n\tfmt.Println(\"Unsorted:\", numbers"
  },
  {
    "path": "algorithms/bubble_sort/haskell/bubble_sort.hs",
    "chars": 454,
    "preview": "import Debug.Trace\n\nmain :: IO()\nmain = do\n  let sorted = bubbleSort [6, 5, 3, 1, 8, 7, 2, 4] :: [Integer]\n  print sorte"
  },
  {
    "path": "algorithms/bubble_sort/java/BubbleSortExample.java",
    "chars": 1207,
    "preview": "import java.util.Scanner;\n\npublic class BubbleSortExample {\n\n    private static void bubbleSort(int[] arr) {\n        int"
  },
  {
    "path": "algorithms/bubble_sort/java/GenericBubbleSort.java",
    "chars": 1098,
    "preview": "\nclass GenericBubbleSort {\n\n    public static <T extends Comparable<T>> void bubble_sort(T array[]){\n        boolean swa"
  },
  {
    "path": "algorithms/bubble_sort/javascript/bubble-sort.js",
    "chars": 344,
    "preview": "function bubbleSort(a)\n{\n    let swapped;\n    do {\n        swapped = false;\n        for (let i=0; i < a.length-1; i++) {"
  },
  {
    "path": "algorithms/bubble_sort/javascript/bubbleSort.js",
    "chars": 381,
    "preview": "function bubbleSort(array) {\n    let len = array.length;\n    let temp;\n\n    for (let i = 0; i < len; i++) {\n        for "
  },
  {
    "path": "algorithms/bubble_sort/javascript/main_bs.js",
    "chars": 726,
    "preview": "let bubbleSort = require('./bubbleSort');\n// import bubbleSort from './bubbleSort';\nlet rl = require('readline');\n// imp"
  },
  {
    "path": "algorithms/bubble_sort/kotlin/bubblesort.kt",
    "chars": 529,
    "preview": "public class bubbleSort : Algorithm{\n\n    public override fun sort(arr: Array<Long>): Array<Long> {\n        var swappedE"
  },
  {
    "path": "algorithms/bubble_sort/objetive-c/BubbleSort.m",
    "chars": 1018,
    "preview": "- (NSArray *)bubbleSort:(NSArray *)unsortedArray {\n    //create mutable copy of the array\n    NSMutableArray *unsortedMu"
  },
  {
    "path": "algorithms/bubble_sort/perl/BubbleSort.pl",
    "chars": 241,
    "preview": "my @array = ( 5, 6, 3, 1, 7, 3, 2, 9, 10, 4 );\n\nfor my $x ( reverse 1 .. $#array ) {\n    for my $y ( 0 .. $x - 1 ) {\n   "
  },
  {
    "path": "algorithms/bubble_sort/power_shell/bubble_sort.ps1",
    "chars": 337,
    "preview": "function bubblesort ($a) {\n    $l = $a.Length\n    $hasChanged = $true\n    while ($hasChanged) {\n        $hasChanged = $f"
  },
  {
    "path": "algorithms/bubble_sort/python/bubble_sort.py",
    "chars": 317,
    "preview": "def bubbleSort(a):\n    n = len(a)\n    sorted = False\n    while not sorted:\n        sorted = True\n        for i in range("
  },
  {
    "path": "algorithms/bubble_sort/ruby/bubble_sort.rb",
    "chars": 332,
    "preview": "def bubble_sort(array)\n  n = array.length\n  loop do\n    swapped = false\n\n    (n-1).times do |i|\n      next unless array["
  },
  {
    "path": "algorithms/bubble_sort/swift/bubble_sort.swift",
    "chars": 715,
    "preview": "func bubbleSort(unsortedArray: Array<NSNumber>) -> Array<NSNumber> {\n    //mutable copy of the initial array\n    var mut"
  },
  {
    "path": "algorithms/bubble_sort/vb/bubble_sort.bas",
    "chars": 715,
    "preview": "Option Explicit\n'VB6 Specific\nPrivate Sub bubble_sort()\nDim i As Integer\nDim j As Integer\nDim k As Integer\nDim array_uns"
  },
  {
    "path": "algorithms/bucket_sort/bucket_sort.cpp",
    "chars": 1031,
    "preview": "// C++ program to sort an array using bucket sort\n#include <iostream>\n#include <algorithm>\n#include <vector>\nusing names"
  },
  {
    "path": "algorithms/bucket_sort/bucket_sort.java",
    "chars": 1601,
    "preview": "//This is a java program to sort numbers using bucket sort\nimport java.util.Random;\n \npublic class Bucket_Sort \n{\n    st"
  },
  {
    "path": "algorithms/bucket_sort/bucket_sort.py",
    "chars": 1106,
    "preview": "def bucketsort( A ):\n  # get hash codes\n  code = hashing( A )\n  buckets = [list() for _ in range( code[1] )]\n  # distrib"
  },
  {
    "path": "algorithms/bucket_sort/c/bucket_sort.c",
    "chars": 1219,
    "preview": "    /*\n\n     * C Program to Sort Array using Bucket Sort\n\n     */\n\n    #include <stdio.h>\n\n     \n\n    /* Function for bu"
  },
  {
    "path": "algorithms/caesar_cipher/java/caesar.java",
    "chars": 2752,
    "preview": "/**\nAuthor : FAHRI YARDIMCI\nA Java implementation of Caesar Cipher.\n/It is a type of substitution cipher in which each l"
  },
  {
    "path": "algorithms/caesar_cipher/javascript/caesarCipher.js",
    "chars": 1941,
    "preview": "const LEGAL_VALUES = 'abcdefghijklmnopqrstuvwxyz';\nconst START_CODE = 'a'.charCodeAt(0);\nconst END_CODE = 'z'.charCodeAt"
  },
  {
    "path": "algorithms/check_pallindrome_number/c/checkPalindrome.c",
    "chars": 310,
    "preview": "#include <stdio.h>\n#include <stdlib.h>\n\nint checkPall(char str[])\n{\n\tfor(int i = 0; i < strlen(str); i++)\n\t{\n\t\tif(str[i]"
  },
  {
    "path": "algorithms/check_pallindrome_number/cpp/checkPall.cpp",
    "chars": 365,
    "preview": "#include <iostream>\n#include <cstring>\n#include <string>\nusing namespace std;\nint checkPall(char str[])\n{\n\tfor(int i = 0"
  },
  {
    "path": "algorithms/closest/java/Closest.java",
    "chars": 1094,
    "preview": "package algorithms.closest.java;\n\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Scanner;\n\n/"
  },
  {
    "path": "algorithms/count_sort/javascript/count_sort.js",
    "chars": 932,
    "preview": "\"use strict\";\nvar countSort = (arr, range)=>{\n    /**\n     * Consider the input is in range of 1 to 9\n      */\n    // th"
  },
  {
    "path": "algorithms/cycle_sort/java/cycleSort.java",
    "chars": 1740,
    "preview": "// Java program to impleament cycle sort\n\nimport java.util.*;\nimport java.lang.*;\n\nclass GFG\n{\n// Function sort the arra"
  },
  {
    "path": "algorithms/decoding/c/base64_decoder.c",
    "chars": 2097,
    "preview": "// C implementation of base64 decoder for converting radix-64 representation into ASCII string format\n#include<stdio.h>\n"
  },
  {
    "path": "algorithms/dfs/cpp/dfs.cpp",
    "chars": 1533,
    "preview": "\n\n#import <vector>\n#import <queue>\n#import <iostream>\n\n\nclass Vertex {\npublic:\n    Vertex(std::string n);\n\n    bool visi"
  },
  {
    "path": "algorithms/dfs/java/Graph.java",
    "chars": 1365,
    "preview": "import java.util.*;\n\n/**\n * Represents a directed graph using adjacency list\n */\nclass Graph {\n    private int vertexNum"
  },
  {
    "path": "algorithms/dfs/python/Dfs.py",
    "chars": 1315,
    "preview": "__author__ = 'mittr'\n   # Python program to print DFS traversal from a\n# given given graph\nfrom collections import defau"
  },
  {
    "path": "algorithms/dijkstra/cpp/Dijkstras.cpp",
    "chars": 2699,
    "preview": "// A C / C++ program for Dijkstra's single source shortest path algorithm.\n// The program is for adjacency matrix repres"
  },
  {
    "path": "algorithms/dijkstra/java/ShortestPath.java",
    "chars": 2375,
    "preview": "/**\n * A Java program for Dijkstra's single source shortest path algorithm.\n * The program is for adjacency matrix repre"
  },
  {
    "path": "algorithms/dijkstra/python/djikstra.py",
    "chars": 1026,
    "preview": "class Graph:\n  def __init__(self):\n    self.nodes = set()\n    self.edges = defaultdict(list)\n    self.distances = {}\n\n  "
  },
  {
    "path": "algorithms/doomsday/java/doomsday.java",
    "chars": 1632,
    "preview": "/**\n * Determines the day of the week.\n * \n * @author Atom\n *\n */\npublic class Doomsday {\n\t\n\t/**\n\t * Determines the day "
  },
  {
    "path": "algorithms/doomsday/javascript/doomsday.js",
    "chars": 539,
    "preview": "function dayOfTheWeek(y, m, d) {\n    const t = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4]\n    y -= m < 3;\n    return (y + Math"
  },
  {
    "path": "algorithms/dynamic_programming/c/0_1_knapsack_problem.c",
    "chars": 914,
    "preview": "// A Dynamic Programming based solution for 0-1 Knapsack problem\n#include<stdio.h>\n\n// A utility function that returns m"
  },
  {
    "path": "algorithms/dynamic_programming/c/Coin_change_DP.c",
    "chars": 1466,
    "preview": "//Coin change problem : \n/*\nGiven a value N, if we want to make change for N cents, and we have infinite supply of each "
  },
  {
    "path": "algorithms/dynamic_programming/c/coinChange.c",
    "chars": 812,
    "preview": "#include<stdio.h>\nint count( int S[], int m, int n )\n{\n    // table[i] will be storing the number of solutions for\n    /"
  },
  {
    "path": "algorithms/dynamic_programming/c/count_no_of_ways_to_reach_nth_stair.c",
    "chars": 661,
    "preview": "// A C program to count number of ways to reach n't stair when\n// a person can climb 1, 2, ..m stairs at a time\n#include"
  },
  {
    "path": "algorithms/dynamic_programming/c/longestIncreasingSubsequence.c",
    "chars": 1035,
    "preview": "/* Dynamic Programming C/C++ implementation of LIS problem */\n#include<stdio.h>\n#include<stdlib.h>\n \n/* lis() returns th"
  },
  {
    "path": "algorithms/dynamic_programming/c/longestRepeatedSequence.c",
    "chars": 1803,
    "preview": "// C++ program to find the longest repeated\n// subsequence\n#include <bits/stdc++.h>\nusing namespace std;\n \n// This funct"
  },
  {
    "path": "algorithms/dynamic_programming/c/longest_pallindrome_sequence.c",
    "chars": 1437,
    "preview": "# A Dynamic Programming based Python program for LPS problem\n# Returns the length of the longest palindromic subsequence"
  },
  {
    "path": "algorithms/dynamic_programming/c/maxSumIncSequence.c",
    "chars": 1020,
    "preview": "/* Dynamic Programming implementation of Maximum Sum Increasing\nSubsequence (MSIS) problem */\n#include<stdio.h>\n \n/* max"
  },
  {
    "path": "algorithms/dynamic_programming/c/subsetSum.c",
    "chars": 951,
    "preview": "// A recursive solution for subset sum problem\n#include <stdio.h>\n \n// Returns true if there is a subset of set[] with s"
  },
  {
    "path": "algorithms/dynamic_programming/cpp/kadens.cpp",
    "chars": 726,
    "preview": "// C++ program to print largest contiguous array sum\n#include<iostream>\n#include<climits>\nusing namespace std;\n \nint max"
  },
  {
    "path": "algorithms/dynamic_programming/cpp/nCr.cpp",
    "chars": 807,
    "preview": "#include<bits/stdc++.h>\nusing namespace std;\n \n// Returns nCr % p\nint nCrModp(int n, int r, int p)\n{\n    // The array C "
  },
  {
    "path": "algorithms/dynamic_programming/cpp/subset_sum.cpp",
    "chars": 540,
    "preview": "#include<bits/stdc++.h>\nusing namespace std;\nint arr[1000];\nint sum=0;\nint cache[100][100];\nint m_diff(int idx,int sub_s"
  },
  {
    "path": "algorithms/dynamic_programming/java/MinCostPath.java",
    "chars": 1144,
    "preview": "import java.util.Scanner;\n\npublic class MinCostPath {\n\n\tpublic static int minCostPathDP(int arr[][],int row, int column)"
  },
  {
    "path": "algorithms/encoding/base64_encoder.c",
    "chars": 2065,
    "preview": "// C implementation of base64 encoder for converting ASCII string format into radix-64 representation.\n#include<stdio.h>"
  },
  {
    "path": "algorithms/fibonacci/cpp/constexpr-fibonacci.cpp",
    "chars": 430,
    "preview": "// Computes a specific index of the Fibonacci sequence\n// Can be computed at compile-time under certain conditions\n\ncons"
  },
  {
    "path": "algorithms/floyd_warshall/java/ShortestPath.java",
    "chars": 1711,
    "preview": "/**\n * A Java program for Floyd Warshall All Pairs Shortest\n * Path algorithm.\n */\npublic class ShortestPath {\n    priva"
  },
  {
    "path": "algorithms/greedy_search/cpp/prims_algorithm.cpp",
    "chars": 1671,
    "preview": "#include <bits/stdc++.h>\nusing namespace std;\n\nint minkey(int key[], bool mstset[],int n)\n{\n\tint min_index;\n\tint Min = I"
  },
  {
    "path": "algorithms/heap_sort/crystal/heap_sort.cr",
    "chars": 812,
    "preview": "def heap_sort(array)\n  to_heap(array)\n  bottom = array.size - 1\n\n  while bottom > 0\n    array[0], array[bottom] = array["
  },
  {
    "path": "algorithms/heap_sort/java/heap_sort.java",
    "chars": 2107,
    "preview": "/*\n * Java Program to Implement Heap Sort\n */\n \nimport java.util.Scanner;\n \n/* Class HeapSort */\npublic class HeapSort \n"
  },
  {
    "path": "algorithms/heap_sort/java/heapsort.java",
    "chars": 1907,
    "preview": "//Java program for Heap Sort\n\nclass heapsort\n{\n    public void sort(int arr[])\n    {\n        int n = arr.length;\n \n     "
  },
  {
    "path": "algorithms/heap_sort/javascript/heap_sort.js",
    "chars": 948,
    "preview": "  var array_length;\n/* to create MAX  array */  \nfunction heap_root(input, i) {\n    var left = 2 * i + 1;\n    var right "
  },
  {
    "path": "algorithms/heap_sort/python/heap_sort.py",
    "chars": 661,
    "preview": "from heapq import heappush, heappop\n\ndef heap_sort(heap_iterable):\n    '''\n    Heap sort implementation\n    '''\n    heap"
  },
  {
    "path": "algorithms/histogram_equalization/java/HistogramEqualization.java",
    "chars": 4403,
    "preview": "/*\n* This file has been created by github user vn17.\n* Feel free to use it for any purpose.\n*\n* This file makes extensiv"
  },
  {
    "path": "algorithms/huffmann_algorithm/java/Huffman.java",
    "chars": 2373,
    "preview": "package Lecture25;\r\n\r\nimport java.util.HashMap;\r\nimport java.util.Set;\r\n\r\nimport Lecture19.BinaryTree;\r\nimport Lecture21"
  },
  {
    "path": "algorithms/insertion_sort/ada/insertion_sort.adb",
    "chars": 2188,
    "preview": "with Ada.Containers.Vectors;\nwith Ada.Numerics.Discrete_Random;\nwith Ada.Text_IO;\nwith Ada.Integer_Text_IO;\n\nuse Ada.Tex"
  },
  {
    "path": "algorithms/insertion_sort/c/InsertionSort.c",
    "chars": 854,
    "preview": "// C program for insertion sort\n#include <stdio.h> \n/* Function to sort an array using insertion sort */\nvoid insertionS"
  },
  {
    "path": "algorithms/insertion_sort/cpp/insertion_sort.cpp",
    "chars": 875,
    "preview": "//\n// Created by radligna on 05.10.17.\n//\n\n\n// C++ program for insertion sort\n\n//needed to print the sorted array\n#inclu"
  },
  {
    "path": "algorithms/insertion_sort/crystal/insertion_sort.cr",
    "chars": 342,
    "preview": "def insertion_sort(array)\n  x = 1\n  loop do\n    i = x\n\n    while i > 0 && array[i-1] > array[i]\n      array[i], array[i "
  },
  {
    "path": "algorithms/insertion_sort/java/InsertionSort.java",
    "chars": 941,
    "preview": "class InsertionSort {\r\n\r\n    /*\r\n    This class sorts an array using insertion sort\r\n     */\r\n\r\n    public static int[] "
  },
  {
    "path": "algorithms/insertion_sort/javascript/insertionSort.js",
    "chars": 257,
    "preview": "function insertionSort(array) {\n  for (let i = 0; i < array.length; i++) {\n    let temp = array[i];\n    let j = i - 1;\n\n"
  },
  {
    "path": "algorithms/insertion_sort/javascript/insertion_sort.js",
    "chars": 275,
    "preview": "function insertionSort(unsortedList) {\n\tlet len = unsortedList.length;\n\n\tfor (let i = 1; i < len; i++) {\n\t\tlet ele = uns"
  },
  {
    "path": "algorithms/insertion_sort/python/insertionsort.py3",
    "chars": 589,
    "preview": "# Python program for implementation of Insertion Sort\n \n# Function to do insertion sort\ndef insertionSort(arr):\n \n    # "
  },
  {
    "path": "algorithms/insertion_sort/ruby/insertion_sort.rb",
    "chars": 372,
    "preview": "def insertion_sort(numbers)\n  for i in 1...numbers.length\n    key = numbers[i]\n    j = i - 1\n    while j >= 0 and number"
  },
  {
    "path": "algorithms/inversion_count/cpp/inversion_count.cpp",
    "chars": 1148,
    "preview": "#include <bits/stdc++.h>\nusing namespace std;\n\nlong merge(vector<int> &arr, vector<int> &tmp, int left, int mid, int rig"
  },
  {
    "path": "algorithms/jarvis/cpp/jarvis.cpp",
    "chars": 2178,
    "preview": "/*Given a set of points in the plane. the convex hull of the set is the smallest convex polygon that contains all the po"
  },
  {
    "path": "algorithms/johnson_algorithm/cpp/johnson_algorithm.cpp",
    "chars": 1313,
    "preview": "    #include<iostream>\n\n    #include<conio.h>\n\n     \n\n    using namespace std;\n\n     \n\n    int min(int a, int b);\n\n    i"
  },
  {
    "path": "algorithms/kmp_search/cpp/KMPSearch.cpp",
    "chars": 1343,
    "preview": "//CPP Implementation of Knuth-Morris-Pratt(KMP) algorithm for pattern matching in a given text string.\n\n#include<bits/st"
  },
  {
    "path": "algorithms/kmp_search/java/KMPSearch.java",
    "chars": 1799,
    "preview": "\npublic class KMPSearch {\n    public static void main(String[] args) {\n        new KMPSearch().demo();\n    }\n\n    privat"
  },
  {
    "path": "algorithms/kmp_search/python/KMPSearch.py",
    "chars": 884,
    "preview": "class KMP:\n    def partial(self, pattern):\n        \"\"\" Calculate partial match table: String -> [Int]\"\"\"\n        ret = ["
  },
  {
    "path": "algorithms/linear_search/c/linearsearch.C",
    "chars": 599,
    "preview": "#include <stdio.h>\n// linear search function\nint linear(int a[], int n, int x){\n  for(int i = 0; i < n; i++){\n    // if "
  },
  {
    "path": "algorithms/linear_search/cpp/linearSearch.cpp",
    "chars": 498,
    "preview": "#include <iostream>\nusing namespace std;\n\nint linearSearch(int* arr, int size, int num){\n  for(int i = 0; i < size; i++)"
  },
  {
    "path": "algorithms/linear_search/java/LinearSearch.java",
    "chars": 684,
    "preview": "import java.util.Scanner;\n\npublic class LinearSearch {\n\n    public static void main(String args[])\n    {\n        int i;\n"
  },
  {
    "path": "algorithms/linear_search/javascript/linear_search.js",
    "chars": 223,
    "preview": "var linearSearch = function(list, target){\n  var result = null,\n      i = 0, value;\n  for(; i < list.length; i++){\n    v"
  },
  {
    "path": "algorithms/linear_search/python/linear_search.py",
    "chars": 357,
    "preview": "def linear_search(a,target):\n\ti = 0\n \twhile i < len(a) and a[i] != target:\n \t\ti = i+1\n \treturn i < len(a);\n\n#input: targ"
  },
  {
    "path": "algorithms/longest_common_subsequence/cpp/LongestCommonSubsequence.cpp",
    "chars": 1070,
    "preview": "/* Dynamic Programming C/C++ implementation of LCS problem */\n#include<bits/stdc++.h>\n  \nint max(int a, int b);\n  \n/* Re"
  },
  {
    "path": "algorithms/longest_common_subsequence/javaj/LCS.java",
    "chars": 1089,
    "preview": "/* Returns length of LCS for X[0..m-1], Y[0..n-1] */\n  int lcs( char[] X, char[] Y, int m, int n )\n  {\n    int L[][] = n"
  },
  {
    "path": "algorithms/longest_common_subsequence/javascript/longest_common_subsequence.js",
    "chars": 390,
    "preview": "function lcs(a, b) {\n  var aSub = a.substr(0, a.length - 1);\n  var bSub = b.substr(0, b.length - 1);\n \n  if (a.length =="
  },
  {
    "path": "algorithms/longest_common_subsequence/python/LCS.py",
    "chars": 856,
    "preview": "# Dynamic Programming implementation of LCS problem\n \ndef lcs(X , Y):\n    # find the length of the strings\n    m = len(X"
  },
  {
    "path": "algorithms/longest_common_substring/java/LongestCommonSubString.java",
    "chars": 1609,
    "preview": "import java.util.Arrays;\n\nclass StringManager {\n\n    public static String findLongestCommonSubString(String str1, String"
  },
  {
    "path": "algorithms/matrix_chain_multiplication/cpp/MCM.cpp",
    "chars": 1335,
    "preview": "// See the Cormen book for details of the following algorithm\n#include<stdio.h>\n#include<limits.h>\n \n// Matrix Ai has di"
  },
  {
    "path": "algorithms/matrix_chain_multiplication/java/MCM.java",
    "chars": 1497,
    "preview": "{\n    // Matrix Ai has dimension p[i-1] x p[i] for i = 1..n\n    static int MatrixChainOrder(int p[], int n)\n    {\n      "
  },
  {
    "path": "algorithms/matrix_chain_multiplication/python/MCM.py",
    "chars": 1105,
    "preview": "def matrix_chain_multiplication(dimensions):\n    \"\"\"\n    Implementation of matrix chain multiplication\n    \"\"\"\n\n    matr"
  },
  {
    "path": "algorithms/merge_sort/c#/MergeSort.cs",
    "chars": 1591,
    "preview": "using System;\n\nnamespace MergeSort\n{\n    class MergeSort\n    {\n        static void Main(string[] args)\n        {\n      "
  },
  {
    "path": "algorithms/merge_sort/cpp/merge_sort.cpp",
    "chars": 1347,
    "preview": "#include <iostream.h>\nint a[50];\nvoid merge(int,int,int);\nvoid merge_sort(int low,int high)\n{\n int mid;\n if(low<high)\n {"
  },
  {
    "path": "algorithms/merge_sort/haskell/merge_sort.hs",
    "chars": 542,
    "preview": "module MergeSort where\n\n{-\nMerge Sort in Haskell.\n-}\n\nmerge :: Ord a =>[a] -> [a] -> [a]\nmerge [] ys = ys\nmerge xs [] = "
  },
  {
    "path": "algorithms/merge_sort/java/merge_sort.java",
    "chars": 2672,
    "preview": "/* Java program for Merge Sort */\nclass MergeSort\n{\n    // Merges two subarrays of arr[].\n    // First subarray is arr[l"
  },
  {
    "path": "algorithms/merge_sort/javascript/MergeSort.js",
    "chars": 731,
    "preview": "var a = [34, 203, 3, 746, 200, 984, 198, 764, 9];\n \nfunction mergeSort(arr)\n{\n    if (arr.length < 2)\n        return arr"
  },
  {
    "path": "algorithms/merge_sort/python/merge_sort.py",
    "chars": 623,
    "preview": "def merge_sort(li):\n    # recursively split the lists\n    if len(li) <= 1:\n        return li\n    middle = len(li) / 2\n  "
  },
  {
    "path": "algorithms/merge_sort/ruby/merge_sort.rb",
    "chars": 629,
    "preview": "def sort(numbers)\n  return numbers if numbers.size <= 1\n\n  arr_len = numbers.size\n  half_size = (arr_len / 2).round\n\n  l"
  },
  {
    "path": "algorithms/minimum_spanning_tree/cpp/MST.cpp",
    "chars": 1051,
    "preview": "#include<bits/stdc++.h>\n#include<algorithm>\nusing namespace std;\nint parent[1000];\nint size[1000];\n\n//// union find\nvoid"
  },
  {
    "path": "algorithms/optimal_binary_search_tree/java/OptimalBst.java",
    "chars": 1634,
    "preview": "import javax.lang.model.element.Element;\n\npublic class OptimalBst {\n\t\n\tstatic int[] elements = {5,6,8,20};\n\t\n\tstatic int"
  },
  {
    "path": "algorithms/parse_tree/python/parse_tree.py",
    "chars": 2384,
    "preview": "class Stack:\n     def __init__(self):\n         self.items = []\n\n     def isEmpty(self):\n         return self.items == []"
  },
  {
    "path": "algorithms/permutations/java/Permutation.java",
    "chars": 870,
    "preview": "//Backtracking solution\npublic class Permutation\n{\n    public void permute(String str, int l, int r)\n    {\n        if (l"
  },
  {
    "path": "algorithms/permutations/javascript/permutations.js",
    "chars": 468,
    "preview": "// Takes an Array, arr, and returns an Array of all permutations of arr\n\nconst permutations = function(arr) {\n  let resu"
  },
  {
    "path": "algorithms/quick_sort/ada/quick_sort.adb",
    "chars": 3068,
    "preview": "with Ada.Containers.Vectors;\nwith Ada.Numerics.Discrete_Random;\nwith Ada.Text_IO;\nwith Ada.Integer_Text_IO;\n\nuse Ada.Tex"
  },
  {
    "path": "algorithms/quick_sort/c/quick_sort.c",
    "chars": 952,
    "preview": "#include<stdio.h>\nvoid quicksort(int number[25],int first,int last){\n   int i, j, pivot, temp;\n\n   if(first<last){\n     "
  },
  {
    "path": "algorithms/quick_sort/cpp/quickSort.cpp",
    "chars": 973,
    "preview": "#include <iostream>\n#include <vector>\nusing namespace std;\n\nvoid quickSort(vector<int>&,int,int);\n\nint partition(vector<"
  },
  {
    "path": "algorithms/quick_sort/csharp/QuickSort.cs",
    "chars": 1215,
    "preview": "using System;\n\nnamespace QuickSort\n{\n    class QuickSort\n    {\n        static void Main(string[] args)\n        {\n       "
  },
  {
    "path": "algorithms/quick_sort/csharp/quicksort.cs",
    "chars": 2419,
    "preview": "using System;\nusing System.Collections.Generic;\n\n/// <summary>\n/// Class for QuickSort\n/// </summary>\npublic class Quick"
  },
  {
    "path": "algorithms/quick_sort/haskell/quicksort.hs",
    "chars": 134,
    "preview": "quicksort [] = []\nquicksort (p:xs) = (quicksort lesser) ++ [p] ++ (quicksort greater)\n    where (lesser, greater) = part"
  },
  {
    "path": "algorithms/quick_sort/java/QuickSort.java",
    "chars": 1007,
    "preview": "public class QuickSort{\n\tstatic void quickSort(int[] arr,int start, int end){\n\t\tif (start < end){\n\t\t\tint pivot_pos = par"
  },
  {
    "path": "algorithms/quick_sort/javascript/quick_sort.js",
    "chars": 539,
    "preview": "/* Quicksort implementation in JavaScript */\n\nfunction quicksort(arr, p, r) {\n\tif ( p < r ) {\n\t\tq = partition(arr, p, r)"
  },
  {
    "path": "algorithms/quick_sort/kotlin/quicksort.kt",
    "chars": 1247,
    "preview": "class QuickSort {\n    private fun quickSort(arr: IntArray, start: Int, end: Int) {\n        if (start < end) {\n          "
  },
  {
    "path": "algorithms/quick_sort/python/quicksort.py",
    "chars": 772,
    "preview": "def partition(li, start, end):\n    pivot = li[start]\n    left = start + 1\n    right = end\n    done = False\n\n    while no"
  },
  {
    "path": "algorithms/quick_sort/ruby/quick_sort.rb",
    "chars": 450,
    "preview": "def quicksort(array)\n  return array if array.length <= 1\n\n  pivot_index = (array.length / 2).to_i\n  pivot_value = array["
  },
  {
    "path": "algorithms/rabin_karp/java/RabinKarp.java",
    "chars": 1064,
    "preview": "import java.math.BigInteger;\nimport java.util.Random;\npublic class RabinKarp {\nprivate long patHash;\n    private int M;\n"
  },
  {
    "path": "algorithms/radixsort/c++/radixsort.cpp",
    "chars": 1010,
    "preview": "# include <iostream>\n\nusing namespace std; \n  \nint getMax(int arr[], int n) \n{ \n    int mx = arr[0]; \n    for (int i = 1"
  },
  {
    "path": "algorithms/radixsort/python/lsd_radixsort.py",
    "chars": 601,
    "preview": "import functools\n\n\ndef get_digit(number, digit):\n    return int((number % (10 ** digit)) / (10 ** (digit - 1)))\n\n\ndef ls"
  },
  {
    "path": "algorithms/selection_sort/c/SelectionSort.c",
    "chars": 562,
    "preview": "#include<stdio.h>\n\nconst int SIZE=100;\n\nvoid SelectionSort(int arr[SIZE]){\n  int i,j,temp,min=999999,index;\n  for (i = 0"
  },
  {
    "path": "algorithms/selection_sort/crystal/selection_sort.cr",
    "chars": 439,
    "preview": "def selection_sort(array)\n  i = 0\n\n  loop do\n    j = i\n    min_index = i\n\n    loop do\n      if array[min_index] > array["
  },
  {
    "path": "algorithms/selection_sort/java/SelectionSort.java",
    "chars": 937,
    "preview": "// Java program for implementation of Selection Sort\nclass SelectionSort\n{\n    // Implementation of Selection Sort\n    v"
  },
  {
    "path": "algorithms/selection_sort/javascript/selection_sort.js",
    "chars": 345,
    "preview": "var selectionSort = function(array){\n  for(var i = 0; i < array.length; i++){\n    //set min to the current iteration of "
  },
  {
    "path": "algorithms/selection_sort/python/selection_sort.py",
    "chars": 504,
    "preview": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Oct 1 21:17 2017\n@author: john2ksonn\n\nJust a simple implementation of the sel"
  },
  {
    "path": "algorithms/selection_sort/ruby/selection_sort.rb",
    "chars": 355,
    "preview": "def selection_sort(input_arr)\n  arr = input_arr.dup\n  n = arr.size - 1\n\n  n.times do |i|\n    index_min = i\n    (i + 1).u"
  },
  {
    "path": "algorithms/shell_sort/C/ShellSort.c",
    "chars": 723,
    "preview": "#include <stdio.h>\n\nvoid shellsort(int arr[], int num)\n{\n    int i, j, k, tmp;\n    for (i = num / 2; i > 0; i = i / 2)\n "
  },
  {
    "path": "algorithms/shell_sort/C++/ShellSort.cpp",
    "chars": 1448,
    "preview": "// C++ implementation of Shell Sort\n#include  <iostream>\nusing namespace std;\n \n/* function to sort arr using shellSort "
  },
  {
    "path": "algorithms/shell_sort/Java/ShellSort.java",
    "chars": 1408,
    "preview": "// Java implementation of ShellSort\nclass ShellSort\n{\n\t/* An utility function to print array of size n*/\n\tstatic void pr"
  },
  {
    "path": "algorithms/shell_sort/python/shellsort.py",
    "chars": 863,
    "preview": "def shellSort(arr):\n \n    # Start with a big gap, then reduce the gap\n    n = len(arr)\n    gap = n/2\n \n    # Do a gapped"
  },
  {
    "path": "algorithms/sieve_of_eratosthenes/cpp/sieve_of_eratosthenes.cpp",
    "chars": 1005,
    "preview": "// C++ program to print all primes smaller than or equal to\n// n using Sieve of Eratosthenes\n#include <bits/stdc++.h>\nus"
  },
  {
    "path": "algorithms/sieve_of_eratosthenes/java/sieve.java",
    "chars": 1938,
    "preview": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n \npublic class sieve\n{\n\t/*\n"
  },
  {
    "path": "algorithms/sieve_of_eratosthenes/javascript/sieve.js",
    "chars": 425,
    "preview": "let sieveOfEratosthenes = function(n) {\n  let array = [];\n  let upperLimit = Math.sqrt(n);\n  let output = [];\n\n  for (le"
  },
  {
    "path": "algorithms/sieve_of_eratosthenes/python/sieve.py",
    "chars": 469,
    "preview": "def run_sieve(N, isPrime):\n    for i in range(N+1):\n        if isPrime[i]:\n            for j in range(i+1, N+1):\n       "
  },
  {
    "path": "algorithms/sort/heap_sort/java/heap_sort.java",
    "chars": 1932,
    "preview": "// Java program for implementation of Heap Sort\npublic class HeapSort\n{\n    public void sort(int arr[])\n    {\n        in"
  },
  {
    "path": "algorithms/strings/cpp/anagrams.cpp",
    "chars": 933,
    "preview": "#include <bits/stdc++.h>\nusing namespace std;\n\nbool isAnagram(string a, string b)\n{\n    sort(a.begin(),a.end());\n    sor"
  },
  {
    "path": "algorithms/tower_of_hanoi/cpp/tower_of_hanoi.cpp",
    "chars": 588,
    "preview": "#include <iostream>\nusing namespace std;\nint moves(0);\nvoid Hanoi(int m, char a, char b, char c);\nint main(){\n\n  int dis"
  },
  {
    "path": "algorithms/tower_of_hanoi/java/towers_of_hanoi.java",
    "chars": 656,
    "preview": "public class TowersOfHanoi {\n\n   public void solve(int n, String start, String auxiliary, String end) {\n       if (n == "
  },
  {
    "path": "algorithms/tower_of_hanoi/javascript/tower_of_hanoi.js",
    "chars": 445,
    "preview": "\n// Prints the movement\nfunction moveDisk(from_pole, to_pole) {\n    console.log(\"Moving disk from \" + \n        from_pole"
  },
  {
    "path": "algorithms/tower_of_hanoi/php/towers_of_hanoi.php",
    "chars": 213,
    "preview": "<?php \n\nfunction move($n, $src, $dest, $temp ){\n\tif($n >= 1){\n\t\tmove($n-1, $src,$temp, $dest);\n\t\tprintf(\"Moving %d -> %d"
  },
  {
    "path": "algorithms/tower_of_hanoi/python/tower_of_hanoi.py",
    "chars": 471,
    "preview": "\ndef move_disk(from_pole, to_pole):\n    '''\n    Prints the movement\n    '''\n    print('Moving disk from', from_pole, ' t"
  },
  {
    "path": "data_structures/arraylist/java/arraylist.java",
    "chars": 767,
    "preview": "import java.util.*;\npublic class arraylist {\n\n   public static void main(String args[]) {\n      // create an array list\n"
  },
  {
    "path": "data_structures/avl_tree/java/AVL.java",
    "chars": 2693,
    "preview": "public class AVL {\n    class Node {\n        private int data, height;\n        private Node left, right;\n        public N"
  },
  {
    "path": "data_structures/avl_tree/javascript/avl.js",
    "chars": 4191,
    "preview": "var Node = function (value)\n{\n    this.left = null;\n    this.right = null;\n    this.value = value;\n\tthis.balance = 0;\n};"
  },
  {
    "path": "data_structures/bag/java/Bag.java",
    "chars": 2655,
    "preview": "package bag.java;\n\nimport java.util.Iterator;\nimport java.util.NoSuchElementException;\n\n/**\n * Collection which does not"
  },
  {
    "path": "data_structures/binary_search_tree/binary_search_tree.md",
    "chars": 1292,
    "preview": "\n## ELI5\nA tree is a container that stores items in sorted order in memory.It's like the inversed version of an actual t"
  },
  {
    "path": "data_structures/binary_search_tree/c/BSTtraversal.c",
    "chars": 2247,
    "preview": "// C program for different tree traversals\n#include <stdio.h>\n#include <stdlib.h>\n \n/* A binary tree node has data, poin"
  },
  {
    "path": "data_structures/binary_search_tree/cpp/BST.h",
    "chars": 5336,
    "preview": "/**\n  A simple BST in C++\n  Author: PryDt\n*/\n\n#ifndef BST_H\n#define BST_H\n\n#include <iostream>\n\ntemplate <class T>\nclass"
  },
  {
    "path": "data_structures/binary_search_tree/java/binary_search_tree.java",
    "chars": 12046,
    "preview": "\n/*\n** Binary tree & Binary tree search implementation in java\n*/\n\n\n/*\n**Input patterns \n**create 25 15 9 18 2 90 25 42 "
  },
  {
    "path": "data_structures/binary_search_tree/java/bst_operations/CheckBST.java",
    "chars": 849,
    "preview": "package bst_operations;\n\npublic class CheckBST {\n    public static void main(String[] args) {\n        new CheckBST().dem"
  },
  {
    "path": "data_structures/binary_search_tree/java/bst_operations/CorrectBST.java",
    "chars": 1413,
    "preview": "package bst_operations;\n\nimport java.util.ArrayList;\n\n/**\n * Two nodes of a BST are swapped, correct the BST\n */\npublic "
  },
  {
    "path": "data_structures/binary_search_tree/java/bst_operations/FindAncestor.java",
    "chars": 1981,
    "preview": "package bst_operations;\n\n/**\n * Created by kalsi on 30/08/17.\n * find lowest ancestor of two items\n * I assumed both the"
  },
  {
    "path": "data_structures/binary_search_tree/java/bst_operations/InorderSuccessor.java",
    "chars": 1453,
    "preview": "package bst_operations;\n\npublic class InorderSuccessor {\n    public static void main(String[] args) {\n        new Inorde"
  },
  {
    "path": "data_structures/binary_search_tree/java/bst_operations/LargestBST.java",
    "chars": 2176,
    "preview": "package bst_operations;\n\n\n/**\n * Created by kalsi on 06/09/17.\n */\npublic class LargestBST {\n    class BSTCount {\n      "
  },
  {
    "path": "data_structures/binary_search_tree/java/bst_operations/LevelOrder.java",
    "chars": 2138,
    "preview": "package bst_operations;\n\n\nimport java.util.*;\n\n/**\n * Created by kalsi on 01/09/17.\n */\npublic class LevelOrder {\n    pu"
  },
  {
    "path": "data_structures/binary_search_tree/java/bst_operations/MorrisTraversal.java",
    "chars": 1561,
    "preview": "package bst_operations;\n\n\n/**\n * Created by kalsi on 30/08/17.\n * Inorder traversal without recursion or stacks\n */\npubl"
  },
  {
    "path": "data_structures/binary_search_tree/java/bst_operations/Node.java",
    "chars": 143,
    "preview": "package bst_operations;\n\npublic class Node {\n    int data;\n    Node left;\n    Node right;\n\n    public Node(int d) {\n    "
  },
  {
    "path": "data_structures/binary_search_tree/java/bst_operations/PathFromRootToNode.java",
    "chars": 1536,
    "preview": "package bst_operations;\n\nimport java.util.ArrayList;\n\n/**\n * Created by kalsi on 30/08/17.\n * Path from root to node\n */"
  },
  {
    "path": "data_structures/binary_search_tree/javascript/binary_tree.js",
    "chars": 834,
    "preview": "// Cleaner Logging\nexport const _ = (...vals) => console.log(...vals);\n\n// Create BST Node\nexport function BST(val) {\n  "
  },
  {
    "path": "data_structures/binary_search_tree/javascript/binary_tree_search.js",
    "chars": 1717,
    "preview": "import { _, BST } from './binary_tree';\n\n// Recursive binary search\nBST.prototype.contains = function(value) {\n    var d"
  },
  {
    "path": "data_structures/binary_search_tree/javascript/breadth_first_search.js",
    "chars": 3440,
    "preview": "import { _, BST } from './binary_tree';\n// Create Queue Class\nlet Queue = () => {\n    let _data = [];\n\n    return {\n    "
  }
]

// ... and 113 more files (download for full content)

About this extraction

This page contains the full source code of the BaReinhard/Hacktoberfest-Data-Structure-and-Algorithms GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 313 files (481.8 KB), approximately 143.8k tokens, and a symbol index with 1293 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!