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
Articles by Mahesh Parahar
Page 5 of 15
Difference between sums of odd level and even level nodes of a Binary Tree in Java
Given a binary tree, find the difference between the sum of nodes at odd levels and the sum of nodes at even levels. The root is at level 1 (odd), its children are at level 2 (even), and so on. Problem Statement The tree structure for our example is − Level 1 (odd) Level 2 (even) Level 3 (odd) Level 4 (even) ...
Read MoreDifference between sums of odd and even digits.
Given a number n, check whether the difference between the sum of digits at odd positions and the sum of digits at even positions is zero. Positions are indexed starting from 0 (rightmost digit). Key Insight A number is divisible by 11 if and only if the alternating sum of its digits (difference between sum of digits at odd and even positions) is 0 or divisible by 11. So a simple n % 11 == 0 check can determine if the difference is zero. Worked Example For n = 1212112 − Digits: ...
Read MoreDifference between sum of the squares of and square of sum first n natural numbers.
Given a number n, find the difference between the square of the sum and the sum of the squares of the first n natural numbers. This is a classic mathematical problem that can be solved efficiently using direct formulas. Formulas The two formulas used are − Sum of squares of first n natural numbers: n(n+1)(2n+1) / 6 Sum of first n natural numbers: n(n+1) / 2, then square it The difference is: (Square of Sum) − (Sum of Squares). Worked Example For n = 3 − Sum of squares = ...
Read MoreExplain difference between Strong Entity and Weak Entity
In database design, entities are classified as strong or weak based on their independence. A strong entity can exist on its own with a primary key, while a weak entity depends on a strong entity and cannot be uniquely identified without it. Strong Entity A strong entity is independent of any other entity in the schema. It always has a primary key that uniquely identifies each instance. In an ER diagram, a strong entity is represented by a single rectangle, and a relationship between two strong entities is shown as a single diamond. Weak Entity A ...
Read MoreDifference between Static SQL and Dynamic SQL
Static SQL and Dynamic SQL are two approaches to writing SQL statements in applications. Static SQL uses fixed, hard-coded queries known at compile time, while Dynamic SQL constructs queries at runtime based on user input or program logic. Static SQL Static SQL refers to SQL statements that are fixed and hard-coded into the application. Since the queries are known at compile time, they can be pre-analyzed, optimized, and do not require special security handling. Example -- Static SQL: query is fixed at compile time SELECT name, salary FROM employees WHERE department = 'Engineering'; ...
Read MoreDifference between readonly and const keyword in C#
In C#, both readonly and const are used to create fields whose values cannot be modified after being set. The key difference is when the value is determined − const is resolved at compile time, while readonly is resolved at runtime (in the constructor). const Keyword The const keyword creates a compile-time constant. The value must be assigned at the time of declaration and cannot be changed afterward. const fields are implicitly static and can be declared inside methods. readonly Keyword The readonly keyword creates a runtime constant. The value can be assigned either at declaration ...
Read MoreDifference between Relational Algebra and Relational Calculus
Relational Algebra and Relational Calculus are both formal query languages used to retrieve data from relational databases. Relational Algebra is procedural (specifies how to get the result), while Relational Calculus is declarative (specifies what result to get). Both are equivalent in expressive power. Relational Algebra Relational Algebra is a procedural query language that takes instances of relations as input and yields instances of relations as output. It uses operators to perform queries step by step. The fundamental operations are − Select (σ) − Filters rows based on a condition Project (π) − Selects specific columns Union ...
Read MoreDifference between Optical fibre and Coaxial cable
Optical fibre and coaxial cable are both types of guided media used to transmit data over a network. Optical fibre is made of plastic and glass and transmits signals as light pulses, whereas coaxial cable is made of plastic and copper wires and transmits signals as electrical signals. Optical Fibre Optical fibre uses thin strands of glass or plastic to carry data as pulses of light. It offers extremely high speeds, very low signal loss over long distances, and is immune to electromagnetic interference. However, it is more expensive and complex to install. Coaxial Cable Coaxial ...
Read MoreDifference between Apache Kafka and Flume
Apache Kafka and Apache Flume are both used for real-time data processing and are developed by Apache. Kafka is a general-purpose publish-subscribe messaging system, while Flume is specifically designed for collecting and moving log data into the Hadoop ecosystem (HDFS). Apache Kafka Kafka is a distributed data store optimized for ingesting and processing streaming data in real time. It uses a publish-subscribe model where producers publish messages to topics and consumers pull messages at their own pace. Kafka is highly available, resilient to node failures, and supports automatic recovery. Apache Flume Flume is a distributed system ...
Read MoreDifference between Apache Kafka and Kinesis
Apache Kafka and Amazon Kinesis are both platforms for processing data streams in real time. Apache Kafka is an open-source distributed data store originally developed by LinkedIn, written in Scala and Java. Amazon Kinesis is a fully managed cloud service developed by Amazon, available only as an AWS service. Apache Kafka Apache Kafka is a distributed data store optimized for ingesting and processing streaming data in real time. It handles a constant influx of data from thousands of sources, processing records sequentially and incrementally. Kafka can be installed and run on local machines, on-premise servers, or in the ...
Read More