# HackWithInfy System Engineer Technical Interview Questions and Answers

## HackWithInfy Technical Questions and Answer

Here below you will get System Engineer technical questions and answers. These are the most asked  interview questions of system engineer round 2.

This will surely help you in preparing for system engineer interview. So prepare well for the HackWithInfy Technical questions  of System Engineer role. ## HackWithInfy System Engineer role Interview 2022

#### Q1.Define a Relation Schema and a Relation.

Solution:-

A Relation Schema is specified as a set of attributes. It is also known as table schema. It defines what the name of the table is. Relation schema is known as the blueprint with the help of which we can explain that how the data is organized into tables. This blueprint contains no data.

A relation is specified as a set of tuples. A relation is the set of related attributes with identifying key attributes

#### Q2.What is the main difference between UNION and UNION ALL?

Solution:- UNION and UNION ALL are used to join the data from 2 or more tables but UNION removes duplicate rows and picks the rows which are distinct after combining the data from the tables whereas UNION ALL does not remove the duplicate rows, it just picks all the data from the tables.

#### Q3.How are the elements of a 2D array are stored in the memory?

Solution:- There are two techniques by using which, the elements of a 2D array can be stored in the memory.

• Row-Major Order: In row-major ordering, all the rows of the 2D array are stored into the memory contiguously. First, the 1st row of the array is stored into the memory completely, then the 2nd row of the array is stored into the memory completely and so on till the last row.
• Column-Major Order: In column-major ordering, all the columns of the 2D array are stored into the memory contiguously. first, the 1st column of the array is stored into the memory completely, then the 2nd row of the array is stored into the memory completely and so on till the last column of the array.

#### Q4. What is Huffman’s algorithm?

Solution:-Huffman’s algorithm is used for creating extended binary trees that have minimum weighted path lengths from the given weights. It makes use of a table that contains the frequency of occurrence for each data element.

#### Q5. Give some benefits of multithreaded programming.

Solution:- There is increased responsiveness to the user
– resource sharing within the process
– economy
– utilization of multiprocessing architecture

#### Q6.Calculate the address of a random element present in a 2D array, given base address as BA.

Solution:- Row-Major Order: If array is declared as a[m][n] where m is the number of rows while n is the number of columns, then address of an element a[i][j] of the array stored in row major order is calculated as,

Address(a[i][j]) = B. A. + (i * n + j) * size

Column-Major Order: If array is declared as a[m][n] where m is the number of rows while n is the number of columns, then address of an element a[i][j] of the array stored in column major order is calculated as

Address(a[i][j]) = ((j*m)+i)*Size + BA.

#### Q7.What is functional Dependency?

Solution:- Functional Dependency is the starting point of normalization. It exists when a relation between two attributes allow you to determine the corresponding attribute’s value uniquely. The functional dependency is also known as database dependency and defines as the relationship which occurs when one attribute in a relation uniquely determines another attribute. It is written as A->B which means B is functionally dependent on A.

#### Q8.What is BCNF?

Solution:- BCNF stands for Boyce-Codd Normal Form. It is an advanced version of 3NF, so it is also referred to as 3.5NF. BCNF is stricter than 3NF.

A table complies with BCNF if it satisfies the following conditions:

• It is in 3NF.
• For every functional dependency X->Y, X should be the super key of the table. It merely means that X cannot be a non-prime attribute if Y is a prime attribute.

#### Q9.What is a semaphore?

Solution:- – A semaphore is a hardware or a software tag variable whose value indicates the status of a common resource.
– Its purpose is to lock the common resource being used. A process which needs the resource will check the semaphore to determine the status of the resource followed by the decision for proceeding.
– In multitasking operating systems, the activities are synchronized by using the semaphore techniques.

#### Q10.Is non-pre-emptive scheduling frequently used in a computer? Why?

Solution:-

No, it is rarely used for the reasons mentioned below:

– It can not ensure that each user gets a share of CPU regularly.
– The idle time with this increases reducing the efficiency and overall performance of the system.
– It allows program to run indefinitely which means that other processes have to wait for very long.

#### Q11.Describe the types of keys?

Solution:- There are following types of keys:

Primary key: The Primary key is an attribute in a table that can uniquely identify each record in a table. It is compulsory for every table.

Candidate key: The Candidate key is an attribute or set of an attribute which can uniquely identify a tuple. The Primary key can be selected from these attributes.

Super key: The Super key is a set of attributes which can uniquely identify a tuple. Super key is a superset of the candidate key.

Foreign key: The Foreign key is a primary key from one table, which has a relationship with another table. It acts as a cross-reference between tables.

#### Q12.What are the drawbacks of array implementation of Queue?

Solution:-

• Memory Wastage: The space of the array, which is used to store queue elements, can never be reused to store the elements of that queue because the elements can only be inserted at front end and the value of front might be so high so that, all the space before that, can never be filled.
• Array Size: There might be situations in which, we may need to extend the queue to insert more elements if we use an array to implement queue, It will almost be impossible to extend the array size, therefore deciding the correct array size is always a problem in array implementation of queue.

#### Q13. How is the pattern matching done in the SQL?

Solution:-

With the help of the LIKE operator, pattern matching is possible in the SQL.’%’ is used with the LIKE operator when it matches with the 0 or more characters and ‘_’ is used to match the one particular character.

Example

SELECT * from Emp WHERE name like ‘b%’;
SELECT * from Emp WHERE name like ‘hans_’;

Q14.What is the difference between BETWEEN and IN condition operators?

Solution:-

The BETWEEN operator is used to display rows based on a range of values. The values can be numbers, text, and dates as well. BETWEEN operator gives us the count of all the values occurs between a particular range.

The IN condition operator is used to check for values contained in a specific set of values. IN operator is used when we have more than one value to choose.

#### Q15.What are the scenarios in which an element can be inserted into the circular queue?

Solution:-

• If (rear + 1)%maxsize = front, the queue is full. In that case, overflow occurs and therefore, insertion can not be performed in the queue.
• If rear != max – 1, the rear will be incremented to the mod(maxsize) and the new value will be inserted at the rear end of the queue.
• If front != 0 and rear = max – 1, it means that queue is not full therefore, set the value of rear to 0 and insert the new element there.

#### Q16.What is a constraint? Tell me about its various levels.

Solution:- Constraints are the rules and regulations which are applied to the table column which enforces yours to store valid data and prevents users to store irrelevant data. There are two levels :

1. column level constraint
2. table level constraint

#### Q17.Write an SQL query to get the third maximum salary of an employee from a table named employee_table.

Solution:-

1. SELECT TOP 1 salary
2. FROM (
3. SELECT TOP 3 salary
4. FROM employee_table
5. ORDER BY salary DESC ) AS emp
6. ORDER BY salary ASC;

#### Q18.What are the advantage of using threads?

Solution:- The main advantages of using threads are:

a.) No special communication mechanism is required.
b.) Readability and simplicity of program structure increases with threads.
c.) System becomes more efficient with less requirement of system resources.

#### Q19.Why is round robin algorithm considered better than first come first served algorithm?

Solution:-

The first come first served algorithm is the simplest scheduling algorithm known. The processes are assigned to the CPU on the basis of their arrival time in the ready queue. Since, it is non-preemptive once a process is assigned to the CPU, it will run till completion. Since a process takes the CPU till it is executed it is not very good in providing good response times. It can make other important processes wait un-necessarily.

On the other hand, the round robin algorithm works on the concept of time slice or also known as quantum. In this algorithm, every process is given a predefined amount of time to complete the process. In case, a process is not completed in its predefined time then it is assigned to the next process waiting in queue. In this way, a continuous execution of processes is maintained which would not have been possible in case of FCFS algorithm

#### Q20.Explain how a copying garbage collector works. How can it be implemented using semispaces?

Solution :-

The copying garbage collector basically works by going through live objects and copying them into a specific region in the memory. This collector traces through all the live objects one by one. This entire process is performed in a single pass. Any object that is not copied in memory is garbage.

The copying garbage collector can be implemented using semispaces by splitting the heap into two halves. Each half is a contiguous memory region. All the allocations are made from a single half of the heap only. When the specified heap is half full, the collector is immediately invoked and it copies the live objects into the other half of the heap. In this way, the first half of the heap then only contains garbage and eventually is overwritten in the next pass.