Programmingcroatia.files.wordpress.com



Algorithm solutions in C#Console string printing (recursion learners – beginning level):Explanation: Print a word n (given input) amount of times.Solution: static void PrintWord(int n) { for (int i = 1; i < n; i++) { Console.WriteLine("Printing"); } }Solution (recursive): static void RecursionPrint(int n) // without using else, just one if { if (n != 0) { Console.WriteLine("Printing"); RecursionPrint(a, n-1); } }Sum, subtract, multiply, divide to input number :Explanation: Sum all numbers starting from 1 and ending with n (n is the input number). Example: 1+2+3…+n; 1-2-3-…-n; 1*2*3...*n; 1:2:3…: n.Solution: static double SumSubMultDivNumbers(int n) //the program currently divides. { //int sum = 0; //int mult = 1; //int sub = 0; double div = 1; // change method to double return type for (int i=1; i<=n; i++) { //sum += i; //sub -= i; //mult *= i; div /= i; } return div; }Solution (recursive) – sum numbers to input: static int Sumtozero(int n) { if (n == 1) return n; else return Sumtozero(n - 1) + n; }Solution (recursive) – subtract numbers to input: static int SubtractNum(int n) { if (n == 1) return n; else return SubtractNum(n - 1) - n; }Solution (recursive) – multiply numbers to input: static int MultNum(int n) { if (n == 1) return n; else return MultNum (n - 1) * n; }Solution (recursive) – divide numbers to input: static double DivideNum(int n) { if (n == 1) return n; else return DivideNum (n - 1) / n; }Armstrong number:Explanation: An?Armstrong number?of three digits is an integer such that the sum of the cubes of its digits is equal to the?number?itself. For example, 371 is an?Armstrong number?since 3^3 + 7^3 + 1^3 = 371.Solution: static void ArmstrongNumber(string input_number) { double suma = 0.0; char[] array = input_number.ToCharArray(); for (int i = 0; i < array.Length; i++) { suma = suma + Math.Pow(Convert.ToDouble(array[i].ToString()), 3.0); } if (suma.Equals(Convert.ToDouble(input_number))) Console.WriteLine("The entered number is an Armstrong number"); else Console.WriteLine("The entered number is not a Armstrong number"); }Solution (recursive) num. 1: static void ArmstrongNumberRecursion1(string input_number,double sum, string input_copy) { if (input_number=="") { if (sum.ToString()==input_copy) Console.WriteLine("this is an Armstrong number"); else { Console.WriteLine("this is not an Armstrong number"); } } else { sum = sum + Math.Pow(Convert.ToDouble(input_number[0].ToString()), 3.0); ArmstrongNumberRecursion1(input_number.Substring(1),sum, input_copy); } }Solution (recursive) num. 2:static void ArmstrongNumberRecursion2(string input_number,int input_length, double sum) { if (input_length==0) { if (input_number == sum.ToString()) Console.WriteLine("The entered number is an Armstrong number"); else Console.WriteLine("The entered number is not an Armstrong number"); } else { sum = sum + Math.Pow(Convert.ToDouble(input_number[input_length-1].ToString()), 3.0); ArmstrongNumberRecursion2(input_number,input_length-1, sum); } }Solution (recursive) num. 3:WRONG APPROACH static void ArmstrongNumberRecursion(string input_number,double sum) { if (input_number=="") { return; } else { ArmstrongNumberRecursion(input_number.Substring(1),sum); sum = sum + Math.Pow(Convert.ToDouble(input_number[0].ToString()), 3.0); //showing a good example how the recursion won't work // the sum is always, upon each call set to zero, therefore the previous sum will always be zero } }RIGHT APPROACH (wrong design-public variables, use ref keyword instead) public static double sum = 0; static void ArmstrongNumberRecursion(string input_number) { if (input_number=="") { return; } else { ArmstrongNumberRecursion(input_number.Substring(1)); sum = sum + Math.Pow(Convert.ToDouble(input_number[0].ToString()), 3.0); if (input_number == sum.ToString() && input_number.Length==sum.ToString().Length) { Console.WriteLine("Armstrong found!"); } if (input_number != sum.ToString() && input_number.Length == sum.ToString().Length) { Console.WriteLine("Armstrong not found"); } } }Power of number 2 :Explanation: Find the entered amount of numbers which are powers of number two (2). Example 2^2,2^3,2^4,2^5,… 2^n; where n is the given parameter for the function.Solution 1: static void PowerOfTwo(int amount) { for (int i = 1; i < amount+1; i++) { Console.WriteLine(Math.Pow(2, i)); } }Solution 2 (check if given number is power of number 2): static void Main(string[] args) { int x = Convert.ToInt32(Console.ReadLine()); if (x % 3 == 2 || x % 3 == 1) Console.WriteLine("Number {0} is a power of number two!"); else Console.WriteLine("Number {0} is not a power of number two!"); Console.ReadKey(); }Solution 3 (check if given number is power of number 2): public static string Function(int input) { int result = 2; bool message = false; int counter = 0; do { counter++; if (input == result) { message = true; break; } result *= 2; } while (result <= Math.Pow(2, 32)); if (message) { return "Power of number 2 found!"; } else { return "Not number of power 2"; } }Solution (recursive) num. 1: static void PowerOf2(int counter) { if (Math.Pow(2, counter) % 3 == 2 || Math.Pow(2, counter) % 3 == 1) Console.WriteLine(Math.Pow(2, counter)); if (counter == 0) return; PowerOf2(counter-1); }Solution (recursive) num. 2, rearranged: static void PowerOf2(int counter) { if (counter == 0) return; PowerOf2(counter - 1); if (Math.Pow(2, counter) % 3 == 2 || Math.Pow(2, counter) % 3 == 1) Console.WriteLine(Math.Pow(2, counter)); }Palindrome :Explanation: A?palindrome?is a word, phrase, number, or other sequence of characters which reads the same backward or forward. Palindrome example is: civic, racecar, level, radar, 101, 121, and 1001 etc.Solution (checks just a number) num. 1: static void Main(string[] args) { /* input number to array * 1. array --> array , 2. array--> reversed 1. array. * if array1 equals array two * palindrome detected */ int j = 0; int x = int.Parse(Console.ReadLine()); string z = x.ToString(); char[] array = z.ToCharArray(); char[] array1 = new char[array.Length]; bool[] array2 = new bool[array.Length]; for (int i = array.Length - 1; i >= 0; i--) { array1[i] = array[j]; j++; } for (int i = 0; i < array.Length; i++) { if (array[i] == array1[i]) { array2[i] = true; } else array2[i] = false; } foreach (char c in array) Console.Write(c); if (array2.All(element => element == true)) Console.WriteLine("The entered number is a palindrome!{0}", x); else Console.WriteLine("No Palindrome number"); Console.ReadLine(); }Solution (checks number and string) num. 2 - simplified: static void IsPalindrome(string input) { bool match= true; char[] array = input.ToCharArray(); int j = input.Length - 1; for (int i = 0; i < input.Length; i++) { if (array[i] != array[j]) { match = false; break; } --j; } if (match) { Console.WriteLine("The given input is Palindrome"); } else { Console.WriteLine("The given input is not Palindrome"); } }Solution (recursive) num. 1: static bool IsPalindromeRecursion(String s) { int len = s.Length; if (len <= 1) { return false; } if (s[0] == s[len - 1]) { return true; } return IsPalindromeRecursion(s.Substring(1)); }:Solution (recursive) num. 2 - stackoverflow: static bool CheckPalin(string p) { if (p.Length == 1 || p.Length == 0) //added check for even cases return true; if (p[0] != p[p.Length - 1]) return false; return CheckPalin(p.Substring(1, p.Length - 2)); }Solution (recursive) num. 3 – modified with ifs: static bool CheckPalin(string p) { if (p.Length == 1 || p.Length == 0) //if empty string or one letter than palindrome return true; else if (p[0] != p[p.Length - 1]) //if one doesn't match than it is sure the string is not a palindrome return false; else return CheckPalin(p.Substring(1, p.Length - 2)); }Convert denary to binary :Explanation: A number of base 10 is given, you must find the binary equivalent of the denary number. Example: number 23 in denary is 10111 in binary. To get a binary number you must divide the denary number with number two until you reach number zero (0). The remainder of all divisions will be the binary number equivalent.Solution num. 1: static void DectoBin(int dec) { List<int> list = new List<int>(); int remainder = 0; do { remainder = dec % 2; list.Add(remainder); dec = dec / 2; } while (dec != 0); for (int i = list.Count-1; i>=0; i--) { Console.Write(list[i]); } }Solution num. 2: static int[] digitArr(int n) { if (n == 0) return new int[1] { 0 }; var digits = new List<int>(); for (; n != 0; n /= 10) digits.Add(n % 10); var arr = digits.ToArray(); Array.Reverse(arr); return arr; }Solution (recursive) num. 1: static List<int> Dec_Bin(int input_decimal, List<int> list) { int remainder; remainder = input_decimal % 2; if (remainder == 0) return list; else list.Add(remainder); return Dec_Bin(input_decimal / 2, list); } private static void Reverse_list(List<int> list) { list.Reverse(); // Reverse method can be done manually by using a for loop from last element to the zero index }Solution (recursive) num. 1 – simplified, stackoverflow: Showing that you don’t always have to write a second if for the base case, the base case is implemented within one if statement static void DectoBinRecursion(int input) { if (input > 0) { DectoBinRecursion(input / 2); Console.WriteLine(input % 2 + " "); } }Convert binary to denary:Solution (recursive) num. 1: static void Main(string[] args) { Console.WriteLine("Write a number"); int number1 = int.Parse(Console.ReadLine()); Console.WriteLine("Denary number is:"); Console.WriteLine(number(digitArr(number1), 0, 0)); Console.ReadLine(); } static int[] digitArr(int n) { if (n == 0) return new int[1] { 0 }; var digits = new List<int>(); for (; n != 0; n /= 10) digits.Add(n % 10); var arr = digits.ToArray(); Array.Reverse(arr); return arr; } private static int number(int[] array1, int index, int sum) { if (index == array1.Length) { return sum; } else { double a = array1[index] * Math.Pow(2, array1.Length - index - 1); sum = sum + (int)a; return number(array1, index + 1, sum); } }Display even numbers :Explanation: Display even numbers in reverse given the max value as the input parameter from where the numbers have to start.Solution: static void EvenNums(int n) { for (int i = 1; i <= n; i++) { if (i % 2 == 0) { Console.WriteLine(i); } } }Solution (recursive) num. 1: static void Even(int n,List<int>list) { if (n % 2 == 0 && n != 0) { list.Add(n); Even(n - 1, list); } else if (n % 2 == 1) Even(n - 1, list); else return; }Find maximum value:Explanation: find max value inside of an array. Example: {0, 2, 7, 1, 9, -1, 4} max: 9Solution: private static int FindMaximumValue(int[] input_array) { int max = input_array[0]; foreach (int item in input_array) { if (item > max) { max = item; } } return max; }Solution (recursive) num. 1: static int MaxVal(int[] array, int max, int n) { if (n == array.Length) { return max; } else { if (array[n] > max) { return MaxVal(array, array[n], n + 1); } else { return MaxVal(array, max, n + 1); } } }Solution (recursive) num. 2: static void Main(string[] args) { int max; int[] array = new int[] { 4, 2, 12, 43, 2, 1, 5, 22, 32, 11, 17, 0 }; max = array[0]; FindMaxRecursion(array,ref max,0); Console.WriteLine(max); Console.ReadLine(); } static void FindMaxRecursion(int[] input_array,ref int max, int n) { if (n < input_array.Length) { if (input_array[n] > max) { max = input_array[n]; } FindMaxRecursion(input_array, ref max, n + 1); } }Byte array :Explanation: Write an array with 0’s and 1's which include all possible combinations. For example if the array has 5 cells (array length of 5) then you must have the following combinations: 0,0,0,0,0 up to 1,1,1,1,1, (32 possible combinations) 2^5;Solution: Solution (recursive) num. 1: static void Main(string[] args) { int size = 8; int[] vector = new int[size]; Bits(size - 1, vector); Console.ReadLine(); } private static void Bits(int index, int[] vector) { if (index == -1) { for (int i = 0; i < vector.Length; i++) { Console.Write(vector[i]); } Console.WriteLine(""); } else { for (int i = 0; i <= 1; i++) { vector[index] = i; Bits(index - 1, vector); } } }Find amount of vowels inside a string :Explanation: Write a program which counts the amount of lowercase vowels (a, e , i , o, u) inside a given string.Solution: static void Main(string[] args) { string word = "jonathan"; char[] array = word.ToCharArray(); Console.WriteLine(Vowels(array)); //only lowercase letters Console.ReadLine(); } static int Vowels(char[] input) { int counter = 0; foreach (char item in input) { if (item=='a'|| item == 'e' || item == 'i' || item == 'o' || item == 'u') { ++counter; } } return counter; }Solution (recursive) num. 1: static void Main(string[] args) { Console.WriteLine(Vowels("jonathan",0,0)); //only lowercase letters Console.ReadLine(); } static int Vowels(string input,int counter, int index) { if (index == input.Length) { return counter; } else if (input[index] == 'a' || input[index] == 'e' || input[index] == 'i' || input[index] == 'u' || input[index] == 'o') { return Vowels(input, counter + 1, index + 1); //instead of +1 you can put preincrement (example: ++counter) } else { return Vowels(input, counter, index+1); } }Solution (recursive) num. 2: private static int CountVowels(string s, int counter) { if (s.Length == 0) { return counter; } if (s[0] == 'a' || s[0] == 'e' || s[0] == 'i' || s[0] == 'o' || s[0] == 'u') { return CountVowels(s.Substring(1), counter+1); } else { return CountVowels(s.Substring(1),counter); } }Find the integer which you imagined in your head by answering a question with M or L:Explanation: Write a program where a user defines an interval from a to b. From this interval a number is selected randomly. After the number is selected input char M or L depending on the random number value. If your number (which you picked up in your head) is greater than the random number then input the letter ‘M’ if your number is lesser then the imagined number then write ‘L’. When the number in your head (which you picked) matches the random number then write out the exclamation mark “!”.Solution:static void Main(string[] args) { int minValue = 0; int maxValue = 100; while (true) { int rnd_num = new Random().Next(minValue, maxValue); Console.WriteLine(" R: " + rnd_num); char c = Console.ReadLine()[0]; if (c == 'M') { Console.WriteLine(" K: M,"); minValue = rnd_num + 1; } else if (c == 'L') { Console.WriteLine(" K: L,"); maxValue = rnd_num - 1; } else { Console.WriteLine(" K: !"); break; } } Console.ReadLine(); }Solution (recursive) num. 1:static void Main(string[] args) { int minValue = 0; int maxValue = 100; guessGame(minValue, maxValue); Console.ReadLine(); } public static void guessGame(int min, int max) { int rand = new Random().Next(min, max); Console.WriteLine("R: "+rand); char c = Console.ReadLine()[0]; if (c == 'M') { Console.WriteLine("K:M"); guessGame(rand + 1, max); } else if (c == 'L') { Console.WriteLine("K:L"); guessGame(min, rand - 1); } else { Console.WriteLine("!"); return; } } Interview questions:Banksoft (Croatia):Write a function/method which adds an integer flag to the end of the input number. Example: you are given the following number 247521 and you have to add a flag number at the end of the given/input number, result: 2475211. The flag number is determined by the following procedure: every character/number at an odd position in the given number is multiplied by one and every number at an even position is multiplied by two. In the above number scenario this would be: 2*1, 4*2, 7*1, 5*2, etc. After that you need to sum all of the numbers which are multiplied, this would be: (2+4*2+7+5*2+2+1*2). At the end, you must get the remainder of the sum division by number 10, this would be: (2+4*2+7+5*2+2+1*2) % 10=1. After you have the remainder (in this case num 1) then you just have to attach the number to the input number which will give you 2475211.Find which word in a file of words has the most anagrams?Find the second max value inside the array?Find a number inside the array of values 1-100 (sorted) which is missing. Example: you have a sorted array of numbers 1-10 {1, 2, 3, 4, null, 6, 7, 8, 9, 10} you have to display which value is missing inside a sorted array. In this case, number 5 is missing.Write a function/method which accepts two parameters, one string and the other of type char. The functions has to return how many times the given char input appears in a string. Example: string: Julius, char: u, number of times letter u appears is two (2).Star net software (Croatia)Economy matrixCreate ERM Create database model, parent child connectionGeneral questions (circle the right answer)Ericsson - Nikola Tesla (Croatia)Data conversion from denary to binary, hexadecimal, octal etc. Knowing XOR table, shift operations and other Boolean tables by heart.Difference between list, stack and queue. Difference in time complexity of adding an element to the list which is implemented using a cursor and a list which is implement using pointersDifference between static and dynamic memory, what is placed on them. Difference between stack(not static memory) and heap (dynamic memory)Difference between reference and pointers and value typesWrite a function which accepts an array/list as a parameter and returns/prints all of the elements of the input array/listBubble sort and bubble sort optimizationWrite a method which accepts two lists as input parameters and outputs a merged list from the two inputted lists. Write a recursive function which find the max value in an arrayGeneral interview questions (1):Linked ListsImplement?Insert?and?Delete?forsingly-linked linked listsorted linked listcircular linked listint Insert(node** head, int data)int Delete(node** head, int deleteMe)Split a linked list given a pivot valuevoid Split(node* head, int pivot, node** lt, node** gt)Find if a linked list has a cycle in it. Now do it without marking nodes.Find the middle of a linked list. Now do it while only going through the list once. (same solution as finding cycles)StringsReverse words in a string (words are separated by one or more spaces). Now do it in-place.?By far the most popular string question!Reverse a stringStrip whitespace from a string in-placevoid StripWhitespace(char* szStr)Remove duplicate chars from a string ("AAA BBB" -> "A B")int RemoveDups(char* szStr)Find the first non-repeating character in a string:("ABCA" -> B )int FindFirstUnique(char* szStr)More Advanced Topics:You may be asked about using Unicode strings. What the interviewer is usually looking for is:each character will be two bytes (so, for example, char lookup table you may have allocated needs to be expanded from 256 to 256 * 256 = 65536 elements)that you would need to use wide char types (wchar_t instead of char)that you would need to use wide string functions (like wprintf instead of printf)Guarding against being passed invalid string pointers or non nul-terminated strings (using walking through a string and catching memory exceptionsBinary TreesImplement the following functions for a binary tree:InsertPrintInOrderPrintPreOrderPrintPostOrderImplement a non-recursive?PrintInOrderArraysYou are given an array with integers between 1 and 1,000,000. One integer is in the array twice. How can you determine which one? Can you think of a way to do it using little extra memory.You are given an array with integers between 1 and 1,000,000. One integer is missing. How can you determine which one? Can you think of a way to do it while iterating through the array only once. Is overflow a problem in the solution? Why not?Returns the largest sum of contiguous integers in the arrayExample: if the input is (-10, 2, 3, -2, 0, 5, -15), the largest sum is 8int GetLargestContiguousSum(int* anData, int len)Implement?Shuffle?given an array containing a deck of cards and the number of cards. Now make it O(n).Return the sum two largest integers in an arrayint SumTwoLargest(int* anData, int size)Sum n largest integers in an array of integers where every integer is between 0 and 9int SumNLargest(int* anData, int size, int n)QueuesImplement a Queue class in C++ (which data structure to use internally? why? how to notify of errors?)General interview questions (2):String Programming Interview Questions String is the primary and probably most common thing you come across on any programming language and so is with any programming interview. There is almost always a question on String whether it’s related to length or replace but I have always find one or two String programming questions on interviews.1) Write code to check a String is palindrome or not??Palindrome are those String whose reverse is equal to original. This can be done by using either StringBuffer?reverse()?method or by technique demonstrated in the here.2) Write a method which will remove any given character from a String?? hint : you can remove a given character from String by converting it into character array and then using?substring()?method for removing them from output string.3) Print all permutation of String both iterative and Recursive way?? 4) Write a function to find out longest palindrome in a given string?? 5) How to find first non-repeated character of a given String??6) How to count occurrence of a given character in a String??7) How to check if two String are Anagram??8) How to convert numeric String to int in Java??Some more String related Questions which mostly appear in Java programming interviews: 1) What is difference between String, StringBuilder and StringBuffer in Java??(Main difference is that String is immutable but both StringBuilder and StringBuffer are mutable. Also StringBuilder is not synchronized like StringBuffer and that's why faster and should be used for temporary String manipulation.2)?Why String is final in Java??String is final because of same reason it is immutable. Couple of reasons which I think make sense is implementation of String pool, Security, and Performance. Java designers knows that String will be used heavily in every single Java program, so they optimized it from the start.3)?How to Split String in Java??Java API provides several convenient methods to split string based upon any delimiter e.g. comma, semi colon or colon. You can even use regular expression to split a big string into several smaller strings.4)?Why Char array is preferred over String for storing password??Programming questions on ArrayArray is one of the topics where most of programming questions is asked. There are many and many programming questions on Array and here I have included only some of them which is not very difficult to solve but some of array programming question can be extremely challenging, so well prepare this topic.9) In an array 1-100 numbers are stored, one number is missing how do you find it? 10) In an array 1-100 exactly one number is duplicate how do you find it? 11) In an array 1-100 multiple numbers are duplicates, how do you find it??One trick in this programming questions is by using HashMap or Hashtable , we can store number as key and its occurrence as value, if number is already present in Hashtable then increment its value or insert value as 1 and later on print all those numbers whose values are more than one.12) Given two arrays, 1, 2, 3, 4, 5 and 2,3,1,0,5 find which number is not present in the second array.Here is a quick tip to solve this programming question: put the elements of the second array in the?Hashtable?and for every element of the first array, check whether it’s present in the hash or not, O/P all those elements from the first array that are not present in the hash table13) How do you find second highest number in an integer array??14) How to find all pairs in array of integers whose sum is equal to given number?15) How to remove duplicate elements from array in Java??16) How to find largest and smallest number in array??17) How to find top two maximum number in array??LinkedList Programming Interview Questions14) How do you find middle element of a linked list in single pass?To this programming question I would say you start with simple on which you traverse the LinkedList until you find the tail of linked list where it points to null tofind the length of linked list?and then reiterating till middle. After this interviewer will ask you find the middle element in single pass and there you can explain that by doing space-time trade-off you can use two pointers one incrementing one step at a time and other incrementing two step a time, so when first pointer reaches end of linked second pointer will point to the middle element.15) How do you find 3rd element from last in single pass??This programming question is similar to above and can be solved by using 2 pointers, start second pointer when first pointer reaches third place.16) How do you find if there is any loop in singly linked list? How do you find the start of the loop??This programming question can also be solved using 2 pointers and if you increase one pointer one step at a time and other as two steps at a time they will meet in some point if there is a loop.17) How do you reverse a singly linked list??18) Difference between linked list and array data structure?Binary Tree Programming Interview QuestionsBinary tree or simply tree is one of favorite topic for most of interviewer and pose real challenge if you struggle with recursion. Programming questions on tree can become increasingly difficult when you think iterative but sometime can be very easy if you come with recursive.18) How do you find depth of binary tree?19) Write code to print InOrder traversal of a tree?20) Print out all leaf node of a binary tree?21) Write a method in Java to check if a tree is a binary search tree or not?22) How to check if a tree is balanced or not in Java?Programming Questions on Searching and SortingI have only included two programming questions related to searching and sorting but there are more can be finding on Google. Purpose of these programming questions is to see whether programmer is familiar with essential search and sort mechanism or not.23) Write a program to sort numbers?in place?using quick sort??24) Write a program to implement binary search algorithm in Java or C++??25) How do you sort Java object using Comparator??This is another Java specific programming questions and you can check how to sort Object using Comparator and Comparable for.?26) Write code to implement Insertion Sort in Java??27) Write code to implement Bubble Sort in Java??Programming Questions on NumbersMost of the programming questions are based on numbers and these are the ones which most of us did on college level and mind you they still has value I have seen programmers with experience of 3 years struggle with these programming questions and doesn't solve it sometime and take a lot of time which simply shows that they are not in programming in there day to day work.26) Write code to check whether a no is power of two or not?27) Write a program to check whether a number is palindrome or not?Check out this post which shows how to reverse number in Java and can be used to find if its palindrome or not.28) Write code to check whether an integer is Armstrong number or not?Here is a Java program to find Armstrong number, you can use same logic to write code in any other programming language like C and C++.29) Write a program to find all prime number up to a given numbers??Here is another Java program to find prime numbers and print them. By using logic demonstrated in this program; you can write similar program in C and C++.30) Write function to compute Nth Fibonacci number? Both iterative and recursive?Check this Java program to print Fibonacci Series using recursion and iteration.?31) How to check if a number is binary?For this question, you need to write a function which will accept an integer and return true if it contains only 0 and 1 e.g. if input is 123 then your function will return false, for 101 it should return true.32) ?How to reverse an integer in Java?33) How to count number of set bits in given integer?34) How to find sum of digits of a number using recursion?35) How to swap two numbers without using temp variable?36) How to find largest of three integers in Java?37) Write a program to find prime factors of integer?38) How to add two integer without using arithmetic operator?General Programming Interview QuestionsIn this category of programming questions I have put questions which are not fit into any data structure but presents a real life problem and you need to provide. These programming questions are sometime based on problems faced by developer itself. I have not included many Software design related programming question which I have shared on Top 20 software design questions and s; you can also check that.?31) Write a program to find out if two rectangles R1 and R2 are overlapping?32) You need to write a function to climb n steps you can climb either 1 step at a time or 2 steps a time, write a function to return number of ways to climb a ladder with n step.33) Write code for Generate Random No in a range from min to max?34) Write program for word-wrap which should work on any screen size?35) Design an algorithm to find the frequency of occurrence of a word in an article?36) Write a program to implement blocking queue in Java?37) Write a program for producer-consumer problem?This article solves producer consumer problem using Blocking Queue in Java. You can refer it to this question.-learn balanced, unbalanced trees, linked list, Solution to interview questions: ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download