Articles on Trending Technologies

Technical articles with clear explanations and examples

Explain difference between == and is operator in Python.

Mahesh Parahar
Mahesh Parahar
Updated on 14-Mar-2026 356 Views

In Python, == and is are both comparison operators but they check different things. == checks if two objects have the same value (equality), while is checks if two variables point to the same object in memory (identity). == Operator (Equality) The == operator compares the values of two objects. If the values are equal, it returns True, regardless of whether they are stored at different memory locations. is Operator (Identity) The is operator checks whether two variables refer to the exact same object in memory (same id()). Even if two objects have equal values, is ...

Read More

Difference between Inverted Index and Forward Index

Mahesh Parahar
Mahesh Parahar
Updated on 14-Mar-2026 2K+ Views

Inverted Index and Forward Index are data structures used to search text within a document or a collection of documents. They differ in how they map the relationship between words and documents − one indexes by word, the other by document. Forward Index A forward index stores the document name as the key and maps it to the list of words contained in that document. It answers the question: "What words does this document contain?" Inverted Index An inverted index stores each word as the key and maps it to the list of documents that contain ...

Read More

Difference between two given time periods in C++

Mahesh Parahar
Mahesh Parahar
Updated on 14-Mar-2026 515 Views

Given two time periods in HH:MM:SS format where HH represents hours, MM represents minutes, and SS represents seconds, find the difference between them in the same format. The approach uses borrowing (similar to subtraction in arithmetic) when seconds or minutes of the smaller time are greater. Worked Example Time period 1 = 8:06:02 Time period 2 = 3:09:03 Step 1: Seconds: 02 < 03, borrow 1 minute → 62 - 03 = 59 seconds Step 2: Minutes: 05 < 09, borrow 1 hour → 65 - 09 = 56 minutes Step 3: Hours: ...

Read More

Differences between Data paths.

Mahesh Parahar
Mahesh Parahar
Updated on 14-Mar-2026 1K+ Views

A CPU has two main sections: the data section (data path) and the control section. The data path consists of registers, ALU, and interconnection buses that carry out the actual data processing. Data paths are classified into three types based on how instructions are executed − Single Cycle, Multiple Cycle, and Pipeline. Single Cycle Data Path In a single cycle data path, each instruction completes in exactly one clock cycle. The clock cycle must be long enough to accommodate the slowest instruction, which wastes time for simpler instructions. Multiple Cycle Data Path In a multiple cycle ...

Read More

Difference between Traits and Abstract Classes in Scala.

Mahesh Parahar
Mahesh Parahar
Updated on 14-Mar-2026 1K+ Views

In Scala, both traits and abstract classes can contain abstract and non-abstract methods. Traits are similar to Java interfaces (with default methods), while abstract classes are similar to Java abstract classes. The key difference is that traits support multiple inheritance, while abstract classes support only single inheritance. Traits Traits are created using the trait keyword. They can contain both abstract and concrete methods. A class can mix in multiple traits using the with keyword, and traits can also be added to individual object instances at creation time. Abstract Classes Abstract classes are created using the abstract ...

Read More

Difference between the largest and the smallest primes in an array in Java

Mahesh Parahar
Mahesh Parahar
Updated on 14-Mar-2026 997 Views

Given an array of integers (all elements less than 1, 000, 000), find the difference between the largest and smallest prime numbers in the array. Worked Example Array: [1, 2, 3, 4, 5] Primes in array: 2, 3, 5 Largest Prime = 5 Smallest Prime = 2 Difference = 5 - 2 = 3 Solution Approach Use the Sieve of Eratosthenes to pre-compute all prime numbers up to 1, 000, 000. Then scan the array to find the largest and smallest primes and return their difference. The sieve runs in ...

Read More

Difference between sums of odd level and even level nodes of a Binary Tree in Java

Mahesh Parahar
Mahesh Parahar
Updated on 14-Mar-2026 478 Views

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 More

Difference between sums of odd and even digits.

Mahesh Parahar
Mahesh Parahar
Updated on 14-Mar-2026 599 Views

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 More

Difference between sum of the squares of and square of sum first n natural numbers.

Mahesh Parahar
Mahesh Parahar
Updated on 14-Mar-2026 1K+ Views

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 More

Explain difference between Strong Entity and Weak Entity

Mahesh Parahar
Mahesh Parahar
Updated on 14-Mar-2026 15K+ Views

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 More
Showing 1–10 of 61,260 articles
« Prev 1 2 3 4 5 6126 Next »
Advertisements