Sai Teja Kotha

Sai Teja Kotha

9 Articles Published

Articles by Sai Teja Kotha

9 articles

Doubly linked lists in Javascript

Sai Teja Kotha
Sai Teja Kotha
Updated on 16-Dec-2022 2K+ Views

In this article, we are going to discuss a Doubly Linked List Class data structure in JavaScript. This is a linear data structure. Doubly linked lists are almost the same as a singly linked list in all operations, we just need to keep track of one extra link per node. In singly linked lists, we just had next links, in doubly linked lists, we have 2 links, next and prev. Doubly linked lists are represented as − Note that in the class itself, we also need to keep track of the tail(last element). Example In this example, we understand ...

Read More

Types of Linked List in Javascript

Sai Teja Kotha
Sai Teja Kotha
Updated on 16-Dec-2022 2K+ Views

In this article, we are going to discuss various types of linked lists in JavaScript. A linked list is a sequential data structure that stores data dynamically. Since, this data structure is not indexed, the data can be added and removed as seen fit. This will reduce the wastage of memory storage. There are various types of linked list. They are as follows − Simple Linked List − Item Navigation is forward only. Doubly Linked List − Items can be navigated forward and backward way. Circular Linked List − Last item contains link of the first element as next ...

Read More

The Priority Queue in Javascript

Sai Teja Kotha
Sai Teja Kotha
Updated on 16-Dec-2022 3K+ Views

In this article, we are going to discuss the priority queue data structure in JavaScript. A priority queue is an abstract data type (ADT) which is like a regular queue or stack data structure, but where additionally each element has a "priority" associated with it. In a priority queue, an element with high priority is served before an element with low priority. If two elements have the same priority, they are served according to their order in the queue. Example 1 The following example demonstrates the priority queue class data structure in JavaScript. Here, we insert the elements into the ...

Read More

Queue Data Structure in Javascript

Sai Teja Kotha
Sai Teja Kotha
Updated on 16-Dec-2022 710 Views

In this article, we are going to discuss the queue data structure in JavaScript. It is a linear data structure where the enqueue and dequeue of elements follow the FIFO (first in first out sequence). The queue is open at both ends. One end is always used to insert data and the other is used to remove data. Here, we use two pointers rear and front. The rear is used to insert the data and the front is used to remove the data. A real-world example of the queue can be a single-lane one-way road, where the vehicle enters first, ...

Read More

Stack Data Structure in Javascript

Sai Teja Kotha
Sai Teja Kotha
Updated on 08-Dec-2022 919 Views

In this article, we are going to discuss the stack data structure in JavaScript. A stack is an Abstract Data Type (ADT), commonly used in most programming languages. It is named stack as it behaves like a real-world stack, for example – a deck of cards or a pile of plates, etc. A stack allows operations at one end only. This feature makes it LIFO data structure. LIFO stands for Last-in-first-out. Here, the element which is placed (inserted or added) last, is accessed first. In stack terminology, insertion operation is called PUSH operation and removal operation is called POP ...

Read More

Removing an element from a given position of the array in Javascript

Sai Teja Kotha
Sai Teja Kotha
Updated on 07-Dec-2022 358 Views

In this article, we are going to discuss removing an element from a given position of the array in JavaScript. The delete operator, the slice() method, and the splice() method can be used to remove an element from a given position of the array in this article. Following is the syntax of the delete operator. let del = delete arr[index]; Following is the syntax of the slice() method. arr.slice(start, end) Following is the syntax of the splice() method. arr.splice(position, no_of_elem) Using delete Operator Example In this example, we are going to discuss the use of the ...

Read More

Removing an element from the start of the array in javascript

Sai Teja Kotha
Sai Teja Kotha
Updated on 07-Dec-2022 200 Views

In this article, we are going to discuss removing an element from the start of the array in JavaScript. For that, we are going to use the _.rest() method. This method returns the array elements except for the 0th indexed element. We can also use the shift() method and the slice() method to remove the first element from an array. Let us see the implementation of it further. Using _.rest() Method The following example demonstrates how to remove the start element from an array in JavaScript. Syntax The syntax of the _.rest() method is − _.rest( array, index ); ...

Read More

How to modify an array value of a JSON object in JavaScript?

Sai Teja Kotha
Sai Teja Kotha
Updated on 07-Dec-2022 8K+ Views

In this article, we are going to discuss how to modify an array value of a JSON object in JavaScript. We try to update a new value or modify the existing value in an array. Modifying an array is just like modifying an object when that array is inside the object. The normal general principles of modifying will apply here. Syntax Following is the syntax of the for…in statement. for (var in obj) { //code } Example 1 In this example, we are trying to loop through an array using the for…in statement. This statement ...

Read More

How to get the Width and Height of the screen in JavaScript?

Sai Teja Kotha
Sai Teja Kotha
Updated on 07-Dec-2022 10K+ Views

In this article, we are going to discuss how to get the width and height of the screen in JavaScript. Javascript provides an window.screen object that contains information regarding the user's screen. The information includes height and width, and also many other features. To find the height and width of the screen you need to use the following read-only properties Screen.height − This property is used to get the height of the screen in pixels. Screen.width − This property is used to get the width of the screen in pixels. Syntax Following is the syntax of the height ...

Read More
Showing 1–9 of 9 articles
« Prev 1 Next »
Advertisements