Found 1862 Articles for Data Structure

Find time taken to Execute the Tasks in A Based on the Order of Execution in B

Neetika Khandelwal
Updated on 22-Aug-2023 17:34:51

62 Views

The goal is to determine the minimum time required to complete the tasks in queue A based on the order of execution in queue B, given two queues A and B, each of size N, where: Pop this task and run it if the task identified at the head of queue B is also at the head of queue A. Pop the current task from queue A and push it at the end if the task discovered at the front of queue B is not also found at the front of queue A. One unit of time is ... Read More

Find the Time Taken Finish Processing of given Processes

Neetika Khandelwal
Updated on 22-Aug-2023 17:31:50

44 Views

Given are N processes and two N−sized arrays, arr1[] and arr2[]. A process's time in the critical section is recorded in arr1[], and it’s time to finish processing after leaving the critical part is recorded in arr2. The goal is to determine how long it will take for each process to finish processing (both inside and outside of the critical section) in any given order. Input Output Scenarios Assume we have 3 arrays as shown below Input N = 3, arr1[] = {1, 4, 3}, arr2[] = {2, 3, 1} Output 9 The first process, at ... Read More

Find the Order of Execution of given N Processes in Round Robin Scheduling

Neetika Khandelwal
Updated on 22-Aug-2023 17:24:03

275 Views

In this article, you will learn about how to find the order of execution for the given N processes in the Round Robin Scheduling algorithm. But before starting with the code, let’s understand a bit about how this algorithm works. Round Robin Scheduling is a popular CPU scheduling algorithm used in operating systems to allocate CPU time to multiple processes in a fair and efficient manner. In this blog, we will explore how round−robin scheduling works, its advantages and disadvantages, and provide an example to help you understand the concept better. What is Round Robin Scheduling? Round Robin Scheduling is ... Read More

Advantages and Disadvantages of Three-tier Architecture

Neetika Khandelwal
Updated on 22-Aug-2023 17:21:29

2K+ Views

A 3−tier application architecture is a modular client−server architecture that consists of a presentation tier, an application tier, and a data tier. The presentation tier is a graphical user interface (GUI) that interacts with the other two tiers; the data tier stores information; the application tier manages logic. A 3−tier architecture has pros in terms of better horizontal scalability, performance, and availability. When there are three layers, each component can be produced concurrently by a separate team of programmers using a different programming language than the developers of the other levels. The 3−tier paradigm makes it simpler for an organization ... Read More

Ways to choose three points with distance between the most distant points <= L

Rinish Patidar
Updated on 21-Aug-2023 20:58:49

121 Views

The problem states that we need to figure out the number of ways to choose three points with distance between the most distant points less than or equal to L, a positive integer that will be given as an input. In the problem we will be given an array of different points which lies on the x-axis and an integer L greater than 0. The task involves finding the number of sets of three points where the distance between the most distant points is less than or equal to that integer L. NOTE : The set of points ... Read More

Two Odd Occurring Elements in an Array where all Other Occur Even Times

Rinish Patidar
Updated on 21-Aug-2023 20:50:41

180 Views

The problem includes finding two odd occurring elements in an array where all other elements occur even times in C++. An array is a data structure in C++ which is used to store a list of elements in it of similar data types. We will be given an array of any size greater than or equal to 2 in input. The array will contain integers in it. Every integer in the array will occur even times except two integers which will be occurring odd times in the array. In this problem, we need to find out those two elements ... Read More

Sum of Product of r and rth Binomial Coefficient (r * nCr)

Rinish Patidar
Updated on 21-Aug-2023 20:45:57

137 Views

The problem states that we must determine the sum of the product of r and the rth binomial coefficient (r*nCr). Positive numbers that are coefficients in the binomial theorem are called binomial coefficients. Both Pascal's triangle and a straightforward formula can be used to determine the binomial coefficients. The formula for binomial coefficient is: $$\mathrm{n_{c_{r}}=\frac{n!}{(n-r)!r!}}$$ NOTE : The value of 0! is always equal to 1. In this equation n and r can be any non-negative integers and r should never be greater than n. The objective at hand in this problem entails computing the ... Read More

Subtract 1 Without Arithmetic Operators

Rinish Patidar
Updated on 21-Aug-2023 18:30:20

290 Views

This problem includes that we need to subtract 1 without using arithmetic operators. We will be given any integer N as input in the problem and we need to subtract 1 from the number or simply we need to print N-1. Our task is to perform the operation without using any arithmetic operators. The arithmetic operations involves variety of operations on numbers like addition(+), subtraction(-), multiplication(*), division(/), modulo(%), etc. These operations are supported by every programming language on numbers. Despite using this we need to subtract 1 from the number. For example, Input 7 Output 6 Explanation ... Read More

Sorting of Vector of Tuple in C++ (Ascending Order)

Rinish Patidar
Updated on 21-Aug-2023 18:12:03

1K+ Views

We will discuss sorting the vector of Tuple in C++ in ascending order in this article. A list of elements are stored in a C++ data structure known as a tuple. The same or different data types may be contained in it, and we may access them in the same sequence in which they were initialised as inputs. A tuple's data is organised so that we can retrieve it in the same order. Syntax tuple name In C++, this is how we can initialise a tuple. We may require few more tuple functions to sort the vector ... Read More

Set the Rightmost Unset Bit

Rinish Patidar
Updated on 21-Aug-2023 18:31:40

329 Views

The problem statement includes setting the rightmost unset bit of any positive integer N in C++. A bit is simply a binary digit of any number when represented in the form of a binary number. A binary number is the numerical representation of any data in the form of 0 and 1 where every bit(digit) of the number represents the power of 2 starting with 2^0 from the unit digit. Let's represent an integer 7 in the form of a binary number. The binary representation of 7 will be 111. These numbers can either be represented ... Read More

Advertisements