Alternate Sorting of Linked List in C++

sudhir sharma
Updated on 16-Oct-2019 07:46:07

337 Views

A linked list is a linear data structure that stores elements and also stores a pointer to the next data node.In this problem on the sorting of a linked list, the alternate sort means sorting in such a way that the 1st node contains data with the minimum value, the 2nd node contains data with maximum value, 3rd with the next minimum (second minimum value) and so on. This pattern of alternate maxima and minimas is created in alternate sorting of linked lists.Let’s take an example to understand the problem better −Input : 3 > 4 > 21 >67 > ... Read More

Algorithm for Implementing Distributed Shared Memory

sudhir sharma
Updated on 16-Oct-2019 07:22:39

5K+ Views

Shared memory is the memory block that can be accessed by more than one program. A shared memory concept is used to provide a way of communication and provide less redundant memory management.Distributed Shared Memory abbreviated as DSM is the implementation of shared memory concept in distributed systems. The DSM system implements the shared memory models in loosely coupled systems that are deprived of a local physical shared memory in the system. In this type of system distributed shared memory provides a virtual memory space that is accessible by all the system (also known as nodes) of the distributed hierarchy.Some ... Read More

Allocate Minimum Number of Pages in C++

sudhir sharma
Updated on 16-Oct-2019 07:18:39

492 Views

Allocate a minimum number of pages is a programming problem. Let's discuss this problem in detail and see what can be the solution to it.StatementYou are given the number of pages of n different books. Also, there are m students to whom the books are to be assigned. The books are arranged in ascending order of the number of pages. And every student can be assigned some consecutive books. The program should return the maximum number of pages read by a student which should be minimum.Let's take an example to understand this problem in a better way, Input : books[] ... Read More

ARC Function in C

sudhir sharma
Updated on 16-Oct-2019 07:12:56

3K+ Views

In the C programming language, there is an option to create an arc of a circle of a given radius with a given center coordinates and degree of the arc.The arc() function is used to create an arc. This arc function is included in graphics.h library in C which contains methods that can draw figures on the output screen.Syntaxvoid arc(int x, int y, int startangle, int endangle, int radius);Now, let's get deep into the function and understand each parameter passed and output returned by the function.Parametersx − type = int, function: defines the x coordinate of the center of the arc.y ... Read More

Anonymous Classes in C++

sudhir sharma
Updated on 16-Oct-2019 07:09:38

3K+ Views

Anonymous entity is anything that is defined without a name. A class with no name provided is known as an anonymous class in c++. An anonymous class is a special class with one basic property.As there is no name given to the class there is no constructor allocated to it, though a destructor is there for deallocating the memory block.The class cannot be used as an element of a function i.e. you cannot pass it as an argument or cannot accept values return from the function.The syntax for defining an anonymous class in c++class {    //data members    // ... Read More

Aliquot Sequence in C++

sudhir sharma
Updated on 16-Oct-2019 06:56:44

369 Views

Aliquot sequence is a special sequence of numbers. The sequence starts from the number itself and the next number of the sequence is the sum of the proper divisors of the previous terms.Let’s take an example of the sequence to learn the concept better −Input : 8 Output : 8 7 1 0 Explanation :    Proper divisors of 8 are 4, 2, 1. The sum is 7    Proper divisors of 7 are 1. The sum is 1    Proper divisors of 1 are 0. The sum is 0Perfect number is the number that has the aliquot sequence of ... Read More

Generate Positive Rational Numbers in Java

sudhir sharma
Updated on 16-Oct-2019 06:47:04

832 Views

Rational Numbers − A number that is expressed in the form of p/q. Given the condition that p and q both should be integers and q should not be equal to 0.Positive rational numbers are those numbers whose final values are positive. For this, either p and q both should be positive or p and q both should be negative.In this problem to generate positive random numbers up to a given number. We have to generate a finite number of positive rational numbers to n i.e. we will find rational numbers between 1 to n. For this algorithm, we will ... Read More

Advanced JavaScript Backend Basics

sudhir sharma
Updated on 16-Oct-2019 06:36:48

728 Views

JavaScript programming language that is usually used for web scripting. It is a lightweight, interpreted programming language. JavaScript is one of the most programming languages for web development. For running JavaScript each browser has its own engine which enables the proper functioning of JavaScript in the browser. Some common Browsers and their JavaScript engines are −Spider Monkey for firefoxV8 for Google ChromeJavaScript code for SafariChakra for Microsoft Internet Explorer/ edgeTo make JavaScript universe and stop a browser from describing their own scripts. There is a standard set for JavaScript which will be used throughout the browser. there is an Association ... Read More

Virtual Copy Constructor in C++

sudhir sharma
Updated on 16-Oct-2019 06:32:23

7K+ Views

Before digging deep into the topics lets brush up all the related terms.A copy constructor is a special type of constructor that is used to create an object that is an exact copy of the object that is passed.A virtual function is a member function that is declared in the parent class and is redefined ( overridden) in a child class that inherits the parent class.With the use of a virtual copy constructor, the programmer will be able to create an object without knowing the exact data type of the object.In C++ programming language, copy Constructor is used to creating ... Read More

Remove Leading Zeroes from a String in Java Using Regular Expressions

Maruthi Krishna
Updated on 15-Oct-2019 12:51:11

8K+ Views

The replaceAll() method of the String class accepts two strings representing a regular expression and a replacement String and replaces the matched values with given String.Following is the regular expression to match the leading zeros of a string −The ^0+(?!$)";To remove the leading zeros from a string pass this as first parameter and “” as second parameter.ExampleThe following Java program reads an integer value from the user into a String and removes the leading zeroes from it using the Regular expressions. Live Demoimport java.util.Scanner; public class LeadingZeroesRE {    public static String removeLeadingZeroes(String str) {       String strPattern ... Read More

Advertisements