Skip to content

SlayStudy

Learn Computer Science

  • Algorithms
  • Data Structures
  • Coding Questions
  • Graph Theory
  • Hiring
  • Contact

Prolog Program to Reverse a List

Prolog / Leave a Comment / By admin

In this post, we will see how to reverse a list in prolog. Program Output Explaination The first parameter in the reverse/3 predicate is the list. The second parameter is an empty list. The third parameter is the reverse list. The reverse/3 recursively pushes the elements from the beginning of the first list to the …

Prolog Program to Reverse a List Read More »

Prove that the 1+3+5+…+(2n-1)=n^2 for every positive integer

Mathematical Induction / Leave a Comment / By admin

Given 1 + 3 + 5 + 7 + ⋯ + (2n-1) = n2 ∀ n ∈ N Proof We will prove the statement by mathematical induction. STEP 1 In this step, we check if the statement is true for n = 1. LHS = 1 + 3 + 5 + 7 + ⋯ + …

Prove that the 1+3+5+…+(2n-1)=n^2 for every positive integer Read More »

Prove that the sum of the first n odd numbers is a perfect square

Discrete mathematics / Leave a Comment / By admin

Given 1 + 3 + 5 + 7 + ⋯ + (2n-1) = m2 ∀ n, m ∈ N Proof Let, S = 1 + 3 + 5 + .. + (2n-5) + (2n-3) + (2n-1) S is the summation of first n odd numbers. 2*S = ( 1 + 3 + 5 + .. …

Prove that the sum of the first n odd numbers is a perfect square Read More »

Advantages and Disadvantages of Adjacency Matrix Graph Representation

Graph / Leave a Comment / By admin

What is Adjacency Matrix Graph Representation? Adjacency Matrix is a graph data structure. It is a technique to store graphs. The adjacency matrix is a 2D boolean array of size V2 where V is the number of vertices in the graph. The adjacency matrix contains V rows and V columns. The i-th row and j-th …

Advantages and Disadvantages of Adjacency Matrix Graph Representation Read More »

Prove that 4^n-3n-1 is divisible by 9

Mathematical Induction / Leave a Comment / By admin

To Prove 4n – 3n – 1 is divisible by 9 ∀ n ∈ N Proof We will prove the given statement using mathematical induction. Step 1 First, we will check if the given statement is true for n = 1. 4n – 3n – 1 = 41 – 3(1) – 1 = 4 – …

Prove that 4^n-3n-1 is divisible by 9 Read More »

Prove that 3^n-1 is a multiple of 2

Mathematical Induction / Leave a Comment / By admin

To Prove 3n – 1 is a multiple of 2 ∀ n ∈ N Proof We can prove the given statement using many ways. We will discuss 2 of them. Direct Proof We know the product of two odd numbers is always an odd number. This implies that the term 3n is always odd ∀ n …

Prove that 3^n-1 is a multiple of 2 Read More »

Prove that n^3+5n is divisible by 6

Mathematical Induction / Leave a Comment / By admin

To Prove n3 + 5n is divisible by 6 ∀ n ∈ N Proof We will prove the given statement using the principle of mathematical induction Step 1 We need to check if the statement is true for n = 1. n3 + 5n = 13 + 5(1) = 1 + 5 = 6 Therefore, the statement is …

Prove that n^3+5n is divisible by 6 Read More »

Prove that n^2-n is divisible by 2

Discrete mathematics / Leave a Comment / By admin

To Prove n2 – n is divisible by 2 ∀ n ∈ Z Proof n2 – n = n * (n – 1) For the value of n, we have 2 cases n is evenIf n is even, then n * (n – 1) is even since multiplying even number and odd number gives even number. Therefore, …

Prove that n^2-n is divisible by 2 Read More »

Prove that n^2+n is even

Discrete mathematics / Leave a Comment / By admin

To Prove n2 + n is even ∀ n ∈ Z Proof n2 + n = n * (n + 1) For the value of n, we have 2 cases n is evenIf n is even, then n * (n + 1) will also be even since multiplying even number with any integer gives even …

Prove that n^2+n is even Read More »

Program to check whether a given graph is Bipartite

Graph / Leave a Comment / By admin

In this article, we will explain how we can check if a given graph is bipartite or not in detail. Basic Terminologies Bipartite Graph: A simple graph G(V, E) is called Bipartite Graph if it’s vertices can be partitioned into two disjoint sets – V1 and V2, such that no edge connects vertices belonging to …

Program to check whether a given graph is Bipartite Read More »

Posts navigation

1 2 … 23 Next Page →

Thanks for visiting this site. If you face any problem or find any error feel free to contact us.

Copyright © 2023 SlayStudy
Privacy Policy