Given a number X which represents the floor of a matchstick pyramid, write a program to print the total number of matchstick required to form pyramid of matchst
Given an integer n, find the nth Pentagonal number. First three pentagonal numbers are 1, 5 and 12 (Please see below diagram). The n’th pentagonal number Pn i
Given a number , write a program to reverse this number using stack. Examples: Input : 365 Output : 563 Input : 6899 Output : 9986 Recommended: Please try your
A magic number is defined as a number which can be expressed as a power of 5 or sum of unique powers of 5. First few magic numbers are 5, 25, 30(5 + 25), 125, 1
Given a number x, find next number with same number of 1 bits in it’s binary representation. For example, consider x = 12, whose binary representation is 1100
Given an array of sorted integers. We need to find the closest value to the given number. Array may contain duplicate values and negative numbers. Examples: Inp
Given an array of 1s and 0s which has all 1s first followed by all 0s. Find the number of 0s. Count the number of zeroes in the given array. Examples : Input: a
Bit Rotation: A rotation (or circular shift) is an operation similar to shift except that the bits that fall off at one end are put back to the other end. In le
Given a square matrix and the task is to check the matrix is in lower triangular form or not. A square matrix is called lower triangular if all the entries abov
Given a square matrix and the task is to check the matrix is in upper triangular form or not. A square matrix is called upper triangular if all the entries belo
Given a binary matrix (containing only 0 and 1) of order n*n. All rows are sorted already, We need to find the row number with maximum number of 1s. Also find n
Given Q queries, of type: L R, for each query you must print the maximum number of divisors that a number x (L <= x <= R) has. Examples: L = 1 R = 10: 1 has 1 d
Given an array ‘a[]’ and number of queries q. Each query can be represented by l, r, x. Your task is to print the number of elements less than or equal to x
Given a sorted array of n distinct integers where each integer is in the range from 0 to m-1 and m > n. Find the smallest number that is missing from the array.
Given a number x and two positions (from right side) in binary representation of x, write a function that swaps n bits at given two positions and returns the re
Prerequisite – Designing finite automata Problem – Contruct a DFA machine over input alphabet = {0, 1}, that accepts: Odd number of 0’s or even number of
Lex is a computer program that generates lexical analyzers, which is commonly used with the YACC parser generator. Lex, originally written by Mike Lesk and Eric
Prerequisite – Binary to/from Gray Code Problem – Write an assembly language program in 8085 which convert an 8 bit number into grey number Example – Assu
Problem – Write an assembly language program in 8085 microprocessor to convert an 8 bit BCD number into hexadecimal number. Assumptions – Assume that starti
Problem – Write an assembly language program in 8086 microprocessor to convert an 8 bit BCD number into hexadecimal number. Example – Assumption – Initial
Problem – Write an assembly language program in 8086 microprocessor to divide a 16 bit number by an 8 bit number. Example – Algorithm – Assign value 500 i
Problem – Write a program to count number of once in the given 8-bit number use register B to display the count of once where starting address is 2000 and the
In this article, we are discussing how to find number of functions from one set to another. For understanding the basics of functions, you can refer this: Class
Prerequisite – Relational Model Introduction and Codd Rules Any subset of attributes of a table that can uniquely identify all the tuples of that table is kno
Prerequisite – PL/SQL introduction In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare