What are different types of Tries?

Sonal Meenu Singh
Updated on 04-Oct-2023 08:17:51

10 Views

Introduction In this tutorial, we will understand different types of tries and their uses. Tries are tree-like data structures that are mostly used for operations like string searching. There are various types of trie and they are used as per the task requirement. Generally, trie tries are of three types: Standard trie, compressed trie, and suffix trie. We elaborate on the meaning of each type of trie. What is Trie A trie is a sorted binary tree also called a digital tree or a prefix tree. It has nodes that are used to store data or alphabets. Each node can ... Read More

How to sort the string based on the number of matchsticks for representation?

Sonal Meenu Singh
Updated on 03-Oct-2023 18:56:27

21 Views

Introduction In this tutorial, we implement an approach to sort a string on the basis of the number of matchsticks required for its representation. In this approach, we use N numbers of matchsticks and sort an array. The array can contain numbers, words, or both. Matchsticks are used to arrange them in the shape of a particular number or character. Demonstration 1 Input = Arr = ["1", "3", "4"] Output = The sorted array is 1 4 3 Explanation In the above input array, the array elements are 1, 3, and 4 Number of matchsticks required for ... Read More

How to alphabetically sort an array while converting numbers into words?

Sonal Meenu Singh
Updated on 03-Oct-2023 18:54:31

14 Views

Introduction This tutorial deals with the problem of sorting an array alphabetically while each number is converted into words. To translate numbers into words means changing numbers to their number names. Like, 65 is sixty-five. Here, we consider a numerical array, convert all array elements to words and arrange them alphabetically. Print the sorted array elements after converting words to their respective numbers. Demonstration 1 Input = Arr = {13, 1, 6, 7} Output = 1 7 6 13 Explanation The input array elements are 13, 1, 6, 7 The output with alphabetically sorted elements is 1 7 ... Read More

Range Update Queries to XOR with 1 in a Binary Array

Sonal Meenu Singh
Updated on 03-Oct-2023 18:52:33

7 Views

Introduction In this tutorial, we find an approach to find the range update Queries to XOR with 1 in a binary array. To implement the approach we use a binary array which is an array consisting of 0 and 1. The range update queries are the queries which are used to modify the binary array within the given upper and lower limit of a range. The upper and lower limits are the index of binary array elements. The elements lying in that range are updated with defined operations. XOR is one of the bitwise operations standing for exclusive OR. Its ... Read More

Queries to search an element in an array and move it to front after every query

Sonal Meenu Singh
Updated on 03-Oct-2023 18:51:01

8 Views

Introduction In this tutorial, the task is to use queries to search for an element in an array. It is to push to the front after every query in C++. To implement this task, it takes an array A with elements from 1 to 5 and a query array Q for finding the element in A and moving it to the front of the array. The output is the index number of the searched elements. We use two methods for moving array elements to the front as per the query array. Naive Approach − Iterate through the array of ... Read More

How to Process strings using std::istringstream?

Sonal Meenu Singh
Updated on 03-Oct-2023 18:48:22

7 Views

Introduction In this tutorial, we will learn about the istringstream and how to use it for processing strings. istringstream is an object of string class defined in the header file. It is used for reading from the stream strings. A stream is a flow of data (collection of characters) between input-output devices and programs. The header file defines 3 string class objects, which are as follows − istringstream ostringstream Stringstream All are used for separate operations, like istringstream is responsible for stream input, ostringstream is for stream output, and stringstream handles both input and output of ... Read More

Queue.LIFOQueue vs Collections.Deque in Python

Kalyan Mishra
Updated on 03-Oct-2023 16:03:16

12 Views

In this article we will learn about Queue.LIFOQueue vs Collections.Deque in Python programming language. When we need to manage our data using the last in first out method then we can use these data structures. But to choose one of them we need to know about their functionalities and characteristics. Before that let’s get to know about Queue.LIFOQueue and Collections.Deque. LIFOQueue This class is part of the queue module. It works as stack data structure and it is considered as thread safe means we can talk between the different threads at the same time. Here are some specifications of ... Read More

Python - Replace sublist with others in list

Kalyan Mishra
Updated on 03-Oct-2023 15:48:19

9 Views

In this article we will get to know how we can replace sublist value with new list. You may have faced this problem while working with manipulation of list. Here we will see various methods using which we can replace the sublist with other list. Let’s get to know this using below example − listItem = [1, 2, 3, 4, 5, 6] new_list = [7, 8, 9] Here we have list named as listItem which contains some elements and we have another list named as new_list. So, we want to replace the sublist of listItem with new_list. Take ... Read More

Python - Replace rear word in String

Kalyan Mishra
Updated on 03-Oct-2023 15:42:20

9 Views

In this article we will learn how we can replace rear (word at the end of the string) word with any other given word. You may have seen this problem while doing manipulation of string. Here we will see various methods for replacing the rear word in string with given word. Let’s get to know this using below example − string_txt = "This cat is running very Fast" Here we have a string string_txt which contains sentences and we want to replace the last word which is "Fast" into "Slow" so that the resulting string will be like. ... Read More

Python - Replace punctuations with K

Kalyan Mishra
Updated on 03-Oct-2023 15:40:12

7 Views

In this article we will learn about replacement of punctuation with letter k in the string. You may have seen this problem while performing text processing or data cleaning task in the python where you need to replace punctuations with specific characters or any symbol. Here we will see various methods for replacing the punctuations with given text "k" Let’s get to know this using below example − string = "Welcome, to, * the website ! aliens" Here we have a string which contains punctuations like [, * !] and we want to replace that with text "k". ... Read More

1 2 3 4 5 ... 11340 Next
Advertisements