Curated List to prepare for c++ , data structure, Algorithms, Design Related programming interview

Amit.Kumar
4 min readMar 27, 2019

--

Below are the list I have found useful while preparing for the programming interviews. My choice of coding was c++ , so the links are mainly for c++ but it can help others as well.

I will keep adding to this list . So please bookmark this link for future references as well and keep coming back to check the list again.

I am trying to make this page a one stop shop to get all the useful resources to prepare for coding interviews .

Please comment if you have any useful link to be added here.

Design Questions

Design url shortener

Design questions discussions

c++ Multithreading concepts (Locks , Condition Variable , Semaphores and Locked data structure)

Condition Variable

OS Concepts — VERY IMPORTANT

Multithreading questions and solutions

deadlock , starvation and livelock

Inter process communication methods

What happens when we switch on the power button of computer.

Socket/Network Programming Fundamentals and Questions

Socket programming . Basics of client and server code

c++ Fundamentals and Interview Questions

C++ inteview question archives

Learn cpp fundamentals

Function overloading based on const type

Understanding const in data types

Copy constructor , Copy Assignment operator , Move Constructor , Move Assignment operator , copy and swap idiom.

Implicit User Defined Type-casting .

Design Patterns

Interview Questions from Experience

  1. Create a circular queue using array.
  2. Given an array of integers , sort the numbers according to the number of bits set for the integers.
  3. Given a list of files (total number of files could be more than thousands maybe 8192) and each file contains millions of records of the form (transaction time , transaction id , data)sorted according to transaction time. Write a program to sort the data in all the files according to transaction time and dump in a single file. (cannot load all data from all the files as it could empty RAM) .
  4. Reverse a linked list using recursion.
  5. Consider a server has thousands of files containing strings. Everyday either a new file could be added , or deleted , or some files could be edited and some files are left untouched. Clients need to download the files from the server , check the contents , do some processing on it , then dump the processed data in to some other file. How this process can be done effectively (meaning what data structure , algorithms to be used). Suppose if a file is unedited , it shouldn't waste resources in downloading the file and then checking if it is unedited and do nothing because it was unedited.
  6. Given a function like this :

void func()

{

int *ptr = new int();

//lots of code here

delete ptr;

}

what could go wrong in the above given function and what need to be done to fix it.

7. Type casting in c++. which is used when and on what type (reference , pointer , normal object)
8. How to introduce constness on variable (opposite to what const-cast does)

9. How map works internally . How keys are sorted. how compare function is called by map. how to make map work when keys are classes.

10. When is dynamic cast called . real world use case.

11. Dynamic cast between two derived classes from the same base class

12. What is placement new in c++.

11. what if derived class overrides the base function but make it private

12. how do you avoid deadlock if it is already in deadlock

13. when deadlock occurs and how to avoid it.

13. Diamond problem in multiple inheritance and how to solve it

14. Print numbers from 1 to 100 such that 1 is printed by 1st thread , 2 by 2nd thread , 3 by third and 4 by fourth
and then this repeats till 100.(4 threads are spawned by main thread)

15. what all properties do threads inherit from the parent process.

16. What will be the output of below codes:
class A{
};

int main()
{
cout<<sizeof(A);
}

Ans — 1

17.

class A{
int a[0];
}
int main()
{
cout<<sizeof(A);
}
Ans — 0

18.

#include<iostream>

using namespace std;

class Empty { };

class Derived: Empty { int a; };

int main()

{

cout << sizeof(Derived);

return 0;

}

Ans — 4

19.

#include <iostream>
using namespace std;

class A{
public :
virtual void func1 ()
{
cout<<”A:func1"<<endl;
}
};

class B : public A{
void func1()
{
cout<<”B : func1"<<endl;
}
public :
void func2 ()
{
cout<<”B:func2"<<endl;
}
};

int main() {
A *obj = new B;
obj->func1();
return 0;
}

func1 which is public in base class is overridden in private section in derived class.Will the func1 now be accessible
as in the main code above.
Ans : B : func1(Accessibility check is performed statically . So object is of A and func1 is public in A .hence its accessible.)

20.

#include <iostream>
#include <vector>
using namespace std;

class A {
int a;

public :
A ()
{
cout<<”default ctor”<<endl;
}

A (const A& obj)
{
cout<<”copy ctor”<<endl;
}

A& operator= (const A& obj)
{
cout<<”copy assignment”<<endl;
}

A (A&& obj)
{
cout<<”move copy ctor”<<endl;
}

A& operator= (A&& obj)
{
cout<<”move assignmnt operator”<<endl;

}
~A ()
{
cout<<”destructor”<<endl;
}
};

int main() {
A obj;
vector<A> v;
v.push_back (obj);
return 0;
}

what is the output of the above code . What could go wrong if the class has a buffer and it is deleted inside the destructor.

21. What is move copy constructor and move assignment operator and when they are called.

22. Write code to check if the given tree is BST .

--

--

Amit.Kumar
Amit.Kumar

Written by Amit.Kumar

I have been a coder all my life . And yes a dreamer too. But i am also interested in understanding different aspects of life .

Responses (1)