Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Server Side Programming Articles
Page 10 of 2110
How to print number of islands in a given matrix using C#?
An island in a matrix is a group of connected cells containing '1' (representing land) that are surrounded by '0' (representing water). Two cells are considered connected if they are adjacent horizontally or vertically. This problem uses Depth-First Search (DFS) to traverse and mark all connected land cells as visited. The algorithm performs a linear scan of the 2D grid. When it finds a '1' that hasn't been visited, it triggers a DFS to explore the entire connected island and marks all cells in that island as visited. Each DFS call represents one complete island. Algorithm Steps ...
Read MoreHow to find all the permutation of the string by backtracking using C#?
String permutation using backtracking is a classic algorithm that generates all possible arrangements of characters in a string. The approach works by fixing one character at a time and recursively finding permutations of the remaining characters, then backtracking to explore other possibilities. The core idea is to swap characters systematically − fix the first position with each character, find permutations of the rest, then backtrack by undoing the swap to try the next possibility. Backtracking Process for "ABC" ABC ...
Read MoreHow to get all the combinations of the keypad value in a mobile by backtracking using C#?
The problem of generating all possible letter combinations from mobile keypad digits can be solved efficiently using backtracking. This approach explores all possible paths by making choices, exploring them recursively, and backtracking when a complete combination is formed. On a traditional mobile keypad, each digit from 2-9 corresponds to a set of letters. The goal is to find all possible combinations when given a sequence of digits. Mobile Keypad Mapping 2 ABC 3 DEF 4 ...
Read MoreHow to find the target sum from the given array by backtracking using C#?
The target sum problem involves finding all possible combinations from a given array where the sum of elements equals a specific target value. The backtracking approach systematically explores all possible combinations by adding elements to the current solution and removing them when they don't lead to a valid result. Given an array of positive integers and a target sum, we need to find all combinations where elements can be reused and their sum equals the target. For example, with array [1, 2, 3] and target 4, valid combinations are [1, 1, 1, 1], [1, 1, 2], [1, 3], and ...
Read MoreHow to find the distinct subsets from a given array by backtracking using C#?
The distinct subsets problem involves finding all unique combinations of a specific size from a given array using backtracking. This technique systematically explores all possible combinations by adding elements to the current subset and then removing them to explore other possibilities. When we specify a target size, the algorithm generates all combinations that contain exactly that many elements. For example, with array [1, 2, 3] and target size 2, we get combinations "1, 2", "1, 3", and "2, 3". How Backtracking Works for Subsets The backtracking algorithm follows these steps − Choose − Add an ...
Read MoreHow to find all the different combinations of opening and closing brackets from the given number k using C#?
Finding all valid combinations of opening and closing brackets for a given number k is a classic backtracking problem in computer science. This problem generates all possible arrangements of k pairs of brackets where each opening bracket has a corresponding closing bracket in the correct order. The solution uses a recursive backtracking approach that builds valid bracket combinations by placing opening brackets when available and closing brackets only when they don't exceed the number of opening brackets already placed. Algorithm Overview The backtracking algorithm follows these key rules − Add an opening bracket if ...
Read MoreC# Program to estimate the size of the file using LINQ
The Language Integrated Query (LINQ) in C# provides powerful methods to work with data from various sources, including files and directories. In this article, we'll explore how to estimate file sizes using LINQ operations, specifically calculating the average file size in a directory. LINQ is part of the .NET framework that enables developers to write queries directly in C# using a SQL-like syntax. It provides a unified approach to query data from different sources like collections, databases, XML documents, and file systems. Syntax Following is the basic syntax for using LINQ to work with file information − ...
Read MoreC# Program to Generate Random Even Numbers Using LINQ Parallel Query
In this article, we will learn how to write a C# program that uses LINQ parallel query to generate random even numbers. LINQ (Language Integrated Query) is a powerful feature of C# that allows developers to query data from various sources using a consistent syntax. Parallel LINQ (PLINQ) extends LINQ to execute queries in parallel, improving performance for large datasets. Problem Explanation We need to create a program that generates random even numbers using LINQ parallel query. The solution involves using ParallelEnumerable.Range() to create a sequence of numbers, then applying the Where() clause to filter even numbers and ...
Read MoreC# Program to Generate Marksheet of Student
A marksheet generation program is a practical application that calculates a student's total marks, percentage, and grade based on subject scores. This C# program demonstrates how to create a simple marksheet system using basic input/output operations, arithmetic calculations, and conditional logic. Algorithm The marksheet generation follows these steps − Step 1 − Declare variables for student roll number, name, subject marks, total marks, and percentage. Step 2 − Accept input for student details and marks in each subject. Step 3 − Calculate total marks by summing all subject marks. Step 4 − Calculate percentage ...
Read MoreC# Program to Get and Print the Command Line Arguments Using Environment Class
The Environment class in C# provides access to current environment and platform information, including command line arguments. The Environment.CommandLine property retrieves the complete command line that started the current process, including the executable name and all arguments. Environment Class Overview The Environment class offers various properties and methods to access system information − Environment.CommandLine − Gets the complete command line Environment.GetCommandLineArgs() − Gets arguments as a string array Environment.CurrentDirectory − Gets current working directory Environment.OSVersion − Gets operating system version Environment.MachineName − Gets computer name Environment.ProcessorCount − Gets processor count ...
Read More