Prepppp
Prepppp
Prepppp
accessible by index.
Linked List: A linear collection of nodes where each node points to the next
node in the sequence.
Stack: A collection of elements with Last In, First Out (LIFO) access.
Queue: A collection of elements with First In, First Out (FIFO) access.
Hash Table: A data structure that maps keys to values using a hash function to
index into an array.
Tree: A hierarchical data structure with nodes connected by edges, often used to
represent hierarchical relationships.
Heap: A specialized tree-based structure that maintains the heap property (max-
heap or min-heap).
Graph: A collection of nodes (vertices) and edges connecting pairs of nodes,
which can be directed or undirected.
Trie: A tree-like data structure used for storing strings in a way that supports
efficient retrieval and prefix matching.
Disjoint Set (Union-Find): A data structure that keeps track of a partition of a
set into disjoint subsets with union and find operations.
Array – Collection of elements stored in contiguous memory locations for
index based access.
Class – used for creating objects
Linked list – contains nodes containing data parts And ref to next node for
insertions and deletions.
calloc
Purpose: Allocates memory for an array of elements and initializes all bytes to
zero.
malloc
Purpose: Allocates a specified number of bytes and returns a pointer to the
allocated memory.
OOP- Object oriented paradigm based on objects which contain data(attributes)
and methods(functions)
Encapsulation – way to restrict direct access to some components of an object,
hides all the complex details and shows what’s necessary
Inheritance – create new classes from existing ones, promotes code reuse
Polymorphism – to have or to be displayed in more than one form
Abstraction - hiding the implementation details of a code and expose only the
necessary info, simplify the complex systems by ignoring irrelevant details and
reduce complexity
Binary search tree – data structure in which each nodes has atmost two
children
Databases
Data Definition Language (DDL)
Purpose: Used to define and manage database schema objects like tables,
indexes, and constraints.
CREATE: Defines a new database object (e.g., table, index).
ALTER: Modifies an existing database object.
DROP: Deletes an existing database object.
TRUNCATE: Removes all records from a table but keeps the structure for
future use.
Data Control Language (DCL)
Purpose: Used to control access to data within the database, managing user
permissions and security.
GRANT: Gives specific privileges to users or roles.
REVOKE: Removes specific privileges from users or roles.
Transaction Control Language (TCL)
Purpose: Used to manage transactions in the database, ensuring data
integrity and consistency.COMMIT: Saves all changes made during the
current transaction.
ROLLBACK: Undoes changes made during the current transaction.
SAVEPOINT: Sets a point within a transaction to which you can later roll
back.
SET TRANSACTION: Configures the properties of the transaction.
Inner Join: Returns records that have matching values in both tables.
Left Join (Left Outer Join): Returns all records from the left table and the
matched records from the right table. Records from the left table with no match
in the right table will contain NULL.
Right Join (Right Outer Join): Returns all records from the right table and the
matched records from the left table. Records from the right table with no match
in the left table will contain NULL.
Full Join (Full Outer Join): Returns all records when there is a match in either
left or right table. Records without a match in one of the tables will contain
NULL.
Normalization – Process of organizing data to minimize redundancy and
improve data integrity
1NF – Eliminates duplicate columns
2NF - Removes subsets of data that can be applied to multiple rows
3NF – Removes columns not dependent on the primary key
SQL Query
Second highest salary from employees
SELECT MAX(salary) FROM employees
WHERE salary < (MAX(salary) FROM employees);
Operating systems
Virtual Memory - Virtual memory is a memory management technique that
provides an "idealized abstraction of the storage resources that are actually
available on a given machine" which "creates the illusion to users of a very
large (main) memory.
Explain the three-way handshake in TCP.
The three-way handshake is a process used in TCP/IP networks to establish a
connection between a client and server. It involves three steps:
1. SYN: The client sends a SYN (synchronize) message to the server.
2. SYN-ACK: The server responds with a SYN-ACK (synchronize-
acknowledge) message.
3. ACK: The client sends an ACK (acknowledge) message back to the
server, establishing the connection.
What are the different types of software testing?
Unit Testing: Tests individual components of the software.
Integration Testing: Tests the combination of units and their interactions.
System Testing: Tests the complete and integrated software.
Acceptance Testing: Tests the software in real-world scenarios to ensure it
meets business requirements.
Regression Testing: Ensures that new changes have not affected existing
functionality.
Process – instance of a program in execution containing code, data, resources
Thread – Smallest unit of process for parallel execution within the process
Deadlock – situation where set of processes are blocked cuz each process is
holding a resource and waiting for another resource which is held by another
process
Networking
TCP(Transmission control) – Connection oriented, reliable data transfer with
error checking and flow control.
UDP(User datagram) – Connectionless, faster but less reliable data transfer
without error checking.
OSI Model – conceptual framework to understand network interactions in
• Physical layer
• Data link layer
• Network layer
• Transport
• Session
• Presentation
• Application
Programs
1.Reverse a linked list
class Node:
def __init__(self, value):
self.value = value
self.next = None
def reverse_linked_list(head):
prev = None
current = head
while current:
next_node = current.next
current.next = prev
prev = current
current = next_node
return prev
2.Reverse a string
def reverse_string(s):
return s[::-1]