Found 34484 Articles for Programming

Iterative Method to Find Height of Binary Tree

Shubham Vora
Updated on 21-Jul-2023 21:51:02

303 Views

The binary tree is a data structure. Each node of the binary tree contains either 0, 1, or 2 nodes. So, the binary tree can contain multiple levels. Here, we need to write the iterative code using the loops to find the height of the binary tree. The total number of levels in the binary tree represents the height of the binary tree. Alternatively, we can say that the maximum depth of the binary tree from the root node is the height of the binary tree. Problem statement − We have given a binary tree. We need to ... Read More

Pie chart in pygal

Priya Mishra
Updated on 24-Jul-2023 21:10:57

226 Views

The Pygal library provides a powerful and intuitive way to create visually appealing pie charts in Python. Pie charts are a popular choice for displaying data distribution, and Pygal makes it easy to generate interactive SVG charts with customizable settings. With Pygal's user-friendly interface, we can easily define data, customize colors, titles, labels, legends, and more. Whether we're visualizing sales figures, survey results, or any other categorical data, Pygal's pie charts offer an effective and visually appealing solution. This article explores the creation of pie charts using Pygal, showcasing its versatility and flexibility in presenting data insights. How to ... Read More

How to Efficiently Implement k Queues in a Single Array?

Shubham Vora
Updated on 21-Jul-2023 21:47:38

197 Views

In some cases, we need to implement our own data structure for better usability and customization. Here, we need to implement the K Queues using the single array. The first solution that comes to mind is dividing the array into N/K parts and using each part of the array as a queue. Here, N is the array length. The problem with this solution is that we can’t utilize the array's space properly. If the array is not full, but any Mth queue indexes are full, we can’t insert an element to the Mth queue. So, we need an optimized approach. ... Read More

Find the Number of 'X' Total Shapes

Shubham Vora
Updated on 22-Jul-2023 14:50:19

100 Views

In this problem, we need to find the total number of ‘X’ shapes in the given matrix. We can construct the single ‘X’ shape using 1 or more adjacent ‘X’ elements. We can use the DFS (depth−first search) technique to solve the problem. For each ‘X’ element, we can find all adjacent elements using DFS and count it as a single ‘X’ shape. If we find a new ‘X’, we find its adjacent again. Here, we will use the iterative and recursive DFS to find the total number of ‘X” shapes. Problem statement − We have given a matrix[] of ... Read More

Perform addition and subtraction using CherryPy

Priya Mishra
Updated on 24-Jul-2023 21:06:50

93 Views

CherryPy, a versatile Python web framework, offers a convenient and efficient way to perform addition and subtraction operations. In this article, we delve into the process of utilizing CherryPy to carry out basic arithmetic calculations within a web application. By leveraging CherryPy's lightweight and intuitive features, developers can effortlessly implement addition and subtraction functionalities, making mathematical operations seamless and easily accessible to users. How to perform addition and subtraction using CherryPy? Below are the steps that we will follow to perform addition and subtraction using CherryPy − We import the CherryPy module, which allows us to create a web ... Read More

Check if any valid sequence is divisible by M

Divya Sahni
Updated on 25-Jul-2023 12:20:14

78 Views

A sequence is a collection of objects, and in our case, it is a collection of integers. The task is to find if a sequence with the usage of the addition and subtraction operator within the elements is divisible by M or not. Problem Statement Given an integer M and an array of integers. Using only addition and subtraction between elements check if there is a valid sequence whose solution is divisible by M. Sample Example 1 Input: M = 2, arr = {1, 2, 5} Output: TRUE Explanation − For the given array a valid sequence {1 ... Read More

Pause method - Action Chains in Selenium Python

Priya Mishra
Updated on 24-Jul-2023 21:00:54

800 Views

The Pause method is an essential technique utilized in Selenium Python for implementing Action Chains. Action Chains allow users to perform complex interactions on web pages, such as hovering over elements, clicking and dragging, and more. By incorporating the Pause method, programmers can introduce specific time delays between actions, ensuring accurate execution and synchronization. This article explores the significance of the Pause method and how it enhances the functionality and reliability of Action Chains in Selenium Python. What are Action chains? Action Chains, in Selenium Python, allow users to perform a series of actions sequentially, mimicking real user interactions. ... Read More

Parkinson Disease Prediction using Machine Learning in Python

Priya Mishra
Updated on 24-Jul-2023 20:58:50

391 Views

Parkinson's Disease is a neurodegenerative disorder that affects millions worldwide, early and accurate diagnosis is crucial for effective treatment which can easily be done using machine learning in Python. This article explores the application of machine learning techniques in predicting Parkinson's Disease using a dataset from the UCI machine learning repository. By employing the Random Forest Classifier algorithm, we demonstrate how Python can be leveraged to analyze and preprocess data, train a predictive model, and make accurate predictions. Parkinson Disease Prediction using Machine Learning in Python We have used Jupyter notebook to run the code in this article. Below ... Read More

Parent element method in Selenium Python

Priya Mishra
Updated on 24-Jul-2023 20:54:46

1K+ Views

Selenium is a robust tool that enables the automation of web browsers, and Python is widely employed for test automation, a significant aspect of Selenium is its capability to find elements on web pages through diverse approaches which can easily be done using the parent element method that emerges as a valuable technique. By recognizing and manipulating the parent element associated with a particular target element, testers can effectively engage with specific sections of a webpage. This article delves into the parent element method in Selenium Python, shedding light on its benefits and practical implementation strategies. What is a ... Read More

How to take a random row from a PySpark DataFrame?

Priya Mishra
Updated on 24-Jul-2023 20:41:54

3K+ Views

In PySpark, working with large datasets often requires extracting a random row from a DataFrame for various purposes such as sampling or testing. However, the process of selecting a random row can be challenging due to the distributed nature of Spark. In this article, we explore efficient techniques to tackle this task, discussing different approaches and providing code examples to help you effortlessly extract a random row from a PySpark DataFrame. How to take a random row from a PySpark DataFrame? Below are the Approaches or the methods using which we can take a random row from a PySpark ... Read More

Advertisements