Narendra Kumar has Published 196 Articles

Mid-Square hashing in C++.

Narendra Kumar

Narendra Kumar

Updated on 31-Oct-2019 05:56:52

2K+ Views

Problem statementThe mid-square method is a method of generating pseudorandom numbers. This method was invented by John von Neumann and was described at a conference in 1949In this technique, an initial seed value is taken and it is squared.Some digits from the middle are extracted and these extracted digits form ... Read More

Mersenne Prime Number in C++.

Narendra Kumar

Narendra Kumar

Updated on 31-Oct-2019 05:54:02

478 Views

DescriptionIn mathematics, a Mersenne prime is a prime number that is one less than a power of two. That is, it is a prime number of the form Mn = 2n − 1 for some integer n.Write a C++ program to print all Mersenne Primes smaller than an input positive ... Read More

Minimize the total number of teddies to be distributed in C++

Narendra Kumar

Narendra Kumar

Updated on 22-Oct-2019 12:23:51

53 Views

Problem statementGiven N number of students and an array which represent the mark obtained by students. School has dicided to give them teddy as a price. Hoever, school wants to save money, so they to minimize the total number of teddies to be distrubuted by imposing following constrain −All students ... Read More

Minimize the sum of squares of sum of N/2 paired formed by N numbers in C++

Narendra Kumar

Narendra Kumar

Updated on 22-Oct-2019 12:16:10

66 Views

Problem statementGiven an array of n elements. The task is to create n/2 pairs in such a way that sum of squares of n/2 pairs is minimal.ExampleIf given array is −arr[] = {5, 10, 7, 4} then minimum sum of squares is 340 if we create pairs as (4, 10) ... Read More

Minimization of ER Diagram

Narendra Kumar

Narendra Kumar

Updated on 22-Oct-2019 12:13:03

2K+ Views

Problem statementER diagram is pictorial representation of shows various tables and relations amongst them. ER diagram we can reduce the number of database.One to one cardinalityLet us consider below diagram with one to one cardinality −Above ER diagram represents 3 entities −Employee entity has 2 attributes namely emp_name. emp_id is ... Read More

Minimax Algorithm in Game Theory (Alpha-Beta Pruning) in C++

Narendra Kumar

Narendra Kumar

Updated on 22-Oct-2019 12:09:07

2K+ Views

DescriptionAplha-Beta pruning is a optimization technique used in minimax algorithm. The idea benind this algorithm is cut off the branches of game tree which need not to be evaluated as better move exists already.This algorithm introduces two new fields −Alpha − This is best value(maximum) that maximizer player can guaratee ... Read More

Deep Copy of Struct Member Arrays in C

Narendra Kumar

Narendra Kumar

Updated on 26-Sep-2019 13:44:41

2K+ Views

Structure allows us to create user defined datatype. Structure member can be primitive datatype or it can be an array of statically allocated memory. When we assign one structure variable to another then shallow copy is performed. However, there is an exception, if structure member is an array then compiler ... Read More

Alternating Vowels and Consonants in C/C++

Narendra Kumar

Narendra Kumar

Updated on 26-Sep-2019 13:41:39

255 Views

Given an input string with vowels and consonants. Rearrange the string such a way that vowels and consonants occupies alternate position in final string. As we are arranging vowels and consonants at alternate position the input string must satisfy either of the following conditions −Number of vowels and consonants must ... Read More

C/C++ Ternary Operator

Narendra Kumar

Narendra Kumar

Updated on 26-Sep-2019 13:36:49

4K+ Views

Syntax of ternary operator is −(expression-1) ? expression-2 : expression-3This operator returns one of two values depending on the result of an expression. If "expression-1" is evaluated to Boolean true, then expression-2 is evaluated and its value is returned as a final result otherwise expression-3 is evaluated and its value ... Read More

C++17 If statement with initializer

Narendra Kumar

Narendra Kumar

Updated on 26-Sep-2019 13:34:49

10K+ Views

C++17 has extended existing if statement’s syntax. Now it is possible to provide initial condition within if statement itself. This new syntax is called "if statement with initializer". This enhancement simplifies common code patterns and helps users keep scopes tight. Which in turn avoids variable leaking outside the scope.ExampleLet us ... Read More

Advertisements