Programming Algorithms

  Home  Computer Programming  Programming Algorithms


“Programming Algorithms Interview Questions and Answers will guide us now that an algorithm is an effective method for solving a problem using a finite sequence of instructions. Algorithms are used for calculation, data processing, and many other fields. Each algorithm is a list of well-defined instructions for completing a task. So learn Programming Algorithms with this Programming Algorithms Interview Questions with Answers guide”



30 Programming Algorithms Questions And Answers

21⟩ Counting set bits in a number

First version:

int CoutSetBits(int Num)

{

for(int count=0; Num; Num >>= 1)

{

if (Num & 1)

count++;

}

return count;

}

Optimized version:

int CoutSetBits(int Num)

{

for(int count =0; Num; count++)

{

Num &= Num -1;

}

}

 210 views

22⟩ What is the general strategy for Markov Algorithm?

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.

 196 views

23⟩ What are the two ways through which the Markov algorithm terminates?

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.

 198 views

24⟩ Name any three skills which are very important in order to work with generating functions.

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

 197 views

25⟩ 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?

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.

 204 views

28⟩ How to find median of a BST?

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.

 209 views

29⟩ What is the general algorithm model for any recursive procedure?

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.

 203 views

30⟩ Define string in an algorithmic notation and an example to support it?

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.’.

 202 views