Today I wrote MS written test. There were 3 questions. 10 marks each.
1. Write a program to output all elements of a binary tree while doing a Breadth First traversal through it.
2.Write a method to combine two two sorted linked list into one in sorted form with out usingĀ temporary Node.
void sort(Node* list1,Node* list2)
3.There are set of coins of {50,25,10,5,1} paise in a box.Write a program to find the number of ways a 1 rupee can be created by grouping the paise.
497 Views |
Answer for 2:
merge the two linked list directly
and sort the combined linked list
This code is written in C#. Again performance and error handling is not given a thought while writting this code. You can optimize it to level you want.
class CoinGames
{
static int _NoofWays = 0;
static void Main(string[] args)
{
int[] Coins = new int[] { 50, 25, 75, 15, 10 };
// iterate through increasing set of numbers
for (int i = 1; i
Leave an Answer/Comment