Hi,
As a software developer we would have came across so many challenges in our day to day work. It would be very helpful if we have the following attitude while solving any puzzle:
1. Be open for challenge
2. Try to synthesize the problem into smaller chunks
3. Write down the algorithm for the solution
4. Think out of the box
5. Don't restrict your capabilities
6. Be Honest in finding the solution
definitely the above approach will give you the cake walk solution against any terrible problem.
Okay let me give you some interesting programming questions I have come across:
Question 1: How could you determine if a linked list contains a cycle in it, and, at what node the cycle starts?
Answer 1:
NODE *p1 = *p2 = HEAD;
do { p1 = p1->next; if(p2->next) p2 = p2->next->next;
} while (p1 != p2);
if p1 and p2 is NULL then it is acyclic otherwise it is cyclic.
Q2: How will you reverse the singly linked list?
Q3: Write a program to remove duplicates in array?
Q4: How will you reverse the doubly linked list without swapping values?
Q5: How can you reset a bit from the given position of given number?
Q6. Insert a node in sorted doubly linked list
Q7. Construct a BST(Binary Search Tree) for the node 3, 1, 2
Q8. Write code to search a given element in BST
Q9. Write a code to find maximum depth of the BST
Q10. What are all the difference between STL map and set. Can I conver a map into set?
Q11. Why hash table and where it is used?
Cheers,
Rajan