Pregunta de entrevista de Fortech SRL

- What's the difference between an array and list? And when would you use one or the other? - What's the differnce between a monolithic and micro kernel? - What do use a mutex for? - What is a scoped lock? - Describe what a binary tree is and what type of data they are best used for - Name at least two sorting alfgorithms

Respuesta de la entrevista

Anónimo

6 ene 2016

- An array is typically a block of memory where all the values are aligned behind each other, and typically of a fixed size. A list usually refers to a linked list, meaning that the data can be stored at random locations in memory, and each item has a pointer to the next item. You'd use an array when you have to access random items in the list often and when you know the number of elements you're going to store so you can pre-allocate the required memory. You'd use a linked list if you don't require random access, and when you don't know how many elements are going to be stored in the list - A monolithic kernel is a single largge process running entirely in a single address space. All kernel services exist and run in kernel address space. In microkernels, the kernel is broken down into multiple processes, typically referred to as "servers". All servers are kept in separate address spaces and communication between them is done using message passing, as opposed to in a monolithic kernel, where functions can be invoked directly. Linux is monolithic, Windows is micro. - A mutex is a mutual exlcusion semaphore, which allows only one locker at the same time. This allows one to "block" access to a piece of data by locking the mutex, perform reads/writes and then unlocking it again, allowing other threads or processes to do stuff with the data. This ensures that only one thread/process accesses the data at the same time. It is possible to for example have separate read/write mutexes/locks. - A scoped lock is a object that locks a specific mutex for the the remainder of it's own life time. When the object is destroyed (aka goes out of scope), the mutex is unlocked/released. This avoid manual locking and unlocking of a mutex. Using scoped locks is considered following RAII. - A binary tree is a tree where each node contains a left reference and right reference. Although, each node is not required to have a left _and_ right reference. It can have no references, or only a left reference. Binary trees are often used as BST's (Binary search trees). They are used in things like routing tables, spatial partition etc. - Bubble sort, quick sort

1