Question In C++ what is the difference between copy constructor and assignment operator. If they are created for you by default then why do we need to create them in the first place. Assignment operator vs copy constructor Copy constructors and assignment operators are created by default even if you do not implement your own.
Problem Given an array of n-1 unique integers. Each element in the array is an integer between 1 and n. Write a program to print the missing number in the array Solution To clarify this problem let us take a simple example. Assume n = 3 so the array consists from two elements only. Here
Problem Write a program to reverse an English sentence word by word not character by character. For example if the sentence is “I love Pizza so much” the program should print “much so Pizza love I” Solution One solution is to split the sentence into tokens using the space character as the separator then print
Problem Given the following sequence of integer numbers: Write a recursive function that receives the index of a given number in the sequence above and returns the corresponding sequence number for example if index = 2 the function should return 2, if the index = 5 the function should return 8 and so on Solution
Problem Given the following sequence of integer numbers: Write a function that receives the index of a given number in the sequence above and returns the corresponding sequence number for example if index = 2 the function should return 2, if the index = 5 the function should return 8 and so on Solution The
What is Recursion: Please Bear with me This is going to be a short and technical article so please bear with my bad English and writing style. Language is also a mean of communication and sometimes it fails to convey understanding so I will brain dump the concept in plain English to the best of
Problem A developer has written a stack designed to hold a maximum of five variables and he has asked you to test it. How would you test that stack? Solution Here are the general guidelines to test the stack. Note that they can be applied to testing software components in general: A. If white box
Problem Given a log file similar to Linux syslog format as in the following example: Write a Perl script to print the top 5 most repeated error messages. Solution Read the file line by line then split each line using “:” as separator then use the error message token as the key in a hash
Problem Write a java program to construct and print a ternary Tree. A ternary tree is similar to a binary tree except a parent node can have up to three children instead of two. The left child value is less than the parent value, the right is greater than the parent value and the middle
Problem Write a java program to convert a character string into long data type. Solution We have already solved this problem using C++ in the post String to Integer. The code below shows a java implementation. Code Here is the code in Java