Find All Pairs with Given Sum in a BST in C++

Hafeezul Kareem
Updated on 01-Feb-2021 12:18:07

402 Views

In this tutorial, we are going to write a program that finds all the pairs whose sum is equal to the given number in the binary search tree.We are going to store and values of trees in two different lists to find the pairs. Let's see the steps to solve the problem.Create a struct node for a binary tree.Write a function to insert a new node into the binary search tree.Remember, in the binary search tree all the elements that are less than root are smaller, and right are larger.Initialize two empty lists to store the left and right nodes ... Read More

Integrate Sikuli Scripts into Selenium

Debomita Bhattacharjee
Updated on 01-Feb-2021 12:17:42

2K+ Views

We can integrate Sikuli scripts into Selenium webdriver. Sikuli is an automation tool which is open-source. It has the feature to capture the images on the elements as well as perform operations on them.Some of the advantages of Sikuli are −Desktop or Windows applications can be automated.Can be used for flash testing.Can be used on platforms like mobile, Mac, and Linux.It is based on image recognition technique.Can be easily integrated with Selenium.To integrate Sikuli with Selenium, follow the below steps − Navigate to the link − https://launchpad.net/sikuli/+download.Click on the jar to download it (which can be used for Java environments) ... Read More

Select and Get Drop Down Option in Selenium

Debomita Bhattacharjee
Updated on 01-Feb-2021 12:15:15

893 Views

We can select the dropdown option in Selenium webdriver. The dropdowns can be worked upon with the help of the Select class. The select tag is used to represent a dropdown and option tag is used to represent items in the dropdown in html.Let us investigate the html structure of a dropdown −We have to add the statement − import org.openqa.selenium.support.ui.Select to use the Select class methods. The Select class methods are listed below −selectByIndex(n) − An option is chosen based on the index of the option on the dropdown. The index n is passed as a parameter to the ... Read More

Resolve Stale Element Reference Exception in Selenium WebDriver

Debomita Bhattacharjee
Updated on 01-Feb-2021 12:14:27

7K+ Views

We can resolve StaleElementReferenceException in Selenium webdriver. The term stale means something which is not fresh and decayed. Thus a stale element points to an element which is not present any more.There may be a case, when an element was in DOM initially but after modifications in Document Object Model (DOM), the element becomes stale and the StaleElementReferenceException is thrown if we make an attempt to access this element.This exception is caused whenever an element is not present in the DOM, or deleted. We can handle this exception by the following ways −Refreshing the page and verifying again.Implement retry method.ExampleCode ... Read More

Find All Divisors of a Natural Number in C++ - Set 2

Hafeezul Kareem
Updated on 01-Feb-2021 12:13:53

2K+ Views

In this tutorial, we are going to write a program that finds all the divisors of a natural number. It's a straightforward problem. Let's see the steps to solve it.Initialize the number.Write a loop that iterates from 1 to the square root of the given number.Check whether the given number is divisible by the current number or not.If the above condition satisfies, then print the current number and given_number/current_number.ExampleLet's see the code. Live Demo#include using namespace std; void findDivisors(int n) {    for (int i = 1; i

Find All Divisors of a Natural Number in C++

Hafeezul Kareem
Updated on 01-Feb-2021 12:10:48

6K+ Views

In this tutorial, we are going to write a program that finds all the divisors of a natural number. It's a straightforward problem. Let's see the steps to solve it.Initialize the number.Write a loop that iterates from 1 to the given number.Check whether the given number is divisible by the current number or not.If the above condition satisfies, then print the current number.ExampleLet's see the code. Live Demo#include using namespace std; void findDivisors(int n) {    for (int i = 1; i

Find All Triplets with Zero Sum in C++

Hafeezul Kareem
Updated on 01-Feb-2021 12:09:53

434 Views

In this tutorial, we are going to write a program that finds the triplet in the array whose sum is equal to the given number.Let's see the steps to solve the problem.Create the array with dummy data.Write three inner loops for three elements that iterate until the end of the array.Add the three elements.Compare the sum with 0.If both are equal, then print the elements and break the loops.ExampleLet's see the code. Live Demo#include using namespace std; void findTripletsWithSumZero(int arr[], int n){    bool is_found = false;    for (int i = 0; i < n-2; i++) {       ... Read More

Click on Hidden Element in Selenium WebDriver

Debomita Bhattacharjee
Updated on 01-Feb-2021 12:09:36

4K+ Views

We can click on the hidden element in Selenium webdriver. In DOM, the hidden elements are the ones which are not displayed on the page. CSS property style should have the value display:none set for the hidden elements. Also, if the hidden element resides within a form tag, it can be made hidden by setting the attribute type to hidden.ElementNotVisibleException is thrown by Selenium while handling hidden elements. So JavaScript Executors can be utilized to access and handle these elements. The executeScript method is used in Selenium to execute the JavaScript commands. The commands to be executed are passed as ... Read More

Convert Selenium IDE Commands to Java

Debomita Bhattacharjee
Updated on 01-Feb-2021 12:09:24

2K+ Views

We can convert commands recorded in Selenium IDE to Java. To convert commands first navigate to File menu, then select the option Export Test case As.After clicking it, all the possible options for conversion get displayed. Choose the option Java/ Junit 4/ WebDriver.Finally, we have to save the file with the .java extension. Then we can open this file using a text Editor or IDE.We can also convert commands recorded in Selenium IDE to Java by navigating to the Options menu. As the Selenium IDE Options pop−up comes up, select the checkbox Enable experimental features. Then click on OK.Next, select ... Read More

Find Value Whose XOR with Given Number is Maximum in C++

Hafeezul Kareem
Updated on 01-Feb-2021 12:09:05

255 Views

In this tutorial, we are going to write a program that finds the number whose XOR operation with the given number is maximum.We are assuming the number of bits here is 8.The XOR operation of different bits gives you the 1 bit. And the XOR operation between the same bits gives you the 0 bit.If we find the 1's complement of the given number, then that's the number we are looking for.ExampleLet's see the code. Live Demo#include using namespace std; int findNumberWithMaximumXOR(int X) {    return ((1

Advertisements