Programming Algorithms Interview Questions & Answers

  1. Question 1. How To Find Median Of A Bst?

    Answer :

    • Find the no. of elements on the left side.
    • If it is n-1 the root is the median.
    • If it is more than n-1, then it has already been found in the left subtree.
    • Else it should be in the right subtree.
  2. Question 2. Define String In An Algorithmic Notation And An Example To Support It?

    Answer :

    In the algorithmic notation, a string is expressed as any sequence of characters enclosed in single quote marks.

    E.g. a single quote contained within a string is represented by two single quotes. Therefore, the string “It is John`s program.” is represented as ‘IT IS JOHN”S PROGRAM.’.

  3. Core Java Interview Questions

  4. Question 3. What Are The Two Ways Through Which The Markov Algorithm Terminates?

    Answer :

    A Markov algorithm terminates in one of the two ways:

    1) The last production is not applicable

    2) A terminal production is applicable

    A terminal production is a statement of the form x map to y., where x and y represent the strings in V* and the symbol “.” Immediately follows the consequences.

  5. Question 4. What Is The General Strategy For Markov Algorithm?

    Answer :

    The general strategy in a Markov Algorithm is to take as input a string x and, through a number of steps in the algorithm, transform x to an output string y. this transformation process is generally performed in computers for text editing or program compilation.

  6. Core Java Tutorial

  7. Question 5. The Most Basic Tool Used To Express Generating Functions In Closed Form Is The Closed Form Expression For The Geometric Series, Which Is An Expression Of The Form A+ar+ar2+——-+arn. It Can Either Be Terminated Or Extended Indefinitely. What Are The Restrictions For This Geometric Series?

    Answer :

    If a and r represents numbers, r must not equal1 in the finite case.In the infinite case the absolute value of r must be less than 1.These restrictions don’t come into play with Generating functions.

  8. C Interview Questions

  9. Question 6. Name Any Three Skills Which Are Very Important In Order To Work With Generating Functions.?

    Answer :

    The three most important skills which are used extensively while working with generating functions are:

    1. Manipulate summation expressions and their indices.
    2. Solve algebraic equations and manipulate algebraic expressions, including partial function decompositions.
    3. Identify sequences with their generating functions.
  10. Question 7. Explain About The Algorithm Ord_words?

    Answer :

    This algorithm constructs the vectors TITLE, KEYWORD and T_INDEX.

  11. C Tutorial
    OOPS Interview Questions

  12. Question 8. Explain The Function Of Kwic_create?

    Answer :

    This algorithm analyses the input phrases and creates the three arrays needed in procedure KWIC_GEN.

  13. Question 9. What Is The General Algorithm Model For Any Recursive Procedure?

    Answer :

    Prologue: Saves the parameters, local variables and returns addresses.

    Body: If the best criterion has been reached: then perform the final computation and go to step3, otherwise, perform the partial computation and go to step1.

    Restore the most recently saved parameters, local variables and return address. Go to this return addresses.

  14. Data analyst Interview Questions

  15. Question 10. Give The Difference Of Format Between An Algorithm And A Sub Algorithm?

    Answer :

    The format used is the same as for algorithms except that a return statement replaces an exit statement and a list of parameters follows the sub algorithms name. Although sub algorithms may invoke each other and that a sub algorithm may also invoke itself recursively.

  16. Data Structure & Algorithms Tutorial

  17. Question 11. Define And State The Importance Of Sub Algorithm In Computation And Its Relation Ship With Main Algorithm?

    Answer :

    A sub algorithm is an independent component of an algorithm and for this reason is defined separately from the main algorithm. The purpose of a sub algorithm is to perform some computation when required, under control of the main algorithm. This computation may be performed on zero or more parameters passed by the calling routine.

  18. Algorithm Interview Questions

  19. Question 12. Write The Program Counting Set Bits In A Number?

    Answer :

    First version:

    int CoutSetBits(int Num)
    for(int count=0; Num; Num >>= 1)
    if (Num & 1)
    return count;

    Optimized version:

    int CoutSetBits(int Num)
    for(int count =0; Num; count++)
    Num &= Num -1;

  20. Core Java Interview Questions

  21. Question 13. Write The Program Return Nth The Node From The End Of The Linked List In One Pass.?

    Answer :

    Node * GetNthNode ( Node* Head , int NthNode )
    Node * pNthNode = NULL;
    Node * pTempNode = NULL;
    int nCurrentElement = 0;
    for ( pTempNode = Head; pTempNode != NULL; pTempNode = pTempNode->pNext )
    if ( nCurrentElement – NthNode == 0 )
    pNthNode = Head;
    if ( nCurrentElement – NthNode > 0)
    pNthNode = pNthNode ->pNext;
    if (pNthNode )
    return pNthNode;
    return NULL;

  22. Object Oriented Analysis and Design Tutorial

  23. Question 14. Write A Function That Finds The Last Instance Of A Character In A String?

    Answer :

    char *lastchar(char *String, char ch)
    char *pStr = NULL;
    // traverse the entire string
    while( * String ++ != NULL )
    if( *String == ch )
    pStr = String;
    return pStr;

  24. Question 15. What Is All About?

    Answer :

    The newsgroup is intended as a forum for people who want to use or explore the capabilities of Genetic Algorithms (GA), Evolutionary Programming (EP), Evolution Strategies (ES), ClassifierSystems (CFS), Genetic Programming (GP), and some other, less well-known problem solving algorithms that are more or less loosely coupled to the field of Evolutionary Computation (EC).

  25. Data Structure & Algorithms Interview Questions

  26. Question 16. What Is Arcball?

    Answer :

    Arcball is a general purpose 3-D rotation controller described by Ken Shoemake in the Graphics Interface ’92 Proceedings. It features good behavior, easy implementation, cheap execution, and optional axis constraints. A Macintosh demo and electronic version of the original paper (Microsoft Word format)

  27. Genetic Algorithms Tutorial

  28. Question 17. How Do I Rotate A 3d Point?

    Answer :

    Assuming you want to rotate vectors around the origin of your coordinate system. (If you want to rotate around some other point, subtract its coordinates from the point you are rotating, do the rotation, and then add back what you subtracted.) In 3-D, you need not only an angle, but also an axis. (In higher dimensions it gets much worse, very quickly.) Actually, you need 3 independent numbers, and these come in a variety of flavors. The flavor I recommend is unit quaternions.

  29. Object Oriented Analysis and Design Interview Questions

  30. Question 18. How Do I Find A T Value At A Specific Point On A Bezier?

    Answer :

    In general, you’ll need to find t closest to your search point. There are a number of ways you can do this, there’s a chapter on finding the nearest point on the bezier curve. In my experience, digitizing the bezier curve is an acceptable method. You can also try recursively subdividing the curve, see if you point is in the convex hull of the control points, and checking is the control points are close enough to a linear line segment and find the nearest point on the line segment, using linear interpolation and keeping track of the subdivision level, you’ll be able to find t.

  31. C Interview Questions

  32. Question 19. How Do I Generate A Bezier Curve That Is Parallel To Another Bezier?

    Answer :

    You can’t. The only case where this is possible is when the bezier can be represented by a straight line. And then the parallel ‘bezier’ can also be represented by a straight line.

  33. Parallel Algorithm Tutorial

  34. Question 20. How Do I Rotate A 2d Point?

    Answer :

    In 2-D, the 2×2 matrix is very simple. If you want to rotate a column vector v by t degrees using matrix M, use

    M = {{cos t, -sin t}, {sin t, cos t}} in M*v.

    If you have a row vector, use the transpose of M (turn rows into columns and vice versa). If you want to combine rotations, in 2-D you can just add their angles, but in higher dimensions you must multiply their matrices.

  35. Genetic Algorithms Interview Questions

  36. Question 21. State The Problems Which Differentiate Between Recursive Procedure And Non-recursive Procedure?

    Answer :

    A recursive procedure can be called from within or outside itself, and to ensure its proper functioning, it has to save in same order the return address so that it return to the proper location will result when the return to a calling statement is made. The procedure must also save the formal parameters, local variables etc.

  37. Question 22. Explain The Depth Of Recursion?

    Answer :

    This is another recursion procedure which is the number of times the procedure is called recursively in the process of enlarging a given argument or arguments. Usually this quantity is not obvious except in the case of extremely simple recursive functions, such as FACTORIAL (N), for which the depth is N.

  38. Design thinking Tutorial

  39. Question 23. Explain About Procedural Body And Computation Boxes?

    Answer :

    The procedural body contains two computation boxes namely, the partial and final computational boxes. The partial computation box is combined with the procedure call box. The test box determines whether the argument value is that for which explicit definition of the process is given.

  40. Question 24. How Can An Inductive Definition Be Realized?

    Answer :

    An inductive definition of a set can be realized by using a given finite set of elements A and the following three clauses.

    1. Basis Clause
    2. Inductive clause
    3. External clause
  41. OOPS Interview Questions

  42. Question 25. State Recursion And Its Different Types?

    Answer :

    Recursion is the name given to the technique of defining a set or a process in terms of itself. There are essentially two types of recursion. The first type concerns recursively defined function and the second type of recursion is the recursive use of a procedure.

  43. Question 26. Define And Describe An Iterative Process With General Steps Of Flow Chart?

    Answer :

    There are four parts in the iterative process they are:

    Initialization: The decision parameter is used to determine when to exit from the loop.

    Decision: The decision parameter is used to determine whether to remain in the loop or not.

    Computation: The required computation is performed in this part.

    Update: The decision parameter is updated and a transfer to the next iteration results.

  44. Question 27. Given A System Of N Equations Whose Coefficient Matrix A Is Triangular And Is Stored In A Vector R And The Right Hand Side Vector B, This Algorithm Obtains The Solution Vector X. Sum Is A Temporary Variable. I Am M Are Integer Variables. How To Follow The Algorithm?

    Answer :

    The algorithm is easy to follow. X1 is first computed from the first equation and then substituted in the second to obtain X2 and so on.

    Another common application is one in which most of the elements of a large matrix are zeros. In such a case, only the non zero elements need to be stored along with their row and column sub scripts.

  45. Data analyst Interview Questions

  46. Question 28. In Algorithmic Context How Would You Define Book Keeping Operations?

    Answer :

    Usually when a user wants to estimate time he isolates the specific function and brands it as active operation. The other operations in the algorithm, the assignments, the manipulations of the index and the accessing of a value in the vector, occur no more often than the addition of vector values. These operations are collectively called as “book keeping operations”.

  47. Question 29. Explain The Function Sub In Algorithmic Notation?

    Answer :

    In the algorithmic notation rather than using special marker symbols, generally people use the cursor position plus a substring length to isolate a substring. The name of the function is SUB.

    SUB returns a value the sub string of SUBJECT that is specified by the parameters i and j and an assumed value of j.

  48. Question 30. What Are The Arguments Present In Pattern Matching Algorithms?

    Answer :

    These are the following arguments which are present in pattern matching Algorithms.

    1. Subject,
    2. Pattern
    3. Cursor
    4. MATCH_STR