diff --git a/cpp.md b/cpp.md index b11bfe5..15f6506 100644 --- a/cpp.md +++ b/cpp.md @@ -310,6 +310,65 @@ int main() } ``` +## linked List + +A linked list is an ordered set of data elements, each containing a link to its successor (and sometimes its predecessor) + +The basic operations associated with linked list are-: +Insertion − Adds an element at the beginning of the list. +Deletion − Deletes an element at the beginning of the list. +Display − Displays the complete list. +Search − Searches an element using the given key. +Delete − Deletes an element using the given key. + +```c + +#include +using namespace std; + +class Node { +public: + int data; + Node* next; +}; + +// This function prints contents of linked list +// starting from the given node +void printList(Node* n) +{ + while (n != NULL) { + cout << n->data << " "; + n = n->next; + } +} +int main() +{ + Node* head = NULL; + Node* second = NULL; + Node* third = NULL; + + // allocate 3 nodes in the heap + head = new Node(); + second = new Node(); + third = new Node(); + + head->data = 1; // assign data in first node + head->next = second; // Link first node with second + + second->data = 2; // assign data to second node + second->next = third; + + third->data = 3; // assign data to third node + third->next = NULL; + + // Function call + printList(head); + + return 0; +} + +``` + ## Stacks Stacks are a type of container adaptors with LIFO(Last In First Out) type of working, where a new element is added at one end (top) and an element is removed from that end only. diff --git a/javascript.md b/javascript.md index 463ff27..a5d1b5d 100644 --- a/javascript.md +++ b/javascript.md @@ -349,3 +349,24 @@ throw "Error message"; // throw error text to user |g| Performs a global match and finds all| |i| Performs case-insensitive matching| |m| Performs multiline matching| + +## Closures + +A closure is the combination of a function bundled together (enclosed) with references + to its surrounding state (the lexical environment). In other words, a closure gives you +access to an outer function's scope from an inner function. In JavaScript, closures are +created every time a function is created, at function creation time. + +### Example +```javascript +function makeFunc() { + const name = 'Mozilla'; + function displayName() { + console.log(name); + } + return displayName; +} +const myFunc = makeFunc(); +myFunc(); +``` + diff --git a/linux.md b/linux.md index 5835dac..502c838 100644 --- a/linux.md +++ b/linux.md @@ -42,3 +42,10 @@ tar -zcvf foo.txt.tar.gz foo.txt tar -xvf foo.txt.tar.gz ``` +## Text Editor Options for Programmers + +```c +Sublime Text Atom GNU Emacs +Vim Gedit Notepadqq +Nano VsCode Brackets +```