Found 1862 Articles for Data Structure

Delete a Linked List Using Recursion

Vanshika Sood
Updated on 19-Apr-2023 11:04:06

836 Views

Linked List A linked list is a linear data structure in which the elements are stored at non-contiguous memory locations. Each element consists of a node. A node is composed of a data field, which holds the value of the element, and an address field, which points to the location of the next node in the series. The first node of the linked list is referred to as the ‘head’ of the list. The last element of the linked list can be defined as the element which points to NULL. A diagrammatic representation of a linked list is shown below. ... Read More

To Check if a Number is a Munchhausen Number

Vanshika Sood
Updated on 19-Apr-2023 11:02:04

400 Views

Munchhausen Numbers are peculiar numbers which possess a unique property. A number is considered to be munchhausen if the sum of the digits of the number, raised to their own power, is equal to the original number. These numbers are uncommon and not many of them are known. If the definition 00 = 0 is used, then 0 can also be considered a munchhausen number. The following article provides a method to determine whether a number is munchhausen or not while keeping in mind these characteristics of munchhausen numbers. Problem Statement The task at hand is to check whether a ... Read More

Difference between Map and HashMap

Pradeep Kumar
Updated on 18-Apr-2023 17:51:44

8K+ Views

We can store and retrieve key-value pairs using two popular data structures in programming: maps and hash maps. They both serve to symbolize a group of components that may be accessed by means of a special key. A collection of key-value pairs is represented using a Java interface called a Map. It is an abstract data type that offers methods for accessing, adding, and removing elements as well as a way to map keys to values. On the other hand, a HashMap is a real-world application of the Map interface. What are Maps? In computer science, a map is a ... Read More

Difference between ARP and RARP

Pranavnath
Updated on 18-Apr-2023 17:25:33

5K+ Views

ARP and RARP are the LAN (Local Area Network) protocols. A LAN is a fast, fault-tolerant data network that only covers a limited area of land. There are three types of LAN data transmissions unicast, multicast, and broadcast. A single packet is transferred from the source to a destination on the network during a unicast transmission. A single data packet is copied and delivered to a certain group of network nodes as part of a multicast transmission. A single data packet is copied and delivered to every network node as part of a broadcast transmission. Both ARP and RARP use ... Read More

Why does Youtube use TCP not UDP?

Pranavnath
Updated on 11-Apr-2023 17:29:51

3K+ Views

In the video on demand platform, YouTube is a popular one in the market. In such a demanding market to increase the audience a focus area should be a better experience and optimum video quality. This quality of the video depends on the streaming protocol it takes. Video streaming like YouTube prefers both TCP and UDP as per the goals and requirements. A TCP-based protocol known as Real-time Messaging Protocol (RTMP) is responsible for streaming video and audio content which provide low latency. The RTMP was developed by Macromedia. RTMP with a secure extension over a Transport layer security and ... Read More

Sort an array containing two types of elements

Vaishnavi Tripathi
Updated on 11-Apr-2023 17:02:38

211 Views

There are different approaches to sort an array containing only two types of elements i.e., only 1’s and 0’s. We will discuss three different approaches to do so. First approach simply uses a predefined sort() function to sort the given array. Second approach is a count sort approach in which we will count the number of zeroes and ones and then update the array by first writing zero for the number of times 0 was counted and then writing 1’s for the number of times we counted one. In the last approach, we used the two pointer method. Problem statement ... Read More

Expressing factorial n as sum of consecutive numbers

Vaishnavi Tripathi
Updated on 11-Apr-2023 17:01:33

220 Views

We will discuss two approaches to find out how we can express the factorial of a number as the sum of consecutive numbers. First one is a straightforward and simple approach while in the other approach we use the concept of arithmetic progression to make it less complex in terms of time and space occupied. Problem statement We are given a number and we need to find out the number of ways in which we can represent the factorial of the number as a sum of consecutive natural numbers. This involves two different functions − To find the ... Read More

Sorting array except elements in a subarray

Vaishnavi Tripathi
Updated on 11-Apr-2023 17:00:26

371 Views

This article is about how we can sort an array by neglecting a subarray of elements present in the same array. We will discuss two approaches for the same. The first approach is a brute force approach with time complexity O(n*n) while the second approach is by using an additional space to keep the sorted part of array other than the subarray. The time complexity of second approach is better i.e., O(nlogn). Problem Statement We are given an array of positive integers “nums” and two indices of the same array namely- left and right and we have to partially sort ... Read More

Undulating Numbers

Vaishnavi Tripathi
Updated on 11-Apr-2023 16:59:26

161 Views

In this article, we will learn what an undulating number is and our approaches to check whether a given number is undulating or not using a boolean function to check undulating numbers. Problem statement We will be given a number and our task is to check whether the given number is undulating. Let us first learn about an undulating number; An undulating number is a number that only consists of two types of digits and every second digit is the same. We can say an undulating number is of the form “PQPQPQ” where P and Q are two different digits ... Read More

Code Solution to sword puzzle

Vaishnavi Tripathi
Updated on 09-Feb-2024 16:22:38

220 Views

We will discuss two approaches to solve the sword puzzle. In the first approach, we will use circular linked list, while the second approach is based on general intuition. In this article, we will discuss what is a sword puzzle problem and how we can solve a sword puzzle problem. Problem Statement We have an arrangement of n people in a circle in which, first person is carrying a sword. The first person kills the second person and hands over the sword to the next alive person in the circle. Now the next person carrying the sword kills the next ... Read More

Advertisements