Posts

Link List

Data-Structure | Linear Category Link List - Code Example Single, Doubly, Circular class Node { constructor(data) { this.data = data; // single this.next = null; // Doubly //this.previous = null; } } // ############################################# // ############################################# class LinkList { // main --> starting point... // & this should be a Node constructor(head) { this.head = head; this.size = 1; } add(data) { const newNode = new Node(data); let currentNode = this.head; // checking until - null area not found... while (currentNode.next != null) { currentNode = currentNode.next; } currentNode.next = newNode; this.size++; } } // ######################################################## // ######################################################## // #########################

Dictionary

Data-Structure | Non-Linear Category Dictionary Code Example class Dictionary { // Time Complexity | Contestant Time // O(1) // empty object constructor() { this.dictionary = {} } // add data as { key : value } pair add(key, value) { this.dictionary[key] = value; } get(key) { return this.dictionary[key]; } } // ######################################################## // ######################################################## // ######################################################## const phoneBook = new Dictionary(); // add data into Dictionary phoneBook.add('Jon', '01717-112233'); phoneBook.add('Sam', '01712-334455'); phoneBook.add('Lee', '01717-556644'); console.log(phoneBook); // Dictionary { // dictionary: { Jon: '01717-112233', Sam: '01712-334455', Lee: '01717-556644' } // } console.

Queue

Data-Structure | Linear Category Queue Code Example // BluePrint || Static Thing class Queue { // FIFO = First In Fast Out | (Linear) Data-Structure constructor() { // empty queue this.queue = []; } // add new data in queue, one by one enqueue(data) { this.queue.push(data); } // remove data from queue, from front side dequeue() { if (this.queue.length) { return this.queue.shift(); } } } // ######################################################## // ######################################################## // ######################################################## // Object Creating || Dynamic Thing // Create an object of Queue class const numbers = new Queue(); numbers.enqueue(2); numbers.enqueue(4); numbers.enqueue(6); numbers.enqueue(8); console.log(numbers.queue); // [ 2, 4, 6, 8 ] numbers.dequeue(); console.log(numbers.queue); /

Stack

Data-Structure | Linear Category Stack Code Example  // BluePrint || Static Thing class Stack { // LIFO = Last In Fast Out | (Linear) Data-Structure constructor() { // empty stack this.stack = []; } // add new data in stack, one by one add(data) { this.stack.push(data); } // remove data from stack remove() { // for checking, is stack empty or not... if (this.stack.length) { return this.stack.pop(); } } } // ######################################################## // ######################################################## // ######################################################## // Object Creating || Dynamic Thing // Create an object of Stack class const person = new Stack(); person.add('Sam'); person.add('Jon'); person.add('Ken'); person.add('Lee'); // total object calling [its not a good approach] c

HTML CSS Bat Ball Hover Effect

Image
HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Transform</title> <link rel="stylesheet" href="style.css"> </head> <body> <h1>Hover on the bat ... </h1> <div class="field"> <img class="bat" src="img/bat.png"> <div class="ball"> </div> </div> </body> </html> CSS h1 { font-size : 50px; text-align : center; font-weight: bolder; font-family: 'Segoe UI'; } .field { border : 5px dotted green; background-color: rgba(4, 145, 4, 0.2); width : 85%; height : 550px; margin : auto; padding : 30px; } /***************** bat **************