CSD
CSD Interview Questions and Answers
Q1. Swap Kth Elements in an Array
Given an array ARR
of size N
, perform the operation to swap the Kth element from the beginning with the Kth element from the end of the array.
Example:
Input:
N = 5, K = 2
ARR = [1,...read more
Swap Kth elements from the beginning and end of an array.
Create a temporary variable to store the Kth element from the beginning
Swap the Kth element from the beginning with the Kth element from the end
Return the modified array
Q2. Count Derangements
Determine the number of derangements possible for a set of 'N' elements. A derangement is a permutation where no element appears in its original position.
Input:
An integer 'T' representing t...read more
Count the number of derangements possible for a set of 'N' elements.
Use dynamic programming to calculate the number of derangements for each test case
The formula for derangements is D(n) = (n-1)*(D(n-1) + D(n-2)), with base cases D(1) = 0 and D(2) = 1
Calculate derangements modulo (10^9 + 7) to avoid overflow issues
Q3. Find the Second Largest Element
Given an array or list of integers 'ARR', identify the second largest element in 'ARR'.
If a second largest element does not exist, return -1.
Example:
Input:
ARR = [2, 4, 5, 6, ...read more
Find the second largest element in an array of integers.
Iterate through the array to find the largest and second largest elements.
Handle cases where all elements are identical by returning -1.
Consider edge cases like empty array or array with less than 2 elements.
Normalization in database management systems is the process of organizing data in a database to reduce redundancy and improve data integrity.
Normalization involves breaking down a database into smaller, more manageable tables.
It helps in reducing data redundancy by storing data in a structured manner.
Normalization ensures data integrity by minimizing data anomalies.
There are different normal forms such as 1NF, 2NF, 3NF, and BCNF that define the level of normalization.
For exam...read more
Interview experiences of popular companies
Calculate your in-hand salary
Confused about how your in-hand salary is calculated? Enter your annual salary (CTC) and get your in-hand salary
Reviews
Interviews
Salaries
Users/Month