0% found this document useful (0 votes)
16 views15 pages

QUESTIONS

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views15 pages

QUESTIONS

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

.

What is the time complexity of adding an element to a dynamic

array (ArrayList)? Answer: O(1) average, O(n) worst case.


.
.

Explain the concept of a binary search algorithm. Answer: Binary

search is a search algorithm that finds the position of a target value in

a sorted array by repeatedly dividing the search interval in half.


.
.

What is the time complexity of a binary search algorithm? Answer:

O(log n).
.
.

Define a linked list data structure. Answer: A linked list is a linear

data structure where elements are stored in nodes, and each node

points to the next node in the sequence.


.
.

What is the difference between a singly linked list and a doubly

linked list? Answer: In a singly linked list, each node points to the

next node, while in a doubly linked list, each node points to both the

next and previous nodes.


.
.
Explain the working of a stack data structure. Answer: A stack is a

Last-In-First-Out (LIFO) data structure where elements can be added

or removed only from one end called the top.


.
.

What is the time complexity of push and pop operations in a

stack? Answer: O(1).


.
.

Describe a queue data structure. Answer: A queue is a

First-In-First-Out (FIFO) data structure where elements are added at

the rear (enqueue) and removed from the front (dequeue).


.
.

What is the time complexity of enqueue and dequeue operations

in a queue? Answer: O(1).


.
.

Explain the concept of recursion in algorithms. Answer: Recursion

is a technique where a function calls itself to solve a smaller

subproblem of the same type.


.
.

What is the base case in a recursive function? Answer: The base

case is the condition that stops the recursion by providing a

straightforward solution without further recursion.


.
.
Define the concept of a binary tree. Answer: A binary tree is a

hierarchical data structure in which each node has at most two

children, left and right.


.
.

What is the difference between a binary tree and a binary search

tree (BST)? Answer: A binary search tree is a binary tree where the left

child is less than the parent, and the right child is greater.
.
.

Explain how depth-first search (DFS) algorithm works on a tree or

graph. Answer: DFS explores as far as possible along each branch

before backtracking.
.
.

What is the time complexity of DFS on a graph with V vertices

and E edges? Answer: O(V + E).


.
.

Describe how the breadth-first search (BFS) algorithm works.

Answer: BFS explores all the vertices at the current depth level before

moving to the next level.


.
.

What is the time complexity of BFS on a graph with V vertices

and E edges? Answer: O(V + E).


.
.
Explain the concept of a hash table. Answer: A hash table is a data

structure that stores key-value pairs and uses a hash function to map

keys to array indices.


.
.

What is the average time complexity of searching, insertion, and

deletion in a hash table? Answer: O(1).


.
.

Describe the concept of a heap data structure. Answer: A heap is a

specialized binary tree-based data structure where the parent node's

value is greater (max heap) or smaller (min heap) than its children.
.
.

What is the time complexity of inserting an element into a heap?

Answer: O(log n).


.
.

Explain the process of quicksort algorithm. Answer: Quicksort is a

sorting algorithm that selects a pivot element and partitions the array

into two sub-arrays - elements smaller than the pivot and elements

larger than the pivot.


.
.

What is the average time complexity of quicksort? Answer: O(n log

n).
.
.
Describe the merge sort algorithm. Answer: Merge sort is a

divide-and-conquer algorithm that divides the unsorted list into n

sublists, each containing one element, and then repeatedly merges

sublists to produce new sorted sublists until there is only one sorted

list.
.
.

What is the time complexity of merge sort? Answer: O(n log n).
.
.

Explain the concept of a graph data structure. Answer: A graph is a

collection of nodes (vertices) connected by edges that represent

relationships between the nodes.


.
.

Define a connected graph and a disconnected graph. Answer: A

connected graph has a path between every pair of vertices, while a

disconnected graph has at least two components that are not

connected.
.
.

Explain the Dijkstra's algorithm for finding the shortest path in a

weighted graph. Answer: Dijkstra's algorithm finds the shortest path

from a source node to all other nodes in a weighted graph with

non-negative edge weights.


.
.
What is the time complexity of Dijkstra's algorithm on a graph

with V vertices and E edges? Answer: O(V^2) with an array-based

implementation, or O(E log V) with a priority queue.


.
.

Describe the concept of dynamic programming. Answer: Dynamic

programming is a technique to solve problems by breaking them

down into overlapping subproblems and storing the results to avoid

redundant calculations.
.
.

What is the 0/1 knapsack problem, and how can you solve it

using dynamic programming? Answer: The 0/1 knapsack problem is

a combinatorial optimization problem where a knapsack with a fixed

capacity should be filled with items to maximize the total value. It can

be solved using dynamic programming with a 2D table.


.
.

Explain the concept of backtracking. Answer: Backtracking is a

technique to solve problems by incrementally building candidates for

the solution and abandoning a candidate as soon as it is determined

to be unfeasible.
.
.
Describe the concept of memoization in dynamic programming.

Answer: Memoization is a technique of caching computed results to

avoid redundant calculations in dynamic programming.


.
.

What is the time complexity of a binary search algorithm when

implemented recursively? Answer: O(log n).


.
.

Explain the concept of Big-O notation. Answer: Big-O notation is

used to describe the upper bound (worst-case scenario) of the growth

rate of an algorithm's time complexity with respect to the input size.

OOPS
.

What is Object-Oriented Programming (OOP)? Answer: OOP is a

programming paradigm that organizes code into objects, which are

instances of classes, and facilitates code reusability, modularity, and

maintainability.
.
.

Define a class and an object in OOP. Answer: A class is a blueprint or

template that defines the structure and behavior of objects. An object

is an instance of a class that encapsulates data and behavior.


.
.
What are the four pillars of OOP? Answer: The four pillars of OOP

are:
.

 Encapsulation: Bundling data and methods that operate

on the data within a single unit (class).

 Abstraction: Hiding the internal implementation details

and exposing only relevant functionalities.

 Inheritance: Allowing a class to inherit properties and

behaviors from another class.

 Polymorphism: Using a single interface to represent

different data types or objects.


.

Explain the concept of inheritance in OOP. Answer: Inheritance is

the ability of a class (subclass or derived class) to inherit properties

and behaviors from another class (superclass or base class).


.
.

What are access modifiers in OOP? Answer: Access modifiers

control the visibility and accessibility of class members (variables and

methods). Common access modifiers are public, private, protected,

and default (package-private).


.
.

Describe the concept of encapsulation. Answer: Encapsulation is

the bundling of data (attributes) and methods (behaviors) that


operate on the data within a class, making the class self-contained

and protecting the internal state from outside interference.


.
.

What is the purpose of the "static" keyword in OOP? Answer: The

"static" keyword is used to define class-level members (variables or

methods) that belong to the class itself, rather than to individual

objects. They can be accessed without creating an instance of the

class.
.
.

Explain the concept of polymorphism. Answer: Polymorphism

allows objects of different classes to be treated as objects of a

common superclass, enabling the use of a single interface to

represent multiple data types.


.
.

What are abstract classes in OOP? Answer: Abstract classes are

classes that cannot be instantiated and may contain abstract methods

(without implementation). They serve as a blueprint for other classes

to inherit from.
.
.

What is an interface in OOP? Answer: An interface is a contract that

defines a set of method signatures that must be implemented by any


class that implements the interface. It allows achieving multiple

inheritances in Java.
.
.

Explain the concept of method overloading. Answer: Method

overloading allows a class to have multiple methods with the same

name but different parameter lists. The appropriate method is called

based on the arguments passed.


.
.

What is method overriding in OOP? Answer: Method overriding

allows a subclass to provide a specific implementation of a method

that is already defined in its superclass. It allows for runtime

polymorphism.
.
.

What is the difference between "this" and "super" keywords in

Java? Answer: "this" refers to the current instance of the class, while

"super" refers to the immediate superclass of the class. They are used

to access instance variables and methods from the current class and

its superclass, respectively.


.
.

Explain the concept of constructor in OOP. Answer: A constructor is

a special method used to initialize the object's state when an instance


of the class is created. It has the same name as the class and does not

have a return type.


.
.

What is the purpose of the "final" keyword in OOP? Answer: The

"final" keyword is used to restrict changes to a variable, method, or

class. A final variable cannot be modified after initialization, a final

method cannot be overridden, and a final class cannot be inherited.


.

DBMS
.

What is a Database Management System (DBMS)? Answer: DBMS

is software that manages and organizes data in databases, ensuring

data integrity, security, and providing a means to interact with the

data.
.
.

What are the main components of a DBMS architecture? Answer:

The main components are:


.

 Data Storage: Manages data storage and retrieval.

 Query Processor: Translates user queries into efficient

execution plans.
 Transaction Manager: Ensures ACID properties for

database transactions.

 Data Dictionary: Stores metadata information about the

database.
.

Explain the difference between a DBMS and a Database. Answer: A

DBMS is the software that manages the database, while a database is

a structured collection of data that is organized and stored using a

DBMS.
.
.

What are the different types of database models? Answer: The

common types are:


.

 Relational Model: Uses tables to store data and represents

relationships between tables.

 NoSQL Model: Supports non-relational data structures for

flexible and scalable data storage.

 Hierarchical Model: Organizes data in a tree-like structure.

 Network Model: Represents data in a graph-like structure.


.

Explain the concept of primary key in a database. Answer: A

primary key is a unique identifier for each record in a table. It ensures


that each record can be uniquely identified and helps maintain data

integrity.
.
.

What is a foreign key in a database? Answer: A foreign key is a field

in a table that establishes a link between the data in two tables. It

refers to the primary key of another table and enforces referential

integrity.
.
.

Define database normalization. Answer: Database normalization is

the process of organizing data in a database to reduce redundancy

and dependency, leading to a more efficient and reliable database

design.
.
.

Explain ACID properties in the context of database transactions.

Answer: ACID stands for Atomicity, Consistency, Isolation, and

Durability. It ensures that database transactions are executed reliably

and consistently, even in the presence of failures.


.
.

What is the purpose of an index in a database? Answer: An index is

a data structure that improves data retrieval speed by allowing the

DBMS to find data quickly without scanning the entire table.


.
.
What is a deadlock in a database? Answer: A deadlock is a situation

where two or more transactions are waiting for each other to release

resources, leading to a state where none of the transactions can

proceed.
.
.

Explain the concept of database normalization. Answer: Database

normalization is the process of organizing data in a database to

reduce redundancy and dependency, leading to a more efficient and

reliable database design.


.
.

What is the difference between SQL and NoSQL databases?

Answer: SQL databases use structured query language and have

predefined schemas, while NoSQL databases allow for flexible and

schema-less data storage, often using key-value, document, or

columnar formats.
.
.

Describe the different types of JOINs in SQL. Answer: The common

types are:
.

 INNER JOIN: Returns rows with matching values in both

tables.
 LEFT JOIN (or LEFT OUTER JOIN): Returns all rows from

the left table and matching rows from the right table.

 RIGHT JOIN (or RIGHT OUTER JOIN): Returns all rows from

the right table and matching rows from the left table.

 FULL JOIN (or FULL OUTER JOIN): Returns all rows when

there is a match in either the left or right table.


.

What is a transaction in the context of databases? Answer: A

transaction is a sequence of one or more database operations that are

executed as a single unit. It ensures data consistency and integrity.


.
.

Explain the purpose of data normalization in databases. Answer:

Data normalization is the process of organizing data in a database to

reduce redundancy and dependency, leading to a more efficient and

reliable database design.


.

You might also like