- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Samual Sam has Published 2492 Articles
Samual Sam
75 Views
Here is the complete implementation of the MySet class. Exampleclass MySet { constructor() { this.container = {}; } display() { console.log(this.container); } has(val) { return this.container.hasOwnProperty(val); } add(val) { if (!this.has(val)) { ... Read More
Samual Sam
106 Views
Here is the complete implementation of the LinkedList class − Exampleclass LinkedList { constructor() { this.head = null; this.length = 0; } insert(data, position = this.length) { let node = new this.Node(data); if (this.head === ... Read More
Samual Sam
221 Views
Lets start by defining a simple class with a constructor that initializes the head and tail to null. We'll also define another structure on the prototype of the DoublyLinkedList class that'll represent each node in the linked list. Exampleclass LinkedList { constructor() { this.head = null; ... Read More
Samual Sam
438 Views
Removing an element is very easy in a linked list. We just need to get rid of the node we want to remove, ie, lose its reference. There are 3 cases we need to consider −Removing an element from head: In this case, we can simply assign head = head.next ... Read More
Samual Sam
146 Views
In the doubly linked list, the next pointer of the last node points to the first node and the previous pointer of the first node points to the last node making the circular in both directions.Insertions and deletions in a circular linked list are the same as other linked lists. ... Read More
Samual Sam
100 Views
Peeking a PriorityQueue means getting the value with the highest priority without removing it. So we can implement the peek function as follows &minusl Examplepeek() { if (isEmpty()) { console.log("Queue Underflow!"); return; } return this.container[this.container.length - 1]; }You can check if this ... Read More
Samual Sam
121 Views
Here is the complete implementation of the PriorityQueue class −Exampleclass PriorityQueue { constructor(maxSize) { // Set default max size if not provided if (isNaN(maxSize)) { maxSize = 10; } this.maxSize = maxSize; ... Read More
Samual Sam
110 Views
Following are the basic operations supported by a list.Insertion − add an element at the beginning of the list.Deletion − delete an element at the beginning of the list.Display − displaying the complete list.Search − search an element using given key.Delete − delete an element using given key.
Samual Sam
1K+ Views
We need to create a function insert(data, position) that inserts data at given position in the linked list. We'll perform the following steps −Create a new NodeCheck if the list is empty. If it then adds the node to head and return.If not, then we'll iterate to the position we ... Read More