Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 5 of 196

How to set a property value by reflection in C#?

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

The System.Reflection namespace in C# provides classes that allow you to obtain information about applications and dynamically add types, values, and objects at runtime. One of the most common uses of reflection is setting property values dynamically when you don't know the property name at compile time. Reflection allows you to examine various types in an assembly, instantiate these types, perform late binding to methods and properties, and even create new types at runtime. Syntax Following is the syntax for setting a property value using reflection − Type type = obj.GetType(); PropertyInfo property = type.GetProperty("PropertyName"); ...

Read More

How to implement coin change problem using bottom-up approach using C#?

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

The coin change problem is a classic dynamic programming challenge where we need to find the minimum number of coins required to make a given amount. The bottom-up approach builds solutions incrementally, starting from the smallest amounts and working up to the target amount. This approach uses dynamic programming to avoid recalculating the same subproblems multiple times, storing previously computed results in an array. Time complexity − O(n × t) where n is the amount and t is the number of coin types Space complexity − O(n) for the dynamic programming array Syntax Following is the ...

Read More

How to convert string to title case in C#?

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

Title case is any text, such as in a title or heading, where the first letter of major words is capitalized. Title case or headline case is a style of capitalization used for rendering the titles of published works or works of art in English. When using title case, all words are capitalized except for minor words (like articles, prepositions, and conjunctions) unless they are the first or last word of the title. C# provides the ToTitleCase method through the TextInfo class to convert strings to title case format. This method capitalizes the first letter of each word while ...

Read More

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

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 240 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 use String Format to show decimal up to 2 places or simple integer in C#?

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

The String.Format method in C# converts values to formatted strings and inserts them into another string. It's particularly useful for displaying numbers with consistent decimal places, showing integers as decimals when needed, or keeping integers without unnecessary decimal points. Syntax Following is the syntax for String.Format with decimal formatting − string.Format("{0:format}", value) Common decimal format specifiers − "{0:0.00}" // Always shows 2 decimal places "{0:F2}" // Fixed-point with 2 decimal places "{0:N2}" // Number format with 2 decimal places ...

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 263 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 invert a binary search tree using recursion in C#?

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

To invert a binary search tree, we swap the left and right child nodes for every node in the tree recursively. This operation creates a mirror image of the original tree. The algorithm uses a recursive approach where we process each node by first inverting its left and right subtrees, then swapping their positions. The process involves calling a method InvertBinaryTree that takes a node as a parameter. If the node is null, we return null. Otherwise, we recursively call the method on both left and right children, then swap the left and right child references. ...

Read More

How to check whether a binary tree is a valid binary search tree using recursion in C#?

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

A Binary Search Tree (BST) is a tree structure where each node's left child contains values smaller than the node, and the right child contains values greater than the node. To validate whether a binary tree is a valid BST using recursion, we need to check that each node's value falls within its allowed range based on its position in the tree. The recursive approach uses upper and lower bounds that get updated as we traverse the tree. For each node, we verify that its value lies within the current bounds, then recursively check the left subtree with updated ...

Read More

How to check whether a binary tree has the given path sum in C#?

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

A binary tree has a path sum when there exists a root-to-leaf path where the sum of all node values equals a given target sum. The HasPathSum method recursively traverses the tree, subtracting each node's value from the target sum until reaching a leaf node. Syntax Following is the syntax for checking path sum in a binary tree − public bool HasPathSum(Node node, int targetSum) { if (node == null) return false; if (node.LeftChild == null && node.RightChild == null) { ...

Read More

What is the difference between Static class and Singleton instance in C#?

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

A static class is declared using the static keyword and contains only static members that belong to the class itself rather than any instance. A Singleton is a design pattern that ensures only one instance of a class can be created and provides global access to that instance. Static Class A static class cannot be instantiated and all its members must be static. It is loaded automatically by the .NET Framework before the class is referenced for the first time − Syntax public static class ClassName { public static void Method() ...

Read More
Showing 41–50 of 1,958 articles
« Prev 1 3 4 5 6 7 196 Next »
Advertisements