Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 1176 of 3363
9K+ Views
Fetchone() methodFetchone() method is used when you want to select only the first row from the table. This method only returns the first row from the MySQL table.Use of fetchone() methodThe fetchone() is not used as a query to be used to the cursor object. The query passed is “SELECT *” which fetches all the rows from the table.Later , we operate fetchone() method on the result returned by “SELECT *”. The fetchone() method then fetches the first row from that result.Steps you need to follow to fetch first row from a table using MySQL in pythonimport MySQL connectorestablish connection ... Read More
3K+ Views
The tables in MySQL consist of rows and columns. The columns specify the fields and the rows specify the records of data. The data in the tables needs to be fetched to use. We may at times need to fetch all the data from the MySQL table.All the rows can be fetched from the table using the SELECT * statement.SyntaxSELECT * FROM table_nameThe * in the above syntax means to fetch all the rows from the table.Steps you need to follow to select all the data from a table using MySQL in pythonimport MySQL connectorestablish connection with the connector using ... Read More
1K+ Views
This article will show you how to install Numpy in Python on MacOS using 3 different methods as below. Using Homebrew Using Anaconda Using pip What is Numpy NumPy is gaining popularity and being used in various commercial systems. As a result, it's critical to understand what this library has to offer. NumPy is a powerful Python library due to its syntax, which is compact, powerful, and expressive all at the same time. It allows users to manage data in vectors, matrices, and higher-dimensional arrays, and it is also used in array computing in the industry. Method 1: ... Read More
207 Views
Suppose, we are given a binary tree and are asked to find out the lowest common ancestor of all the nodes in the tree. The lowest common ancestor in a binary tree is the lowest node of which the nodes x1, x2, x3, ...., xn are descendants. A particular node can also be a descendant of itself. We have to find the node and return it as an output. The inputs are the root node of the tree and the list of nodes that we have to find the ancestor of.So, if the input is likeand the list of nodes ... Read More
949 Views
Suppose, we are given a binary tree and a node that is situated at the leaf of the binary tree.We have to make the leaf node the root node of the binary tree. We can do it in the following way −If a node has a left child, it becomes the right child.A node's parent becomes its left child. In this process, the parent node's link to that node becomes null, so it will have only one child.The node structure of the tree is like below −TreeNode: data: left: right: parent: We have ... Read More
254 Views
Suppose, we are given a binary tree that has a problem; one of the node's right child pointer points to another node at the same level in the binary tree erroneously. So, to fix this problem, we have to find out the node that has this error and delete that node and its descendants except the node that it is erroneously pointing to. We return the root node of the fixed binary tree.So, if the input is likeWe can see that there is an erroneous link between 4 and 6. The right child pointer of 4 points to 6.then the ... Read More
212 Views
Suppose, we are given a binary tree and also two specific nodes x and y. We have to find out the lowest common ancestor of the two nodes from the binary tree. The lowest common ancestor in a binary tree is the lowest node of which both the nodes x and y are descendants. A particular node can also be a descendant of itself. We have to find the node and return it as an output.The node structure of the tree is like below −TreeNode: data: left: right: parent: We have to utilize ... Read More
187 Views
Suppose, we are given a binary tree and also two specific nodes x and y. We have to find out the lowest common ancestor of the two nodes from the binary tree. The lowest common ancestor in a binary tree is the lowest node of which both the nodes x and y are descendants of. Also, a particular node can also be a descendant of itself. We have to find the node and return it as an output.So, if the input is likeand x = 2, y = 4; then the output will be 3.The node of which the nodes ... Read More
3K+ Views
Suppose, we are given two polynomials and we have to find out the addition of the two polynomials. The polynomials have to be represented as linked lists; the terms of the polynomials will be represented as a linked list node. Each linked list node will contain the coefficient value, power value, and the pointer to the next linked list node. We have to return a third linked list which is the addition of two linked list polynomials.So, if the input is like1x^1 + 1x^2 = 0 and 2x^1 + 3x^0 = 0, then the output will be 3x^1 + 1x^2 ... Read More
2K+ Views
Suppose, we are given the post order traversal of an expression tree. We have to build an expression tree from the given post-order traversal, and then evaluate the expression. We return the root of the expression tree and the evaluated value of the tree.So, if the input is likethen the output will be -7.The postfix order given as input of the tree is ['1', '2', '+', '3', '4', '+', '*']. The expression if evaluated, becomes (1 – 2) * (3 + 4); which equals -7.To solve this, we will follow these steps −LEFT = 0 RIGHT = 1Define a function ... Read More