Samsung
Proud winner of ABECA 2024 - AmbitionBox Employee Choice Awards
Filter interviews by
Operating system uses memory protection to prevent modification of const variables like const int i=5;
Operating system marks the memory page containing i as read-only
Any attempt to modify i will result in a segmentation fault
Compiler may optimize code by replacing i with its value at compile time
Explanation of memory layout in main memory of computer system.
Main memory is divided into four segments: stack, heap, data, and code.
Stack stores local variables and function calls.
Heap stores dynamically allocated memory.
Data stores global and static variables.
Code stores the program instructions.
Example: int x; //stored in data segment, int *p = new int; //stored in heap segment
Two methods to allocate memory in C are malloc and calloc. Malloc allocates memory block of given size while calloc initializes the allocated memory block to zero.
Malloc allocates memory block of given size while calloc initializes the allocated memory block to zero.
Malloc returns a pointer to the first byte of allocated memory block while calloc returns a pointer to the first byte of initialized memory block.
Malloc is...
new() is an operator in C++ used for dynamic memory allocation.
new() returns a pointer to the allocated memory.
It can be used to allocate memory for primitive data types, arrays, and objects.
Memory allocated using new() must be deallocated using delete operator.
Example: int *ptr = new int;
Example: int *arr = new int[10];
Example: MyClass *obj = new MyClass();
malloc and new are used to allocate memory dynamically. Malloc is faster but new is safer.
malloc is a C function while new is a C++ operator
malloc only allocates memory while new also initializes the memory
new throws an exception if allocation fails while malloc returns NULL
malloc is faster because it does not involve constructor calls
new is safer because it ensures type safety and prevents memory leaks
extern and static are storage classes in C programming language.
extern is used to declare a variable or function that is defined in another file or module.
static is used to declare a variable or function that is local to a file or module.
Example of extern: extern int count; //declares count variable defined in another file.
Example of static: static int count = 0; //declares count variable local to the file.
The two statements are equivalent and declare a pointer to a constant integer.
Both statements declare a pointer to an integer that cannot be modified through the pointer.
The 'const' keyword can be placed before or after the 'int' keyword.
The pointer itself can still be modified to point to a different integer.
Example: const int *p; and int const *p; both declare a pointer to a constant integer.
Cannot modify value pointed by p, but can change the address it points to.
p is a pointer to a constant integer with value 5
a) is valid as p can point to a non-constant integer
b) is invalid as *p is a constant and cannot be modified
Self referential structure is a structure that contains a pointer to the same type of structure.
It allows a structure to reference itself within its own definition.
It is commonly used in linked lists, trees, and graphs.
Example: struct Node { int data; struct Node *next; };
Here, the Node structure contains a pointer to another Node structure.
Structure and union are data structures in C language. Union stores only one value at a time while structure stores multiple values.
Structure is used to store different data types while union is used to store only one data type at a time.
Structure allocates memory for all its members while union allocates memory for only the largest member.
Structure is used when we want to store multiple values of different data types ...
Structure byte padding is the insertion of unused bytes between structure members to align them in memory.
Padding is added to ensure that each member of a structure is aligned on a memory boundary that is a multiple of its size.
The amount of padding added depends on the size and alignment requirements of the members.
Padding can affect the size of a structure and the performance of code that uses it.
For example, a struc...
To check if a linked list is circular, we can use Floyd's cycle-finding algorithm.
Floyd's cycle-finding algorithm uses two pointers, one moving at twice the speed of the other.
If the linked list is circular, the fast pointer will eventually catch up to the slow pointer.
If the linked list is not circular, the fast pointer will reach the end of the list and the algorithm will terminate.
Windows is a proprietary operating system developed by Microsoft.
Windows is a graphical user interface (GUI) based operating system.
It is designed to run on personal computers, servers, and mobile devices.
Windows has different versions such as Windows 10, Windows 8, Windows 7, etc.
It supports a wide range of software applications and hardware devices.
Windows is known for its ease of use and user-friendly interface.
UNIX is an operating system developed in the 1970s, while LINUX is a free and open-source operating system based on UNIX.
UNIX is proprietary, while LINUX is open-source
UNIX is older and has a longer history, while LINUX is a newer development
UNIX is more stable and reliable, while LINUX is more customizable and flexible
UNIX has a more limited user base, while LINUX has a larger and more active community
Examples of UNIX...
A real-time operating system is an OS that processes data and events as they occur, without delay.
Real-time operating systems are used in applications that require immediate response, such as aviation, medical equipment, and industrial control systems.
They prioritize tasks based on their urgency and importance, and can handle multiple tasks simultaneously.
Examples of real-time operating systems include VxWorks, QNX, an
There are 6 types of CPU scheduling: FCFS, SJF, SRTF, Priority, Round Robin, and Multilevel Queue. Each has its own advantages and disadvantages.
FCFS (First-Come-First-Serve) - processes are executed in the order they arrive
SJF (Shortest-Job-First) - shortest job is executed first
SRTF (Shortest-Remaining-Time-First) - preemptive version of SJF
Priority - processes with higher priority are executed first
Round Robin - eac...
No, there is no ideal CPU scheduling possible.
CPU scheduling is a complex problem with many variables.
Different scheduling algorithms are suited for different scenarios.
The ideal scheduling algorithm would depend on the specific system and workload.
For example, a real-time system would require a different scheduling algorithm than a batch processing system.
To set process priority in Windows and Linux, use task manager and nice command respectively.
In Windows, open task manager, right-click on the process and select 'Set Priority'
In Linux, use the 'nice' command followed by the process name or ID and the priority level (values range from -20 to 19)
Higher priority levels mean the process will get more CPU time
Examples: 'nice -n 10 firefox' sets Firefox priority to 10 in Li...
The priority of a mobile application depends on the business goals and user needs.
The priority of a mobile application can vary depending on the business goals and user needs.
For example, a mobile banking app may have a higher priority than a social media app for a bank.
On the other hand, a social media app may have a higher priority for a media company.
The priority can also depend on the target audience and the market...
Program to find all permutations of a string and discuss time complexity
Use recursion to generate all possible permutations
Swap characters to generate different permutations
Store permutations in an array of strings
Discuss time complexity as O(n!)
The Tower of Hanoi problem has a time complexity of O(2^n).
Time complexity is exponential, O(2^n).
The number of moves required to solve the Tower of Hanoi problem with n disks is 2^n - 1.
For example, with 3 disks, it takes 2^3 - 1 = 7 moves to solve the problem.
The function takes two polynomials represented as linked lists and returns a linked list representing their product.
Traverse both linked lists and multiply the corresponding coefficients of each term
Create a new linked list to store the product terms
Keep track of the current term in the product linked list and update it as you multiply
Handle cases where the product of coefficients is zero
Count the number of occurrences of the pattern 1[0]*1 in a given string.
Use regular expressions to match the pattern in the string.
Iterate through the string and count the number of matches found.
Consider edge cases such as when the pattern occurs at the beginning or end of the string.
Find minimum steps from (0,0) to (i,j) in boolean 2D matrix
Use Breadth First Search (BFS) to find the shortest path
Keep track of visited cells to avoid revisiting
Return -1 if no path is found
Samsung interview questions for popular designations
Yes, static variables can be defined in header files.
Static variables defined in header files have global scope within the file.
They can be accessed by any function within the file.
However, if the header file is included in multiple source files, each file will have its own copy of the static variable.
This can lead to unexpected behavior if the variable is modified in one file and then accessed in another.
It is general...
Yes, constant and volatile can be used together.
Constant variables are read-only and cannot be modified.
Volatile variables are used to indicate that the value may change unexpectedly.
Using both together can be useful in multi-threaded environments.
For example, a constant pointer to a volatile variable can be used to ensure thread safety.
Bi-directional linked list allows traversal in both directions, making it useful for certain algorithms.
Each node in the list has a reference to both the previous and next nodes.
Insertion and deletion operations are more complex than in a singly linked list.
Examples of use include implementing a browser's back and forward buttons or a text editor's undo and redo functionality.
OOPs properties and examples with applications
Encapsulation: bundling of data and methods within a class. Example: Java class. Application: data hiding and security.
Inheritance: creating a new class from an existing class. Example: subclass. Application: code reusability and extensibility.
Polymorphism: ability of an object to take on many forms. Example: method overloading. Application: flexibility and modularity.
Abstr...
Pointers and arrays are related concepts in C programming. Pointers hold memory addresses while arrays hold a collection of values.
Arrays are a collection of values stored in contiguous memory locations.
Pointers hold the memory address of a variable.
Arrays can decay into pointers when passed as arguments to functions.
Pointer arithmetic can be performed on pointers to access memory locations.
Pointers can be used to dyna
It depends on the specific use case and input size.
For small input sizes, simple algorithms like insertion sort or selection sort may be sufficient.
For larger input sizes, more complex algorithms like merge sort or quicksort may be more efficient.
For nearly sorted input, insertion sort may be the fastest.
For input with many duplicates, counting sort or radix sort may be the best choice.
For input with a known range, buc...
Check if a string is palindrome or not
Reverse the string and compare with original
Compare first and last characters and move towards center
Use recursion to check if first and last characters are equal
Get interview-ready with Top Samsung Interview Questions
Count the number of '-' characters in a string and return 1 if it matches the given number, else return 0.
Use a loop to iterate through each character in the string and count the number of '-' characters.
Compare the count with the given number and return 1 if they match, else return 0.
Handle edge cases such as empty string or negative number input.
Functions to create and delete nodes in a stack
To create a stack, initialize a top pointer to null
To push a node, create a new node and set its next to the current top, then set top to the new node
To pop a node, set top to its next and return the popped node
To delete the stack, pop all nodes until top is null
Code for producer-consumer problem using mutex
Create a shared buffer with a fixed size
Create a mutex to control access to the buffer
Create a semaphore to keep track of the number of items in the buffer
Create a producer thread that adds items to the buffer
Create a consumer thread that removes items from the buffer
Use mutex to lock the buffer while adding or removing items
Use semaphore to signal when the buffer is full o
Mutex and Semaphore are synchronization primitives used in multi-threaded environments.
Mutex is used to provide mutual exclusion to a shared resource, allowing only one thread to access it at a time.
Semaphore is used to control access to a shared resource, allowing multiple threads to access it at a time.
Mutex is binary, meaning it has only two states - locked and unlocked, while Semaphore can have multiple states.
Mute...
Virtual addressing is a memory management technique that allows a process to use a range of memory addresses independent of physical memory.
Virtual addresses are mapped to physical addresses by the memory management unit (MMU)
Virtual addresses are allocated to a process during its execution
Virtual addressing allows for efficient use of physical memory by allowing multiple processes to share the same physical memory
Exam...
Deadlock is a situation where two or more processes are unable to proceed because they are waiting for each other to release resources.
Prevent deadlock by using a proper resource allocation strategy
Avoid holding onto resources for too long
Use timeouts to release resources if they are not being used
Implement a deadlock detection and recovery mechanism
Avoid circular wait by imposing a total ordering of all resource types
Program to find the only duplicate in an array
Create a hash set to store elements as they are encountered
If an element is already in the hash set, it is a duplicate
Return the duplicate element
Virtual memory is still needed even with large physical memory. Paging helps manage memory efficiently.
Virtual memory allows for larger programs to run than physical memory can handle
Paging helps manage memory efficiently by swapping out unused pages to disk
Virtual memory also allows for memory protection and sharing between processes
Examples of programs that require virtual memory include video editing software and la
To find the middle of a linked list, use two pointers - one moving at twice the speed of the other.
Initialize two pointers - slow and fast
Move the slow pointer one step at a time and the fast pointer two steps at a time
When the fast pointer reaches the end of the list, the slow pointer will be at the middle
Time complexity of building a heap using linked list and arrays
Building a heap using linked list takes O(nlogn) time complexity
Building a heap using arrays takes O(n) time complexity
Linked list implementation is slower than array implementation
I had a great stay at IIT Roorkee and spent my time exploring various opportunities and learning new skills.
I was actively involved in various technical clubs and societies on campus
I participated in coding competitions and hackathons
I also took part in organizing technical events and workshops
Apart from academics, I enjoyed playing sports and exploring the scenic campus
Overall, my stay at IIT Roorkee was a fulfilling
Top trending discussions
The duration of Samsung interview process can vary, but typically it takes about less than 2 weeks to complete.
based on 391 interviews
Interview experience
based on 7.1k reviews
Rating in categories
Sales Executive
1.1k
salaries
| ₹1 L/yr - ₹6.9 L/yr |
Assistant Manager
1.1k
salaries
| ₹5.5 L/yr - ₹19.3 L/yr |
Software Engineer
867
salaries
| ₹6.6 L/yr - ₹25 L/yr |
Manager
528
salaries
| ₹10 L/yr - ₹33 L/yr |
Senior Engineer
478
salaries
| ₹4.3 L/yr - ₹18 L/yr |
Apple
LG Electronics
Sony
Xiaomi