data-structure-and-sort-algorithms-snippets
What is this?
This is a collection of snippets for creating data structures and sort alogorithms in C++ (C, C#, Java, Python, and JavaScript in the future). The snippets are designed to be used with VSCode
Table of Singly linked list Snippets
All snippets are prefixed with {languge}-ll
where language is the language of the snippet. For example, the C++ Singly linked list snippets are prefixed with cpp-ll
.
Prefix |
Code |
-creat-class |
Creat Class ll |
-find |
Return a Node in index |
-constructor |
Creat constructor |
-push-front |
Insert a Node in front |
-push-back |
Insert a Node in the back |
-insert |
Insert a Node at the Index position |
-pop-front |
Remove a Node in front |
-pop-back |
Remove a Node in the back |
-remove |
Remove a Nond at the Index position |
-is-empty |
Return True if List empty |
-get-size |
Return size of the List |
-retrieve |
Return value of Node at the Index position |
-display |
Print value of all Node in the List |
Table of Stack Snippets
All snippets are prefixed with {languge}-stack
where language is the language of the snippet. For example, the C++ Stack snippets are prefixed with cpp-stack
.
Prefix |
Code |
-creat-class |
Creat Class Stack |
-constructor |
Creat constructor |
-push |
Insert a Node in front |
-pop |
Remove a Node in front |
-get-top |
Return value of Node in front |
-is-empty |
Return True if List empty |
-get-size |
Return size of the List |
-display |
Print value of all Node in the List |
-clear |
Remove all Node in the List |
-reverse |
Reverse all Node in the List |
-infix-to-postfix |
Convert infix to postfix |
-postfix-evaluate |
Evaluate postfix expression |
Table of Queue Snippets
All snippets are prefixed with {languge}-queue
where language is the language of the snippet. For example, the C++ Queue snippets are prefixed with cpp-queue
.
Prefix |
Code |
-creat-class |
Creat Class Queue |
-constructor |
Creat constructor |
-push |
Insert a Node in the back |
-pop |
Remove a Node in front |
-get-front |
Return value of Node in front |
-get-back |
Return value of Node in the back |
-is-empty |
Return True if List empty |
-get-size |
Return size of the List |
-display |
Print value of all Node in the List |
-clear |
Remove all Node in the List |
-reverse |
Reverse all Node in the List |
Table of Binary Search Tree Snippets
All snippets are prefixed with {languge}-bst
where language is the language of the snippet. For example, the C++ Binary Search Tree snippets are prefixed with cpp-bst
.
Prefix |
Code |
-creat-class |
Creat Class BST |
-constructor |
Creat constructor |
-insert-private |
Creat void insert in private of class |
-insert-public |
Insert a Node |
-delete-private |
Creat void delete in private of class |
-delete-public |
Delete a Node |
-search-private |
Creat void search in private of class |
-search-public |
Search a Node |
-inorder-private |
|
-preorder-private |
|
-postorder-private |
|
-inorder-public |
|
-preorder-public |
|
-postorder-public |
|
Table of Recursion Snippets
All snippets are prefixed with {languge}-recursion
where language is the language of the snippet. For example, the C++ Recursion snippets are prefixed with cpp-recursion
.
Prefix |
Code |
-fibo |
Return the nth Fibonacci number |
-gcd |
Return the greatest common divisor |
-lcm |
Return the least common multiple |
-pow |
Return the power of a number |
-sum |
Return the sum of a number |
-fact |
Return the factorial of a number |
-ak |
Return the Akermann function |
-perm |
Return the permutation of a string |
-comb |
Return the combination of a number |
-subset |
Print subset of a string |
-is-prime |
Return True if a number is prime |
-is-palindrome |
Return True if a string is palindrome |
-is-happy |
Return True if a number is happy |
-is-power-of-two |
Return True if a number is power of two |
-hanoi-tower |
Print the steps of Hanoi Tower |
-n-queen |
Print the steps of N Queen |
-dec-to-bin |
Convert a decimal number to binary number |
-dec-to-hex |
Convert a decimal number to hexadecimal number |
-bin-to-dec |
Convert a binary number to decimal number |
-bin-to-hex |
Convert a binary number to hexadecimal number |
-hex-to-dec |
Convert a hexadecimal number to decimal number |
-hex-to-bin |
Convert a hexadecimal number to binary number |
-string-to-int |
Convert a string to integer |
-int-to-string |
Convert an integer to string |
Table of Sort Algorithms Snippets
All snippets are prefixed with {languge}
where language is the language of the snippet. For example, the C++ Sort Algorithms snippets are prefixed with cpp
.
Prefix |
Prefix |
-selection-sort |
comb-sort |
-insertion-sort |
gnome-sort |
-quick-sort |
cycle-sort |
-merge-sort |
bogo-sort |
-bubble-sort |
stooge-sort |
-random-quick-sort |
cocktail-sort |
-counting-sort |
bitonic-sort |
-radix-sort |
pancake-sort |
-heap-sort |
tree-sort |
-bucket-sort |
shell-sort |