Server Side Programming Articles

Page 747 of 2109

How to check whether the tree is symmetric or not using iterative in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 249 Views

A symmetric binary tree is one where the left subtree is a mirror reflection of the right subtree. In the iterative approach, we use two queues to traverse both subtrees simultaneously and compare their values in mirror positions. The algorithm works by enqueueing nodes from the left and right subtrees in opposite orders. For the left subtree, we add left child first, then right child. For the right subtree, we add right child first, then left child. This ensures we compare mirror positions correctly. Syntax Following is the basic structure for checking tree symmetry iteratively − ...

Read More

How to check whether the tree is symmetric or not using recursion in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 274 Views

A symmetric binary tree is a tree where the left subtree is a mirror image of the right subtree. In C#, we can check if a tree is symmetric using recursion by comparing corresponding nodes from left and right subtrees. The recursive approach works by first checking if the tree is null (which is symmetric by definition), then calling a helper method to compare the left and right subtrees as mirror images of each other. Algorithm Steps If the root is null, the tree is symmetric Compare left subtree with right subtree using a mirror comparison ...

Read More

How to rotate an array k time using C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 1K+ Views

Array rotation is a common programming problem where elements are shifted by k positions. When we rotate an array to the right by k positions, the last k elements move to the beginning, and the remaining elements shift right. For example, if we have array [1, 2, 3, 4, 5] and rotate it right by 2 positions, we get [4, 5, 1, 2, 3]. Algorithm The most efficient approach uses the reversal algorithm which works in three steps − Reverse the entire array Reverse the first k elements Reverse the remaining elements from position k ...

Read More

What are the different ways to find missing numbers in a sorted array without any inbuilt functions using C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 2K+ Views

Finding missing numbers in a sorted array is a common programming problem with multiple efficient solutions. This article explores three different approaches to identify missing numbers without using built-in functions in C#. Each method has its own advantages in terms of time and space complexity, making them suitable for different scenarios depending on your specific requirements. Using Sum Formula (Mathematical Approach) This method uses the mathematical formula n(n+1)/2 to calculate the expected sum of consecutive numbers, then subtracts the actual sum of array elements to find the missing number − using System; public class ...

Read More

How to find the missing number and the repeated number in a sorted array without using any inbuilt functions using C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 382 Views

Finding the missing number and the repeated number in a sorted array is a common programming problem. This article demonstrates how to solve this problem without using any built-in functions in C#. The approach uses a boolean array to track which numbers are present and an integer array to count occurrences. By traversing the original array and marking elements in auxiliary arrays, we can identify both the missing and repeated elements efficiently. Algorithm Overview The solution works in two main steps − Finding the missing number: Create a boolean array and mark elements as ...

Read More

How to find the unique combination k sum that corresponds to k sum using C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 349 Views

The k-sum combination problem involves finding all unique combinations of exactly k numbers from a given range that sum up to a specific target value. This is solved using backtracking, which explores all possible combinations while pruning invalid paths early. The algorithm maintains two lists: an output list to store valid combinations and a currentList to track the current combination being explored. The backtracking function recursively explores combinations, adding numbers one by one until either the target sum is achieved with exactly k numbers, or the constraints are violated. How It Works The backtracking algorithm follows these ...

Read More

How to find the minimum number of steps needed by knight to reach the destination using C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 417 Views

In chess, a knight moves in an L-shape − two squares in one direction and one square perpendicular to that. This article explains how to find the minimum number of steps (moves) needed for a knight to reach a destination cell on a chessboard using Breadth-First Search (BFS) algorithm in C#. The knight's movement pattern creates a shortest path problem that can be efficiently solved using BFS, as it explores all possible moves level by level, guaranteeing the minimum number of steps. Knight's Movement Pattern A knight can move to at most 8 positions from any given ...

Read More

How to find the number of times array is rotated in the sorted array by recursion using C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 393 Views

To find the number of times a sorted array has been rotated, we need to locate the position of the minimum element. The number of rotations equals the index of the minimum element. We can solve this efficiently using binary search recursion. In a rotated sorted array, the minimum element is the pivot point where the rotation occurred. For example, in array [4, 5, 6, 1, 2, 3], the minimum element 1 is at index 3, meaning the array was rotated 3 times. Algorithm The recursive binary search approach works as follows − Find ...

Read More

C# Program to Find the List of Students whose Name Starts with ‘S’ using where() Method of List Collection using LINQ

Ankit kumar
Ankit kumar
Updated on 17-Mar-2026 598 Views

The Where() method in LINQ is a powerful filtering tool that allows you to query collections based on specific conditions. This article demonstrates how to use the Where() method with a List collection to find students whose names start with the letter 'S'. LINQ (Language Integrated Query) is a .NET framework feature that provides a consistent way to query different data sources using C# syntax. It eliminates the need for separate query languages like SQL when working with in-memory collections, making data filtering and manipulation more intuitive. Syntax The Where() method has the following syntax − ...

Read More

C# Program to Find the Negative Double Numbers From the List of Objects Using LINQ

Ankit kumar
Ankit kumar
Updated on 17-Mar-2026 593 Views

In this article, we will learn how to write a C# program to find the negative double numbers from a list of objects using LINQ. LINQ (Language Integrated Query) is a powerful feature in C# that allows developers to query data from various sources including arrays, collections, and databases. It provides SQL-like syntax for data manipulation and filtering, making complex data operations simple and readable. Problem Statement Given a list of objects containing different data types, we need to find only the negative double numbers using LINQ. This requires two filtering steps − Filter elements ...

Read More
Showing 7461–7470 of 21,090 articles
« Prev 1 745 746 747 748 749 2109 Next »
Advertisements