Monica Mona

Monica Mona

61 Articles Published

Articles by Monica Mona

Page 3 of 7

What is 'Space Complexity’?

Monica Mona
Monica Mona
Updated on 17-Jun-2020 6K+ Views

Space ComplexitySpace complexity is an amount of memory used by the algorithm (including the input values of the algorithm), to execute it completely and produce the result.We know that to execute an algorithm it must be loaded in the main memory. The memory can be used in different forms:Variables (This includes the constant values and temporary values)Program InstructionExecutionAuxiliary SpaceAuxiliary space is extra space or temporary space used by the algorithms during its execution.Memory Usage during program executionInstruction Space is used to save compiled instruction in the memory.Environmental Stack is used to storing the addresses while a module calls another module ...

Read More

Parity Check of a Number

Monica Mona
Monica Mona
Updated on 17-Jun-2020 7K+ Views

Parity of a number is based on the number of 1’s present in the binary equivalent of that number. When the count of present 1s is odd, it returns odd parity, for an even number of 1s it returns even parity.As we know that the numbers in computer memory are stored in binary numbers, so we can shift numbers easily. In this case, by shifting the bits, we will count a number of 1’s present in the binary equivalent of the given number.Input and OutputInput: A number: 5 Binary equivalent is (101) Output: Parity of 5 is Odd.AlgorithmfinParity(n)Input: The number ...

Read More

Find Weekday using Zeller's Algorithm

Monica Mona
Monica Mona
Updated on 17-Jun-2020 2K+ Views

Zeller’s Algorithm is used to find the weekday from a given date. The formula to find weekday using Zeller’s Algorithm is here:The formula is containing some variables; They are −d − The day of the date.m: It is the month code. From March to December it is 3 to 12, for January it is 13, and for February it is 14. When we consider January or February, then given year will be decreased by 1.y − Last two digits of the yearc − first two digits of the yearw − The weekday. When it is 0, it is Saturday, when ...

Read More

Number to Roman Numerals

Monica Mona
Monica Mona
Updated on 17-Jun-2020 2K+ Views

Roman numbers are non-positional numbers. Some numerals are placed together to form a number in roman numbers. For an example the number 75 can be expressed as 75 = 50 + 10 + 10 + 5, so the roman numerals are LXXV.In this problem one number is provided in a decimal format, our task is to convert it into the Roman numeral strings.There are different symbols and their value, like this.IIVVIXXXLLXCCCDDCMMMMMMV’145910405090100400500900100040005000Using this table, we can easily find the roman numerals of a given number.Input and OutputInput: Decimal number: 3569 Output: The Roman equivalent of 3569 is: MMMDLXIXAlgorithmdecToRoman(nuList, num)Input: The numeral list ...

Read More

Flood fill Algorithm

Monica Mona
Monica Mona
Updated on 17-Jun-2020 3K+ Views

One matrix is given; the matrix is representing the one screen. Each element (i, j) of the screen is denoted as a pixel, the color of that pixel is marked with different numbers. In this algorithm, the pixels will be filled with new color when it is already in selected previous color. If the previous color is not the previous color, that pixel will not be filled. After filling a pixel, it will check for its up, down, left and right pixels to do the same.The idea is really simple, first, we check whether the selected position is colored with ...

Read More

Factorial of a large number

Monica Mona
Monica Mona
Updated on 17-Jun-2020 2K+ Views

In computers, variables are stored in memory locations. But the size of the memory location is fixed, so when we try to find the factorial of some greater value like 15! or 20! the factorial value exceeds the memory range and returns wrong results.For calculation of large numbers, we have to use an array to store results. In each element of the array, is storing different digits of the result. But here we cannot multiply some number with the array directly, we have to perform manual multiplication process for all digits of the result array.Input and OutputInput: A big number: ...

Read More

Find GCD of two numbers

Monica Mona
Monica Mona
Updated on 17-Jun-2020 2K+ Views

In mathematics, Greatest Common Divisor (GCD) is the largest possible integer, that divides both of the integers. The condition is that the numbers must be non-zero.We will follow the Euclidean Algorithm to find the GCD of two numbers.Input and OutputInput: Two numbers 51 and 34 Output: The GCD is: 17AlgorithmfindGCD(a, b)Input: Two numbers a and b.Output: GCD of a and b.Begin    if a = 0 OR b = 0, then       return 0    if a = b, then       return b    if a > b, then       return findGCD(a-b, b)   ...

Read More

What are variadic functions in Java?

Monica Mona
Monica Mona
Updated on 16-Jun-2020 1K+ Views

Methods which uses variable arguments (varargs, arguments with three dots) are known as variadic functions. Example public class Sample {     void demoMethod(String... args) {         for (String arg: args) {             System.out.println(arg);         }     }     public static void main(String args[] ){         new Sample().demoMethod("ram", "rahim", "robert");         new Sample().demoMethod("krishna", "kasyap");     } } Output ram rahim robert krishna kasyap

Read More

How to use telephone input type in HTML?

Monica Mona
Monica Mona
Updated on 15-Jun-2020 621 Views

The telephone input type is used in HTML using the . Using this, allow the users to add telephone number.Note − The input type tel is only supported in Safari.ExampleYou can try to run the following code to learn how to use input type tel to allow user input in the form of a telephone number −           HTML input search                        Details:          Student Name          Student Telephone                    

Read More

Creating Dictionary using Javascript

Monica Mona
Monica Mona
Updated on 15-Jun-2020 2K+ Views

Let's create a MyMap class so that it doesn't hide the actual Map class in JS. We'll create a container object that'll keep track of all our values that we add to the map. We'll also create a display function that prints the map for us. Exampleclass MyMap {    constructor() {       this.container = {};    }    display() {       console.log(this.container);    } }In ES6, you can directly create a dictionary using the Map class. For example,  Exampleconst map1 = new Map(); const map2 = new Map([    ["key1", "value1"],    ["key2", "value2"] ]);Checking if ...

Read More
Showing 21–30 of 61 articles
« Prev 1 2 3 4 5 7 Next »
Advertisements