Technical Questions

1) Which is better – singly linked list or doubly linked list? What are the pros and cons of using each?
Singly linked list has smaller memory requirement because singly linked list can only be traversed in one direction. Doubly linked lists require more space for each element in the list and elementary operations such as insertion and deletion is more complex since they have to deal with two references. But doubly link lists allow easier manipulation since it allows traversing the list in forward and backward directions.

Singly Linked List vs. Doubly Linked List

· Elements in singly linked list are linked to only the next element in the series while elements are linked with previous and next both elements in doubly linked list.

· Singly linked lists need lesser space while doubly linked list need more space for every block in the list.

· Basic functions like addition or deletion are complicated in doubly linked list because there are two links to deal with but you can easily manipulate the data because you can cross over the list and move back and forth in the list.

2) What’s the difference between Managed code and Native code? Give examples of each you have worked on.

Managed Code:

Managed code runs on the CLR (Common Language Runtime), which, among other things, offers services like garbage collection, run-time type checking, and reference checking. Managed code takes advantages of memory management, security and threading services CLR provides.

The managed code is the one generated by C# and other .NET language compilers (IL) and gets finally converted to native code by JIT. If you are writing an application in Visual C++ .NET you can produce managed code if you like, but it’s optional.

Native Code:

Native code does not run under CLR and compiles straight to machine code. No free memory management or anything else the CLR provides. Since you cannot create unmanaged code with Visual Basic or C#, in Visual Studio all unmanaged code is written in C/C++.

I wrote some web applications in C and C++ on the apache on Linux. These are native code applications whose memory is not “managed”, as in, memory isn’t freed (C++’ delete and C’s free, for instance), no reference counting, no garbage collection. I had to take care of these to free allocated memory.

3) What is thread safe code? Give an example of times you’ve used thread safe code.

Thread Safe code is one which runs in a manner that when multiple threads are running simultaneously and are in need of using shared memory, they do not step onto each other or in other words access the shared memory exclusively.

By using thread-safe routines, the risk that one thread will interfere and modify data elements of another thread is eliminated by circumventing potential data race situations with coordinated access to shared data.

Advertisements