Interview All In One Questions.
Q. List out some areas in which data structure is applied extensively.
Robotics: Path Planning: Graphs and trees are used for path planning and navigation.
Sensor Data Management: Data structures help manage and process sensor data in real-
time.
Cryptography:
Encryption Algorithms: Data structures like matrices and arrays are used in various
encryption algorithms.
Operating Systems:
Process Scheduling: Queues, priority queues, and heaps are used to manage
processes and threads.
Databases:
Indexing: Data structures like B-trees and hash tables are used for indexing to
improve the speed of data retrieval.
Q. What is insertion sort and bubble sort?
Insertion sort is like sorting playing cards in your hands. You
split the cards into two groups: the sorted cards and the
unsorted cards. Then, you pick a card from the unsorted group
and put it in the right place in the sorted group.
We have to start with second element of the array as
first element in the array is assumed to be sorted.
Bubble Sort is the simplest sorting algorithm that works by repeatedly
swapping the adjacent elements if they are in the wrong order. This algorithm
is not suitable for large data sets as its average and worst-case time complexity
is quite high.
Bubble Sort Algorithm
In Bubble Sort algorithm,
traverse from left and compare adjacent elements and the higher one
is placed at right side.
In this way, the largest element is moved to the rightmost end at
first.
This process is then continued to find the second largest and place it
and so on until the data is sorted.
Q. What is a pointer?
A pointer is defined as a derived data type that can store the
address of other C variables or a memory location. We can
access and manipulate the data stored in that memory location
using pointers.
datatype * ptr;
ptr is the name of the pointer.
datatype is the type of data it is pointing to.
Q. Explain the difference between pass by reference and pass by value.
Call By Value :
In call by value method, the value of the actual parameters is copied into the
formal parameters.
In call by value method, we can not modify the value of the actual
parameter by the formal parameter.
In call by value, different memory is allocated for actual and formal
parameters since the value of the actual parameter is copied into the
formal parameter.
Call by reference:
In call by reference, the address of the variable is passed into the function
call as the actual parameter.
The value of the actual parameters can be modified by changing the
formal parameters since the address of the actual parameters is passed.
In call by reference, the memory allocation is similar for both formal
parameters and actual parameters. All the operations in the function are
performed on the value stored at the address of the actual parameters,
and the modified value gets stored at the same address.
Q. Explain compiler and interpreter.
The interpreter scans the program line by line and
translates it into machine code whereas the compiler
scans the entire program first and then translates it into
machine code.
The interpreter shows one error at a time whereas the
compiler shows all errors and warnings at the same time.
In the interpreter, the error occurs after scanning each
line whereas, in the compiler, the error occurs after
scanning the whole program.
In an interpreter, debugging is faster whereas, in the
compiler, debugging is slow.
Execution time is more in the interpreter whereas
execution time is less in the compiler.
An interpreter is used by languages such as Java, and
Python, and the compiler is used by languages such as C,
C++, etc.
7) Why java is platform independent?
The most unique feature of java is platform independent. In any programming language
soruce code is compiled in to executable code . This cannot be run across all platforms.
When javac compiles a java program it generates an executable file called .class file. class file
contains byte codes. Byte codes are interpreted only by JVM’s . Since these JVM’s are made
available across all platforms by Sun Microsystems, we can execute this byte code in any
platform. Byte code generated in windows environment can also be executed in linux
environment. This makes java platform independent.
Q. What is garbage Collector.
Garbage collection in Java is the process by which Java programs
perform automatic memory management. Java programs compile
to bytecode that can be run on a Java Virtual Machine, or JVM for
short. When Java programs run on the JVM, objects are created
on the heap, which is a portion of memory dedicated to the
program. Eventually, some objects will no longer be needed. The
garbage collector finds these unused objects and deletes them to
free up memory.
[Link] is normalization of databases?
o Normalization is the process of organizing the data in the database.
o Normalization is used to minimize the redundancy from a relation or
set of relations. It is also used to eliminate undesirable
characteristics like Insertion, Update, and Deletion Anomalies.
o Normalization divides the larger table into smaller and links them
using relationships.
o The normal form is used to reduce redundancy from the database
table.