In this problem, we are given a string that can be interpreted as a number. Now we have to perform the partition that string into two parts such that the first part is divisible by A and the second part is divisible by B (two integers given to us). For example −Input : str = "123", a = 12, b = 3 Output : YES 12 3 "12" is divisible by a and "3" is divisible by b. Input : str = "1200", a = 4, b = 3 Output : YES 12 00 Input : str = ... Read More
Given a linked list in this tutorial, and we need to keep all the numbers smaller than x at the start of the list and the others at the back. We also need to retain their order the same as previously. for exampleInput : 1->4->3->2->5->2->3, x = 3 Output: 1->2->2->3->3->4->5 Input : 1->4->2->10 x = 3 Output: 1->2->4->10 Input : 10->4->20->10->3 x = 3 Output: 3->10->4->20->10To solve this problem, we need to make three linked lists now. When we encounter a number smaller than x, then we insert it into the first list. Now for a value equal ... Read More
A number that contains all the digits from 0 to base B is called the Pandigital number in that base. However, some numbers have digits from 1 to 9 and are called zeroless pandigital numbers. Some Examples of pandigital numbers are 0123456789, 0789564312, etc.In this tutorial, we will discuss a problem where we are given a number and a base, and we need to check whether the number is pandigital in the given base or not, for example −Input: num = “9651723467380AZ”, base = 10 Output: YES Explanation: num contains all the digits in the base 10 i.e from 0 ... Read More
To solve a problem in which we are required to swap the pairwise nodes present in a linked list and then print it, for exampleInput : 1->2->3->4->5->6->NULL Output : 2->1->4->3->6->5->NULL Input : 1->2->3->4->5->NULL Output : 2->1->4->3->5->NULL Input : 1->NULL Output : 1->NULLThere are two ways to approach the solution both to have a time complexity of O(N), where N is the size of our provided linked list, so now we are going to explore both of the approachesIterative ApproachWe will iterate through the linked list elements in this approach, and pairwise swap them until they ... Read More
There are several popular text retrievals indexing techniques such as inverted indices and signature files.Inverted Index − An inverted index is an index structure that maintains two hash indexed or B+-tree indexed tables: document_table and term_table, where document_table consists of a set of document records, each including two fields: doc_id and posting_list, where posting_list is a list of methods (or pointers to methods) that appears in the document, arranged according to some relevance measure.term_table includes a set of term records, each including two fields: term_id and posting_list, where posting_list specifies a list of records identifiers in which the term occurs.It ... Read More
Text retrieval is the process of transforming unstructured text into a structured format to identify meaningful patterns and new insights. By using advanced analytical techniques, including Naïve Bayes, Support Vector Machines (SVM), and other deep learning algorithms, organizations are able to explore and find hidden relationships inside their unstructured data. There are two methods of text retrieval which are as follows −Document Selection − In document selection methods, the query is regarded as defining constraint for choosing relevant documents. A general approach of this category is the Boolean retrieval model, in which a document is defined by a set of ... Read More
Given a binary tree. The task is to pairwise swap the leaf nodes, for example −Input −Output −We will keep track of two pointers that point to the two adjacent leaf nodes and swap their values in the given problem.Approach to Find the SolutionIn this approach, we traverse the tree, find the leaf nodes, and keep track of our counter to check the current count. The main trick is that our counter is odd, so our first pointer points to that node now. When our counter becomes even, we swap the data, and hence our leaf nodes are swapped.ExampleC++ Code ... Read More
Information retrieval (IR) is a field that has been developing in parallel with database systems for many years. Unlike the field of database systems, which has targeted query and transaction processing of structured data, information retrieval is concerned with the organization and retrieval of data from multiple text-based documents.Since information retrieval and database systems each handle different kinds of data, some database system problems are usually not present in information retrieval systems, such as concurrency control, recovery, transaction management, and update. There are some common information retrieval problems that are usually not encountered in traditional database systems, such as unstructured ... Read More
To find the largest subset from the given array in which the sum of every pair is a prime number. Assuming maximum element is 100000, for example −Input: nums[ ] = { 3, 2, 1, 1 } Output: size = 3, subset = { 2, 1, 1 } Explanation: Subsets can be formed: {3, 2}, {2, 1} and { 2, 1, 1}, In {2, 1, 1} sum of pair (2, 1) is 3 which is prime, and the sum of pairs (1, 1) is 2 which is also a prime number. Input: nums[ ] = {1, 4, 3, 2} ... Read More
Given a binary tree. Now we are tasked to find the largest subtree having an equal number of 1's and 0's; the tree only contains 0's and 1's.Approach to Find the SolutionIn this approach, we are going to replace all the nodes with values of 0 to -1. Doing this will make our program simpler as we now need to find the largest subtree with a sum equal to 0.ExampleC++ Code for the Above Approach #include using namespace std; int maxi = -1; struct node { // structure of our tree node int data; struct ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP