Nishtha Thakur

Nishtha Thakur

398 Articles Published

Articles by Nishtha Thakur

Page 36 of 40

C++ Program to Implement Coppersmith Freivald’s Algorithm

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 606 Views

Freivalds' algorithm determines whether the matrices are equal for a chosen k value with a probability of failure less than 2^-k in O(kn^2).It is used to verify matrix multiplication.AlgorithmBegin    Take matrix1(n*n), matrix2(n*n), matrix3(n*n) as input.    // According to the algorithm we have to verify:    // matrix1 × matrix2 = matrix3.    1) Choose vector a[n][1] randomly and uniformly in which component will be 0 or 1.    2) Compute matrix2 * a, matrix3 * a and then matrix1 * (matrix2 * a) for evaluating the expression, matrix1 * (matrix2 * a) - matrix3 * a.    3) ...

Read More

C++ Program to Represent Linear Equations in Matrix Form

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 640 Views

This is a C++ program to represent Linear Equations in matrix form.AlgorithmBegin    1) Take the no of variables n and the coefficients of each variable as input.    2) Declare a matrix[n][n] and constant[n][1].    3) Make for loops i = 0 to n-1 and j = 0 to n-1    to take the coefficients of each variable as the elements of the matrix.    4) Display the matrix by using nested for loops. EndExample#include using namespace std; int main(void) {    char variable[] = { 'x', 'y', 'z', 'd' };    cout > n;    cout > matrix[i][j];       }       cin >> constant[i][0];    }    cout

Read More

C++ Program to Find Basis and Dimension of a Matrix

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 279 Views

This is a C++ program to find Basis and Dimension of a Matrix.AlgorithmBegin    Function determinant() :    It calculates determinant of the matrix.    /*       Arguments:       n = number of elements.       matrix[10][10] = input matrix.    */    declare the submatrix submatrix[10][10].    //Body of the function:    if (n == 2)       return ((matrix[0][0] * matrix[1][1]) - (matrix[1][0] * matrix[0][1]))    else       Make a for loop c = 0 to n-1          Declare and initialize submati = 0, submatj.     ...

Read More

Which one is better in between pass by value or pass by reference in C++?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 602 Views

In C++ we can pass arguments into a function in different ways. These different ways are −Call by ValueCall by ReferenceCall by AddressSometimes the call by address is referred to as call by reference, but they are different in C++. Incall by address, we use pointer variables to send the exact memory address, but in call by reference we pass the reference variable (alias of that variable). This feature is not present in C, there we have to pass the pointer to get that effect.In this section, we will see what are the advantages of call by reference over call ...

Read More

How to use random () in Android sqlite?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 521 Views

Before getting into example, we should know what sqlite data base in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrate about How to use random () in Android sqliteStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to ...

Read More

How to use length () in Android textview?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 1K+ Views

This example demonstrate about How to use length () in Android textview.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.             In the above code, we have taken the name as Edit text, when user click on button it will take data and check length of entered value is 0 or more than zero than returns last index of “sai”.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; ...

Read More

MongoDB query with an 'or' condition?\\n

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 506 Views

To understand the query with an or condition, let us create a collection with the document. The query to create a collection with a document is as follows −> db.orConditionDemo.insertOne({"CustomerName":"Larry", "ShippingDate":new ISODate("2018-01-29")}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8ec5262f684a30fbdfd56a") } > db.orConditionDemo.insertOne({"CustomerName":"Mike", "ShippingDate":new ISODate("2019-04-13")}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8ec5362f684a30fbdfd56b") } > db.orConditionDemo.insertOne({"CustomerName":"Bob", "ShippingDate":new ISODate("2019-02-21")}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8ec5422f684a30fbdfd56c") } > db.orConditionDemo.insertOne({"CustomerName":"David", "ShippingDate":new ISODate("2019-03-15")}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8ec5532f684a30fbdfd56d") } > db.orConditionDemo.insertOne({"CustomerName":"John", "ShippingDate":new ISODate("2019-03-19")}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8ec56c2f684a30fbdfd56e") }Display all documents ...

Read More

C++ Program to Implement Modular Exponentiation Algorithm

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 2K+ Views

This is a C++ program to implement Modular Exponentiation Algorithm.AlgorithmBegin    function modular():    // Arguments: base, exp, mod.    // Body of the function:       initialize res = 1       while (exp > 0)          if (exp mod 2 == 1)          res= (res * base) % mod          exp = exp left shift 1          base = (base * base) % mod       return res. EndExample#include using namespace std; long long modular(long long base, long long exp, int mod) {    long long res = 1;    while (exp > 0) {       if (exp % 2 == 1)          res= (res * base) % mod;       exp = exp >> 1;       base = (base * base) % mod;    }    return res; } int main() {    long long b, e;    int mod;    coutb;    coute;    coutmod;    cout

Read More

How to use split () in Android textview?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 2K+ Views

This example demonstrate about How to use split () in Android textview.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.             In the above code, we have taken name as Edit text, when user click on button it will take data and split the data using space regex.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.EditText; import ...

Read More

How to remove data from treeset in Android?

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 170 Views

This example demonstrates How to remove data from tree set in AndroidStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.                                       In the above code, we have taken the name and record number as Edit text, when the user clicks on save button it will store the data into ArrayList. Click on delete ...

Read More
Showing 351–360 of 398 articles
« Prev 1 34 35 36 37 38 40 Next »
Advertisements