Tip 1 : Must do Previously asked Interview as well as Online Test Questions.
Tip 2 : Go through all the previous interview experiences from Codestudio.
Tip 3 : Do at-least 2 good projects and you must know every bit of them.
Tip 1 : Have at-least 2 good projects explained in short with all important points covered.
Tip 2 : Every skill must be mentioned.
Tip 3 : Focus on skills, projects and experiences more.
The Number of elements smaller than 4 on its right side is 2.
The Number of elements smaller than 2 on its right side is 1.
The Number of elements smaller than 1 on its right side is 0.
The Number of elements smaller than 5 on its right side is 0.
Hence the count array is [2,1,0,0]
A critical section refers to a specific portion of code or a region in a program where shared resources are accessed or modified. It is a section that must be executed atomically, meaning that only one thread or process should be allowed to access it at any given time to avoid race conditions and ensure data integrity.
A mutex (short for mutual exclusion) is a synchronization mechanism used to protect critical sections in concurrent programming. It allows multiple threads or processes to safely access shared resources by ensuring that only one thread or process can enter the critical section at a time.
Semaphores are synchronization primitives used to control access to shared resources in a concurrent system. They help manage the execution order of multiple threads or processes to prevent race conditions and ensure proper synchronization. Semaphores maintain a count that can be incremented or decremented by threads or processes to control resource access.
Here's a high-level explanation of how semaphores work:
Initialization: A semaphore is created and initialized with an initial value. This value represents the number of available resources.
Acquiring (Wait): When a thread or process wants to access a shared resource, it attempts to acquire the semaphore. If the semaphore's count is greater than zero, it decrements the count and proceeds. Otherwise, if the count is zero, the thread or process is blocked until the count becomes greater than zero.
Releasing (Signal): When a thread or process finishes using a shared resource, it releases the semaphore by incrementing the count. This allows other threads or processes waiting on the semaphore to proceed.
Binary Semaphores: Binary semaphores are a specific type of semaphore where the count can only be either 0 or 1. They are often used for mutual exclusion purposes, such as ensuring only one thread or process can access a critical section at a time. Binary semaphores can be seen as a simplified version of mutexes.
Counting Semaphores: Counting semaphores, also known as general semaphores, have a count that can be any non-negative integer. They are used to control access to a pool of resources. Threads or processes can acquire and release multiple resources by decrementing and incrementing the count, respectively.
Difference between Mutex and Binary Semaphore: While binary semaphores and mutexes both provide mutual exclusion, there are some differences between them:
Ownership: Mutexes typically have an owner, meaning the thread that locks the mutex is responsible for unlocking it. In contrast, binary semaphores do not have an inherent ownership concept.
Count Value: Binary semaphores have a count that is either 0 or 1, representing the availability of a resource. Mutexes do not have a count value; they are either locked or unlocked.
Usage: Mutexes are often used to protect critical sections of code, allowing only one thread at a time to access the protected region. Binary semaphores, on the other hand, are more general-purpose and can be used to synchronize access to shared resources or coordinate activities among multiple threads or processes.
Signaling: Mutexes provide a mechanism for signaling between threads or processes, allowing them to wait until a specific condition is met. Binary semaphores, while they can be used for similar purposes, are primarily designed for mutual exclusion and resource availability control.
‘STR’ = “i am a Ninja”, ‘N’ = 3 and ‘WORDS[]’ = [“Ninja”,”a”,”am”]. Then the output should be [1,1,1]. Because the occurrence of “Ninja” in ‘STR’ is 1 and the occurrence of “a” in ‘STR’ is 1.Similarly occurrence of “am” is 1.
The output should be in the same order as given in ‘WORDS’.
(a, b) -> (a + b, b)
(a, b) -> (a, a + b)
For the coordinates, source point = (1, 1) and destination point = (3, 5)
The output will be true as the destination point can be reached using the following sequence of moves:
(1, 1) -> (1, 2) -> (3, 2) -> (3, 5)
An array ‘B’ is a subarray of an array ‘A’ if ‘B’ that can be obtained by deletion of, several elements(possibly none) from the start of ‘A’ and several elements(possibly none) from the end of ‘A’.
The diameter of a binary tree is the length of the longest path between any two end nodes in a tree.
The number of edges between two nodes represents the length of the path between them.
Input: Consider the given binary tree:
Output: 6
Explanation:
Nodes in the diameter are highlighted. The length of the diameter, i.e., the path length, is 6.
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you select an element by class name in CSS?