Data Structure Articles

Found 1,635 articles

Python Program for Convert characters of a string to opposite case

Shubham Vora
Shubham Vora
Updated on 27-Mar-2026 643 Views

In this problem, we will toggle the case of each string character. The easiest way to toggle the case of each string character is using the swapcase() built-in method. Also, we can use the ASCII values of the characters to swap their case. Python also contains isupper() and islower() methods to check the character's case and the lower() and upper() methods to change the case. Problem statement − We have given a string. We need to toggle the case of string characters. It means converting uppercase characters to lowercase and lowercase characters to uppercase. Sample Examples ...

Read More

Python3 Program to Find Maximum number of 0s placed consecutively at the start and end in any rotation of a Binary String

Shubham Vora
Shubham Vora
Updated on 27-Mar-2026 244 Views

In this problem, we need to find the maximum sum of consecutive zeros at the start and end of any rotation of a binary string. We can solve this using two approaches: generating all rotations or using an optimized observation-based method. Problem Statement − Find the total number of maximum consecutive zeros at the start and end of any rotation of the given binary string. Examples Example 1 binary_str = "00100100" print(f"Input: {binary_str}") Input: 00100100 Output: 4 Explanation − Let's examine all rotations: 00100100 − Starting zeros: 2, ...

Read More

Replace two Substrings (of a String) with Each Other

Neetika Khandelwal
Neetika Khandelwal
Updated on 27-Mar-2026 263 Views

Replacing two substrings with each other requires careful handling of overlapping matches. Python provides several approaches to solve this problem efficiently using string methods and regular expressions. Problem Understanding Given a string S and two substrings A and B, we need to replace every occurrence of A with B and every occurrence of B with A. When both substrings are found at the same position, we prioritize the leftmost match. Example S = "aab" A = "aa" B = "bb" # Expected output: "bbb" print(f"Input: S='{S}', A='{A}', B='{B}'") Input: S='aab', A='aa', ...

Read More

Minimum number of given Operations Required to Convert a String to Another String

Neetika Khandelwal
Neetika Khandelwal
Updated on 27-Mar-2026 2K+ Views

You are given two strings A and B, the task is to convert string A to string B using only one operation: taking any character from A and inserting it at the front. We need to find the minimum number of such operations required for transformation. Problem Understanding The key insight is that we can only move characters from their current position to the front of the string. This means we need to work backwards and check which characters are already in the correct relative order. Example 1 For strings A = "ABD" and B = ...

Read More

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

Neetika Khandelwal
Neetika Khandelwal
Updated on 27-Mar-2026 782 Views

In this article, you will learn how to find the order of execution for given N processes using the Round Robin Scheduling algorithm. Round Robin is a preemptive CPU scheduling algorithm that allocates CPU time fairly among processes using fixed time slices. What is Round Robin Scheduling? Round Robin Scheduling is a preemptive scheduling algorithm where each process receives a fixed time slice (quantum) to execute. The CPU scheduler allocates time to processes in a circular order. Once a process uses its time slice, it's preempted and moved to the end of the ready queue. The time ...

Read More

Sort the string as per the ASCII values of the characters

Disha Gupta
Disha Gupta
Updated on 27-Mar-2026 3K+ Views

ASCII (American Standard Code for Information Interchange) assigns unique numeric values to characters. In Python, we can sort strings based on these ASCII values to arrange characters in ascending order. Problem Statement Given a string, we need to sort its characters according to their ASCII values in increasing order. Let's understand this with examples ? Example 1 Input: "$%7wjk()" Output: "$%()7jkw" The ASCII values are ? $ → 36 % → 37 ( → 40 ) → 41 7 → 55 j → 106 k → 107 w → 119 Example ...

Read More

Python Program To Write Your Own atoi()

Prabhdeep Singh
Prabhdeep Singh
Updated on 27-Mar-2026 626 Views

We are given a string that may represent a number and need to convert it into an integer using Python. The atoi() function is used in C programming to convert a string parameter into an integer value if the string is a valid integer, otherwise it shows undefined behavior. Sample Examples Input 1 string S = "9834" Output 9834 Explanation: The string represents a valid number, so we get the same output as an integer. Input 2 string S = "09 uy56" Output ...

Read More

On Disk Data Structures

Way2Class
Way2Class
Updated on 17-Mar-2026 2K+ Views

On-disk data structures are specialized data organization methods designed for persistent storage on physical media like hard drives and SSDs. Unlike in-memory structures, they are optimized for the unique characteristics of disk storage — slower access times, block-based I/O, and persistence across system restarts. These structures form the foundation of file systems, databases, and other storage-intensive applications. What are On-Disk Data Structures? On-disk data structures define how data is physically organized and accessed on storage devices. They differ from memory-based structures in several key ways: Block-oriented access — Data is read/written in blocks rather than individual ...

Read More

Hash Functions and Hash Tables

Alex Onsman
Alex Onsman
Updated on 17-Mar-2026 14K+ Views

Hashing is the process of generating a value from a text or a list of numbers using a mathematical function known as a hash function. Hash functions convert input data of arbitrary size into fixed-size hash values, which are used as indices in hash tables for efficient data storage and retrieval. Hash Functions Hash functions are algorithms that map data to fixed-size hash values. Here are the most commonly used hash functions − Division Method This is the simplest method to create a hash function. The hash function can be described as − h(k) ...

Read More

Bakery Algorithm in Process Synchronization

Manish Kumar Saini
Manish Kumar Saini
Updated on 17-Mar-2026 4K+ Views

It is a prerequisite to understand the terms "process synchronization", "critical section", and "inter-process communication" before we proceed to discuss the Bakery Algorithm in Process Synchronization. What is Process Synchronization? In a multiprocessing system, process synchronization is a method of coordinating execution of multiple processes so it is ensured that all processes access shared resources in a controlled and predictable manner. The primary goal of process synchronization is to avoid the problem of race conditions in the system. It also resolves many other issues related to synchronization in a concurrent system. Therefore, process synchronization ensures that multiple ...

Read More
Showing 1–10 of 1,635 articles
« Prev 1 2 3 4 5 164 Next »
Advertisements