Western Digital
Interview Questions and Answers
Q1. map vs unordered_map, vector vs list
map and unordered_map are associative containers while vector and list are sequence containers.
map and unordered_map are used to store key-value pairs while vector and list are used to store sequences of elements.
map and unordered_map provide faster search and insertion of elements while vector and list provide faster insertion and deletion of elements.
map and unordered_map use red-black trees and hash tables respectively while vector and list use arrays and linked lists resp...read more
Q2. Synchronisation of given thread blocks
Synchronizing thread blocks is important for efficient and correct execution of parallel programs.
Thread blocks must be synchronized to avoid race conditions and ensure correct program output.
Synchronization can be achieved using locks, semaphores, or barriers.
Examples of synchronization include ensuring that shared resources are accessed by only one thread at a time, or that threads wait for each other before proceeding.
Synchronization can also be used to optimize program pe...read more
Q3. Explain dynamic polymorphism
Dynamic polymorphism is the ability of an object to take on multiple forms during runtime.
It allows objects of different classes to be treated as if they are of the same class.
It is achieved through virtual functions and inheritance.
Examples include function overriding and templates in C++.
Q4. Types of casts in C++
C++ has four types of casts: static_cast, dynamic_cast, const_cast, and reinterpret_cast.
static_cast is used for implicit conversions between related types
dynamic_cast is used for runtime type checking and casting of polymorphic types
const_cast is used to remove const or volatile qualifiers from a variable
reinterpret_cast is used for low-level casting between unrelated types
Examples: static_cast
(3.14), dynamic_cast (basePtr), const_cast (str), reinterpret_cast (&ptr)
Q5. Functors in C++, uses
Functors are objects that can be treated as functions in C++. They are used for generic programming and can be passed as arguments.
Functors are often used in algorithms that require a function object as a parameter.
They can be used to implement callbacks and event handlers.
Functors can be used to create custom comparators for sorting algorithms.
They can also be used to implement function objects for mathematical operations.
Examples of functors in C++ include std::function, st...read more
Q6. IPC mechanisms in Linux
IPC mechanisms in Linux are used for inter-process communication between processes running on the same system.
IPC mechanisms include pipes, message queues, shared memory, and semaphores.
Pipes are used for one-way communication between two processes.
Message queues allow for asynchronous communication between processes.
Shared memory allows multiple processes to access the same memory space.
Semaphores are used for synchronization between processes.
IPC mechanisms can be accessed ...read more
More about working at Western Digital
Reviews
Interviews
Salaries
Users/Month