Compiler vs Interpreter
Interpreter
Translates program one statement at a time
It takes less amount of time to analyze the source code but the overall execution time is slower
Continues translating the program until the first error is met, in which case it stops. Hence debugging is easy.
No intermediate object code is generated, hence is memory efficient.
Compiler
Scans the entire program and translates it as a whole into machine code
It takes a large amount of time to analyze the source code but the overall execution time is comparatively faster
It generates the error message only after scanning the whole program. Hence debugging is comparatively hard.
Generates intermediate object code which further requires linking, and hence requires more memory.
Operating System
OS
An operating system is a system that manages computer hardware and software resources and provides common services for computer programs.
Components of OS
Process Management
Memory Management
I/O Device Management
File System
Protection
Network Management
Network Services (Distributed Computing)
User Interface
Kernel
Device Drivers
Security and Access Control
Networking and Communication
System Utilities
Shell
Multitasking/Multiprocessing vs Multithreading
Multitasking/Multiprocessing: Multitasking/Multiprocessing refers to the concurrent execution of multiple tasks or processes by an operating system, enabling efficient sharing of the CPU's time among them.
Multithreading: Multithreading involves dividing a single program into smaller threads that can execute concurrently, allowing for better resource utilization, improved performance, and responsiveness.
Advantage Thread over Process
Much quicker to create a thread than a process
Much quicker to switch between threads than to switch between processes
Threads share data easily
What is the Simplest method to prove that a Graph is Bipartite?
The simplest method to prove that a graph is bipartite is by using a graph coloring algorithm, such as the Two-Coloring or Bipartite Coloring algorithm. This method involves assigning two distinct colors (often denoted as "0" and "1") to the vertices of the graph in such a way that no two adjacent vertices share the same color. If you can successfully color all the vertices of the graph using only two colors without violating the adjacency rule, then the graph is bipartite.
Here's how the algorithm works:
1. Start with an arbitrary vertex and assign it a color (e.g., color "0").
2. Traverse the graph using Breadth-First Search (BFS) or Depth-First Search (DFS), and assign colors alternately to adjacent vertices that haven't been colored yet.
3. If at any point you encounter an edge connecting two vertices of the same color, then the graph is not bipartite. If all edges satisfy the coloring condition, the graph is bipartite.
The simplicity of this method lies in its intuitive process of coloring vertices while checking for adjacent vertices with the same color. If you can successfully color the entire graph without any conflicts, you've proven that the graph is bipartite. This algorithm has a time complexity of O(V + E), where V is the number of vertices and E is the number of edges in the graph.
In C what is the correct syntax to send a 3-dimension array as a parameter?
int sum3darray(int a[][3][3], int size);
Or,
int sum(int(*a)[3][3], int size);
In Java what is true about Private Constructors?
The use of a private constructor is to serve singleton classes. A singleton class is one which limits the number of objects created to one. Using a private constructor we can ensure that no more than one object can be created at a time.
C Data Types
Types: int
Size: at least 2, usually 4 bytes
Format Specifier: %d, %i
Types: char
Size: 1 byte
Format Specifier: %c
Types: float
Size: 4 bytes
Format Specifier: %f
Types: double
Size: 8 bytes
Format Specifier: %lf