Prateek Jangid has Published 190 Articles

Searching an Element in a Linked List using C++

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 10:09:30

4K+ Views

To search an element in a linked list, we must iterate through the complete list, compare each node with the desired data, and keep searching until a match is obtained. Because a Linked List does not provide random access, we must start the search from the first node. We are ... Read More

C++ program to represent the Fraction of Two Numbers in the String Format

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 10:04:34

957 Views

We are given two integer numerators and a denominator. We need to represent the fraction of these two integers in string format. If a certain decimal is repeating, we need a bracket to show its repeating sequence. Algorithm (Steps) Following are the Algorithm/steps to be followed to perform the ... Read More

C++ program to replace an element makes array elements consecutive

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 10:01:57

428 Views

We are given an array of elements. We need to find if it is possible to change the value of any one element to make the array elements consecutive. If not possible, return -1 ; otherwise, the element needs to be changed. Let's suppose we have an array {4, 3, ... Read More

C++ program to search an element in a sorted rotated array

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 09:58:08

689 Views

We are given a sorted array which is rotated about a point. We are also given a key to search in the array. The logic adopted to search for an element in this rotated array is − First, we find the middle element of the array. If the key ... Read More

Searching an Element in Doubly Circular Linked List using C++

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 09:56:26

177 Views

Given a double circular linked list and key, we have to search the key in the linked list and give a proper message if found. Suppose we have a linked list with the specific characters, and we have to search for an element in it. So let's start with the ... Read More

C++ program to find Second Smallest Element in a Linked List

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 09:54:16

244 Views

An ordered collection of data elements, each with a link to its next element (and sometimes its predecessor), Suppose there is a linked list, then we need to find the second smallest element. The below are the following scenarios. Let’s assume some simple input and output scenarios Let’s assume this ... Read More

C++ program to find Second most repeated word in a sequence

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 09:52:54

230 Views

We are given an array of words, and we need to find the word whose frequency is the second largest in the array. Let’s assume some simple input and output scenarios Let’s assume we are having an array which consists of elements like [“point, ” “world, ” “articles, ” “articles, ... Read More

Smallest integer > 1 which divides every element of the given array: Using C++

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 09:51:06

156 Views

In this article, we are given integers in an array, and we must find the smallest number which is greater than 1 that divides all the elements in the array. For example, let us consider a sample array [30, 90, 15, 45, 165]. vector arr = {30, 90, 15, ... Read More

C++ program to Replace Nodes with Duplicates in Linked List

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 09:49:07

296 Views

In this article, we are given a linked list that contains elements from 1 to n and duplicates. Elements 1 to n will always be there with duplicates from [1..n]. We need to replace every duplicate element with n+1, n+2, and so on. Lets consider an example 1→2→2→4→5→3→6→6 Next n ... Read More

C++ program to Replace Every Matrix Element with Maximum of GCD of Row or Column

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 09:47:24

332 Views

In this method, we need to replace every element in the given matrix with the maximum Greatest Common Divisor (GCD) of that row and column. Let us look at some input scenarios − Suppose we are given a 2D matrix of dimensions m*n is; Input: [[3, 2, 1, 4] [7, ... Read More

Advertisements