Add office photos
Employer?
Claim Account for FREE

Western Digital

3.5
based on 268 Reviews
Filter interviews by

10+ Interview Questions and Answers

Updated 3 Mar 2024

Q1. In DSA part, 1. Code for merge sort 2. Check if two trees are mirror 3. Find element in rotated sorted array 4. Check if linked list is palindrome 5. Detect a loop in linked list 6. Remove loop in linked list

Ans.

List of DSA questions including merge sort, tree mirror check, rotated sorted array search, linked list palindrome and loop detection and removal.

  • Merge sort is a divide and conquer algorithm that sorts an array in O(nlogn) time complexity.

  • To check if two trees are mirror, we need to compare their left and right subtrees recursively.

  • To find an element in a rotated sorted array, we can use binary search algorithm.

  • To check if a linked list is palindrome, we can use stack or recu...read more

Add your answer

Q2. What is structure padding and why it happens?

Ans.

Structure padding is the insertion of unused bytes between members of a structure to align the data in memory.

  • Padding is added to ensure that each member of the structure is aligned to a memory address that is a multiple of its size.

  • Padding can be compiler-dependent and can vary based on the target architecture.

  • Padding can affect the size of the structure and the performance of the program.

  • Example: struct MyStruct { char a; int b; char c; }; - padding will be added between a ...read more

Add your answer

Q3. map vs unordered_map, vector vs list

Ans.

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

Add your answer

Q4. Code for fibonacci series

Ans.

Fibonacci series is a sequence of numbers where each number is the sum of the two preceding ones.

  • Declare variables for first, second and next numbers

  • Initialize first and second numbers as 0 and 1 respectively

  • Loop through the desired number of terms and calculate the next number as the sum of the previous two

  • Store the result in an array

  • Return the array

Add your answer
Discover null interview dos and don'ts from real experiences

Q5. What do you know about HDD?

Ans.

HDD stands for Hard Disk Drive, a data storage device used in computers to store and retrieve digital information.

  • HDDs use magnetic storage to store data on spinning disks called platters.

  • They have read/write heads that move across the platters to access and modify data.

  • HDDs are typically used for long-term storage of large amounts of data in desktops, laptops, servers, and other devices.

  • Examples of HDD manufacturers include Seagate, Western Digital, and Toshiba.

Add your answer

Q6. Synchronisation of given thread blocks

Ans.

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

Add your answer

Q7. Explain dynamic polymorphism

Ans.

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++.

Add your answer

Q8. Types of casts in C++

Ans.

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)

Add your answer

Q9. Functors in C++, uses

Ans.

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

Add your answer

Q10. IPC mechanisms in Linux

Ans.

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

Add your answer
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
70 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter