code-rag-bench/online-tutorials huggingface dataset:
Data Structures | Binary Trees | Question 10

28 Jun, 2021
A complete n-ary tree is a tree in which each node has n children or no children. Let I be the number of internal nodes and L be the number of leaves in a complete n-ary tree. If L = 41, and I = 10, what is the value of n?(A) 6(B) 3(C) 4(D) 5Answer: (D)Explanation: For an n-ary tree where each node has n children or no children, following relation holds
    L = (n-1)*I + 1
Where L is the number of leaf nodes and I is the number of internal nodes.
Let us find out the value of n for the given data.
  L = 41 , I = 10
  41 = 10*(n-1) + 1
  (n-1) = 4
  n = 5
Quiz of this Question
Binary Trees Quiz
Data Structures
Data Structures-Binary Trees
Data Structures
Data Structures
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Data Structures | Array | Question 2
Data Structures | Queue | Question 2
Amazon Interview Experience for SDE-II
Data Structures | Hash | Question 5
Data Structures | Misc | Question 9
Data Structures | Linked List | Question 4
Data Structures | Linked List | Question 16
Bit manipulation | Swap Endianness of a number
FIFO vs LIFO approach in Programming
UGC-NET | UGC NET CS 2018 July - II | Question 70
LongAdder increment() method in Java with Examples

28 Jan, 2019
LongAdder class in Java creates a new adder with an initial sum of zero. The Java.LongAdder.increment() is an inbuilt method in java that increases the value by 1.
Syntax:
public void increment()

Parameters: The function does not accepts any parameter.
Return value: The method do not returns any value.
Below programs demonstrate the above function:
Program 1:
// Java program to demonstrate// the LongAdder.increment() method  import java.lang.*;import java.util.concurrent.atomic.LongAdder;  public class GFG {    public static void main(String args[])    {          // Initialized with 0        LongAdder num = new LongAdder();          // Print the initial value        System.out.println("Initial value is: "                           + num);          // Add 6 to it        num.add(6);          // Print the new value        System.out.println("After addition"                           + " of 6, value is: "                           + num);          // Increment operation on num        num.increment();          // Print after increment        System.out.println("After increment, "                           + " value is: "                           + num);    }}
Initial value is: 0
After addition of 6, value is: 6
After increment,  value is: 7

Program 2:
// Java program to demonstrate// the LongAdder.increment() method  import java.lang.*;import java.util.concurrent.atomic.LongAdder;  public class GFG {    public static void main(String args[])    {          // Initialized with 0        LongAdder num = new LongAdder();          // Print the initial value        System.out.println("Initial value is: "                           + num);          // Add 10 to it        num.add(10);          // Print the new value        System.out.println("After addition"                           + " of 10, value is: "                           + num);          // Increment operation on num        num.increment();          // Print after increment        System.out.println("After increment, "                           + " value is: "                           + num);    }}
Initial value is: 0
After addition of 10, value is: 10
After increment,  value is: 11

Java - util package
Java-Functions
Java-LongAdder
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
How to iterate any Map in Java
Interfaces in Java
HashMap in Java with Examples
ArrayList in Java
Multidimensional Arrays in Java
Collections in Java
Set in Java
Stream In Java
Initializing a List in Java
How to Use Enumeration to Display Elements of Hashtable in Java?

18 Nov, 2021
Hashtable class implements a hash table, which maps keys to values. Any non-null object can be used as a key or as a value. To successfully store and retrieve objects from a hashtable, the objects used as keys must implement the hashCode method and the equals method.  
Now here we can get the keys and values of a Hashtable as an Enumeration object using keys() and elements() method. We can obtain all keys and values respectively as an Enumeration object using Enumeration methods like hasMoreElements() and nextElement() we can read all keys and values corresponding to a Hashtable.
Example 1:
Java
// Java Program to Demonstrate Getting Values// as an Enumeration of Hashtable class  import java.io.*;import java.util.Enumeration;import java.util.Hashtable;  // Main class// EnumerationOnKeyspublic class GFG {      // Main driver method    public static void main(String[] args)    {        // Creating an empty hashtable        Hashtable<Integer, String> ht            = new Hashtable<Integer, String>();          // Inserting key-value pairs into hash table        // using put() method        ht.put(1, "Geeks");        ht.put(2, "for");        ht.put(3, "Geeks");          // Now creating an Enumeration object        //  to read elements        Enumeration e = ht.elements();          // Condition holds true till there is        // single key remaining          // Printing elements of hashtable        // using enumeration        while (e.hasMoreElements()) {              // Printing the current element            System.out.println(e.nextElement());        }    }}
Geeks
for
Geeks
 Example 2:
Java
// Java Program to Demonstrate Getting Keys// as an Enumeration of Hashtable class  // Importing required classesimport java.io.*;import java.util.*;  // Main classclass GFG {      // Main driver method    public static void main(String[] args)    {        // Creating an empty hashtable        Hashtable<String, String> ht            = new Hashtable<String, String>();          // Inserting key-value pairs into hash table        // using put() method        ht.put("Name", "Rohan");        ht.put("Age", "23");        ht.put("Address", "India");        ht.put("Article", "GeeksforGeeks");          // Now creating an Enumeration object        // to store keys        Enumeration<String> e = ht.keys();          // Condition holds true till there is        // single key remaining        while (e.hasMoreElements()) {              // Getting key            String key = e.nextElement();              // Printing key and value corresponding to            // that key            System.out.println(key + ":" + ht.get(key));        }    }}
Name:Rohan
Article:GeeksforGeeks
Age:23
Address:India
solankimayank
Java-HashTable
Java
Java Programs
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Word Similarity using spaCy

19 Jul, 2019
Word similarity is a number between 0 to 1 which tells us how close two words are, semantically. This is done by finding similarity between word vectors in the vector space. spaCy, one of the fastest NLP libraries widely used today, provides a simple method for this task.
spaCy’s Model –spaCy supports two methods to find word similarity: using context-sensitive tensors, and using word vectors. Below is the code to download these models.
# Downloading the small model containing tensors.
python -m spacy download en_core_web_sm

# Downloading over 1 million word vectors.
python -m spacy download en_core_web_lg

Below is the code to find word similarity, which can be extended to sentences and documents.
import spacy  nlp = spacy.load('en_core_web_md')  print("Enter two space-separated words")words = input()  tokens = nlp(words)  for token in tokens:    # Printing the following attributes of each token.    # text: the word string, has_vector: if it contains    # a vector representation in the model,     # vector_norm: the algebraic norm of the vector,    # is_oov: if the word is out of vocabulary.    print(token.text, token.has_vector, token.vector_norm, token.is_oov)  token1, token2 = tokens[0], tokens[1]  print("Similarity:", token1.similarity(token2))
Output:
cat True 6.6808186 False
dog True 7.0336733 False
Similarity: 0.80168545

The ‘en_core_web_md’ model yields vectors of dimension 300*1 for ‘dog’ and ‘cat’. One may also use the larger model, ‘en_vectors_web_lg’ which yields vectors of larger dimension for the same two words.
Using Custom Language Models –By simply switching the language model, we can find a similarity between Latin, French or German documents. spaCy supports a total of 49 languages at present. spaCy also allows one to fix word vectors for words as per user need. Below is an example.
import spacyimport numpy as npfrom spacy.vocab import Vocab  nlp = spacy.load('en_core_web_md')new_word = 'bucrest'  print('Before custom setting')print(vocab.get_vector('bucrest'))  custom_vector = np.random.uniform(-1, 1, (300, ))  vocab.set_vector(new_word, custom_vector)  print('After custom setting')print(vocab.get_vector('bucrest'))
Output:
Before custom setting
array([0., 0., 0., 0., 0., 0., 0., 0., --- ])

After custom setting
array([ 0.68106073,  0.6037007,  0.9526876, -0.25600302, -0.24049562, --- ])

Natural-language-processing
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How can I show and hide div on mouse click using jQuery?

To show and hide div on mouse click using jQuery, use the toggle() method. On mouse click, the div is visible and on again clicking the div, it hides.
Live Demo
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $('#show').click(function() {
      $('.menu').toggle("slide");
    });
});
</script>
</head>
<body>

<div id="show">Click to Show/ Hide div</div>
 <div class="menu" style="display: none;">
    <ol>
      <li>India</li>
      <li>US</li>
      <li>UK</li>
      <li>Australia</li>
    </ol>
 </div>
</body>
</html>
How to use seek() method to reset a file read/write position in Python?

You can use the seek(offset[, whence]) method. It sets the file's current position, like stdio's fseek(). The whence argument is optional and defaults to 0 (absolute file positioning); other values are 1 (seek relative to the current position) and 2 (seek relative to the file's end).
For example, if you already have a file open and want to go back to starting position, you can use:
f = open('my_file.txt', 'r')
f.seek(0)
f.close()
This will seek the pointer to beginning of the file. You can also provide the second argument as 2 and get the pointer to end of file.
C++ List Library - pop_back() Function

The C++ function std::list::pop_back() removes the last element from list and reduces size of the list by one.
Following is the declaration for std::list::pop_back() function form std::list header.
void pop_back();

None
None
This member function never throws exception. Calling this function on empty list causes undefined behavior.
Constant i.e. O(1)
The following example shows the usage of std::list::pop_back() function.
#include <iostream>
#include <list>

using namespace std;

int main(void) {
   list<int> l = {1, 2, 3, 4, 5};

   cout << "List contains following elements before pop_back operation" << endl;

   for (auto it = l.begin(); it != l.end(); ++it)
      cout << *it << endl;

   l.pop_back();

   cout << "List contains following elements after pop_back operation" << endl;

   for (auto it = l.begin(); it != l.end(); ++it)
      cout << *it << endl;

   return 0;
}
Let us compile and run the above program, this will produce the following result −
List contains following elements before pop_back operation
1
2
3
4
5
List contains following elements after pop_back operation
1
2
3
4

 Print
 Add Notes
 Bookmark this page
How to use pattern attribute in HTML?

The pattern attribute in HTML is used to set a regular expression in the following input types: text, url, tel, search, date, email, and password. For passwords, with the pattern attribute, you can set the minimum required values. For example, password should have at least 8 characters.
You can try to run the following code to learn how to use pattern attribute in HTML. Here, we have set the pattern for 8 or more characters in the password. If a user will add less than that, then by clicking Submit button, an error will raise i.e. “Please match the requested format: Eight or more characters”.
<!DOCTYPE html>
<html>
   <body>
      <h2>Register</h2>
      <form action="/new.php">
         Student UserName<br><input type = "text" name = "name"/><br>
         Password<br><input type = "password" name = "password" pattern = ".{8,}"
         title="Eight or more characters"><br><br>
         <input type = "submit" value = "Submit">
      </form>
   </body>
</html>
Hide popover using Bootstrap .popover("hide") method

To hide the displayed popover, use the popover(“hide”) method.
Use the method to hide the popover like this −
$(".btn-primary").click(function(){
  $("[data-toggle='popover']").popover('hide');
});
You can try to run the following code to implement the popover(“hide”) method −
Live Demo
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  </head>

<body>

  <div class="container">
    <h3>Example</h3>
    <a href="#" data-toggle="popover" title="Demo Header" data-content="This is demo text!">Info</a>
    <div>
      <p>The following is a demo button:</p>
      <button type="button" class="btn btn-default">Display</button>
      <button type="button" class="btn btn-primary">Hide</button>
    </div>  
  </div>

<script>
  $(document).ready(function(){
    $(".btn-default").click(function(){
      $("[data-toggle='popover']").popover('show');
    });
    $(".btn-primary").click(function(){
      $("[data-toggle='popover']").popover('hide');
    });
  });
</script>

</body>
</html>
Difference Between Primary key and Foreign key in DBMS

In this post, we will understand the difference between Primary key and Foreign key in DBMS
It is used to ensure that the data in the specific column is unique.
It is used to ensure that the data in the specific column is unique.
It helps uniquely identify a record in a relational database.
It helps uniquely identify a record in a relational database.
One primary key only is allowed in a table.
One primary key only is allowed in a table.
It is a combination of the ‘UNIQUE’ and ‘Not Null’ constraints.
It is a combination of the ‘UNIQUE’ and ‘Not Null’ constraints.
This means it can’t be a NULL value.
This means it can’t be a NULL value.
Its value can’t be deleted from parent table.
Its value can’t be deleted from parent table.
The constraint can be implicitly defined for the temporary tables.
The constraint can be implicitly defined for the temporary tables.
CREATE TABLE table_name (
col_name int NOT NULL PRIMARY KEY,
....
);
It is a column or a group of columns in a relational database table.
It is a column or a group of columns in a relational database table.
It gives a link between the data in both the tables.
It gives a link between the data in both the tables.
It is the field in a table which is analogous to primary key of other table.
It is the field in a table which is analogous to primary key of other table.
More than one foreign key is allowed in a table.
More than one foreign key is allowed in a table.
It can contain duplicate values in a relational database.
It can contain duplicate values in a relational database.
It can contain NULL values.
It can contain NULL values.
Its value can be deleted from the child table.
Its value can be deleted from the child table.
The constraint can’t be defined on local or global temporary tables.
The constraint can’t be defined on local or global temporary tables.
CREATE TABLE table_name (
   col_name int NOT NULL PRIMARY KEY,
   col_name int FOREIGN KEY REFERENCES Persons(col_name)
);
Add a temporary column in MySQL where the values depend on another column?

You can use CASE statement for this and set conditions to get result in the temporary column.
Let us first create a table −
mysql> create table DemoTable
   (
   EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   EmployeeName varchar(20),
   EmployeeSalary int,
   EmployeeExperience int
   );
Query OK, 0 rows affected (0.64 sec)
Following is the query to insert some records in the table using insert command −
mysql> insert into DemoTable(EmployeeName,EmployeeSalary,EmployeeExperience) values('Larry',4500,5);
Query OK, 1 row affected (0.20 sec)
mysql> insert into DemoTable(EmployeeName,EmployeeSalary,EmployeeExperience) values('Mike',130000,8);
Query OK, 1 row affected (0.21 sec)
mysql> insert into DemoTable(EmployeeName,EmployeeSalary,EmployeeExperience) values('Sam',11000,5);
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable(EmployeeName,EmployeeSalary,EmployeeExperience) values('Carol',140000,8) ;
Query OK, 1 row affected (0.18 sec)
Following is the query to display records from the table using select command −
mysql> select *from DemoTable;
This will produce the following output −
+------------+--------------+----------------+--------------------+
| EmployeeId | EmployeeName | EmployeeSalary | EmployeeExperience |
+------------+--------------+----------------+--------------------+
| 1          | Larry        | 4500           | 5                  |
| 2          | Mike         | 130000         | 8                  |
| 3          | Sam          | 11000          | 5                  |
| 4          | Carol        | 140000         | 8                  |
+------------+--------------+----------------+--------------------+
4 rows in set (0.00 sec)
Following is the query to add a temporary column in MySQL where the values depend on another column. Here the temporary column is NewSalary −
mysql> select EmployeeId,EmployeeName,EmployeeSalary,EmployeeExperience,
case when
   EmployeeExperience=5 then EmployeeSalary+10000
   when EmployeeExperience=8 then EmployeeSalary+20000
else null
   end as NewSalary
from DemoTable;
This will produce the following output −
+------------+--------------+----------------+--------------------+-----------+
| EmployeeId | EmployeeName | EmployeeSalary | EmployeeExperience | NewSalary |
+------------+--------------+----------------+--------------------+-----------+
| 1          | Larry        | 4500           | 5                  | 14500     |
| 2          | Mike         | 130000         | 8                  | 150000    |
| 3          | Sam          | 11000          | 5                  | 21000     |
| 4          | Carol        | 140000         | 8                  | 160000    |
+------------+--------------+----------------+--------------------+-----------+
4 rows in set (0.00 sec)
Trailing zeroes in factorial | Practice | GeeksforGeeks

For an integer N find the number of trailing zeroes in N!.
Example 1:
Input:
N = 5
Output:
1
Explanation:
5! = 120 so the number of trailing zero is 1.
Example 2:
Input:
N = 4
Output:
0
Explanation:
4! = 24 so the number of trailing zero is 0.
Your Task:  
You don't need to read input or print anything. Your task is to complete the function trailingZeroes() which take an integer N as an input parameter and returns the count of trailing zeroes in the N!.
Expected Time Complexity: O(logN)
Expected Auxiliary Space: O(1)
Constraints:
1 <= N <= 109
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
                    want to view the editorial?
 Login to access your submissions. 

Problem


Contest

Reset the IDE using the second button on the top right corner.
Avoid using static/global variables in your code as your code is tested against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases does not guarantee the correctness of code. On submission, your code is tested against multiple test cases consisting of all possible corner cases and stress constraints.
You can access the hints to get an idea about what is expected of you as well as the final solution code.
You can view the solutions submitted by other users from the submission tab.
How to get innerHTML of a div tag using jQuery?

To get the innerHTML of a div tag in jQuery, use the class with innerHTML. You can try to run the following code to learn how to get innerHTML of a div tag using jQuery −
Live Demo
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
 $(document).ready(function(){
   $("#button1").click(function(){
     var one = $('.a').innerHTML;
     alert(one);
   });
 });
</script>
</head>

<body>
   <div class="a">Value one</div>
   <button id="button1">Get</button>
</body>

</html>
Bootstrap .btn-lg class

To make a large button, use the .btn-lg class in Bootstrap.
You can try to run the following code to implement the btn-lg class
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <meta name = "viewport" content = "width=device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
   </head>
   <body>
      <button type = "button" class = "btn btn-default btn-lg">
         Large button
      </button>
   </body>
</html>
Tryit Editor v3.7

Tryit: Using pixels
Tryit Editor v3.7

Tryit: HTML table border style
What are the properties of Regular expressions in TOC?

A regular expression is basically a shorthand way of showing how a regular language is built from the base set of regular languages.
The symbols are identical which are used to construct the languages, and any given expression that has a language closely associated with it.
For each regular expression E, there is a regular language L(E).
There are some general equalities for the regular expressions.
Properties
All the properties held for any regular expressions R, E, F and can be verified by using properties of languages and sets.
Additive (+) properties
The additive properties of regular expressions are as follows −
R + E = E + R
R + ∅ = ∅ + R = R
R + R = R
(R + E) + F = R + (E + F)
Product (·) properties
The product properties of regular expressions are as follows −
R∅ = ∅R = ∅
R∧ = ∧R = R
(RE)F = R(EF)
Distributive properties
The distributive properties of regular expressions are as follows −
R(E + F) = RE + RF
(R + E)F = RF + EF
Closure properties
The closure properties of regular expressions are as follows −
∅* = ∧ * = ∧
R* = R*R* = (R*)* = R + R*
R* = ∧ + RR* = (∧ + R)R*
RR* = R*R
R(ER)* = (RE)*R
(R + E)* = (R*E*)* = (R* + E*)* = R*(ER*)*
All the properties can be verified by using the properties of languages and sets.
Example 1
Show that
(∅ + a + b)* = a*(ba*)*
Using the properties above:
(∅ + a + b)* = (a + b)* (+ property)
= a*(ba*)* (closure property).
Example 2
Show that
∧ + ab + abab(ab)* = (ab)*
Using the properties above:
∧ + ab + abab(ab)* = ∧ + ab(∧ + ab(ab)*)
                  = ∧ + ab((ab)*) (using R* = ∧ + RR*)
= ∧ + ab(ab)*= (ab)* (using R* = ∧ + RR* again)
Convert Character value to ASCII value in R Programming - charToRaw() Function - GeeksforGeeks

02 Mar, 2021
charToRaw() function in R Language is used to convert the given character to their corresponding ASCII value or “raw” objects. 
Syntax: charToRaw(x)Parameters: x: Given characters to be converted  
Example 1:  
Python3
# R program to illustrate# charToRaw function # Calling charToRaw() function over# some alphabetsx <- charToRaw("a")y <- charToRaw("A")z <- charToRaw("ab") # Getting the corresponding ASCII valuexyz
Output :  
[1] 61
[1] 41
[1] 61 62
Example 2:  
Python3
# R program to illustrate# charToRaw function # Initializing some stringsa <- "Geeks"b <- "GFG is a CS Portal" # Calling charToRaw() function# over above stringsc <- charToRaw(a)d <- charToRaw(b) # Getting the ASCII values of the above# specified stringscd
Output:  
[1] 47 65 65 6b 73
[1] 47 46 47 20 69 73 20 61 20 43 53 20 50 6f 72 74 61 6c
 
arorakashish0911
R String-Functions
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Replace specific values in column in R DataFrame ?
How to change Row Names of DataFrame in R ?
Filter data by multiple conditions in R using Dplyr
Loops in R (for, while, repeat)
Change Color of Bars in Barchart using ggplot2 in R
Printing Output of an R Program
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
K-Means Clustering in R Programming
JSF - Validator Tags

JSF provides inbuilt validators to validate its UI components. These tags can validate the length of the field, the type of input which can be a custom object.
For these tags you need to use the following namespaces of URI in html node.
<html 
   xmlns = "http://www.w3.org/1999/xhtml" 
   xmlns:f = "http://java.sun.com/jsf/core">

Following are important Validator Tags in JSF 2.0−
Validates the length of a string
Validates the range of a numeric value
Validates the range of a float value
Validates JSF component with a given regular expression
Creates a custom validator

    37 Lectures 
     3.5 hours 

 Chaand Sheikh
 Print
 Add Notes
 Bookmark this page
N-th Tribonacci Number in C++

Suppose we have a value n, we have to generate n-th Tribonacci number. The Tribonacci numbers are similar to the Fibonacci numbers, but here we are generating a term by adding three previous terms. Suppose we want to generate T(n), then the formula will be like below −
T(n) = T(n - 1) + T(n - 2) + T(n - 3)
The first few numbers to start, are {0, 1, 1}
We can solve them by following this algorithm −
• first := 0, second := 1, third := 1
• for i in range n – 3, do
   o next := first + second + third
   o first := second, second := third, third := next
• return third
 Live Demo
#include<iostream>
using namespace std;
long tribonacci_gen(int n){
   //function to generate n tetranacci numbers
   int first = 0, second = 1, third = 1;
   for(int i = 0; i < n - 3; i++){
      int next = first + second + third;
      first = second;
      second = third;
      third = next;
   }
   return third;
}
main(){
   cout << "15th Tribonacci Term: " << tribonacci_gen(15);
}
15
15th Tribonacci Term: 1705
How to center a popup window on screen using JavaScript?

To center a popup window on the screen, you can try to run the following code
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <script>
         function myPopup(myURL, title, myWidth, myHeight) {
            var left = (screen.width - myWidth) / 2;
            var top = (screen.height - myHeight) / 4;
            var myWindow = window.open(myURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + myWidth + ', height=' + myHeight + ', top=' + top + ', left=' + left);
         }
      </script>
      <button onclick=" myPopup ('http://www.qries.com', 'web', 1050, 550);">Open Qries.com</button>
   </body>
</html>
GATE | GATE-CS-2007 | Question 76

28 Jun, 2021
Suppose the letters a, b, c, d, e, f have probabilities 1/2, 1/4, 1/8, 1/16, 1/32, 1/32 respectively. Which of the following is the Huffman code for the letter a, b, c, d, e, f?(A) 0, 10, 110, 1110, 11110, 11111(B) 11, 10, 011, 010, 001, 000(C) 11, 10, 01, 001, 0001, 0000(D) 110, 100, 010, 000, 001, 111Answer: (A)Explanation: We get the following Huffman Tree after applying Huffman Coding Algorithm. The idea is to keep the least probable characters as low as possible by picking them first.
The letters a, b, c, d, e, f have probabilities 
1/2, 1/4, 1/8, 1/16, 1/32, 1/32 respectively. 

                 1
               /   \
              /     \
             1/2    a(1/2)
            /  \
           /    \
          1/4  b(1/4) 
         /   \
        /     \
       1/8   c(1/8) 
      /  \
     /    \
   1/16  d(1/16)
  /  \
 e    f
Quiz of this Question
GATE-CS-2007
GATE-GATE-CS-2007
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PyQt5 – How to create semi transparent window ?

26 Mar, 2020
When we design an application in PyQt5, the main window is used to appear by default the window is opaque, but we can make it transparent as well. we can do this by using setWindowOpacity() method which belongs to the QWidget class.
Syntax : setWindowOpacity(0.5)
Argument : It takes float value as argument : 0 for completely transparent and 1 for opaque.
Action performed : Makes the window transparent.
Code :
# importing the required libraries  from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * import sys    class Window(QMainWindow):        def __init__(self):        super().__init__()            # set the title        self.setWindowTitle("Python")          self.setWindowOpacity(0.5)            # setting  the geometry of window        self.setGeometry(60, 60, 600, 400)          # creating a label widget        self.label_1 = QLabel("transparent ", self)        # moving position        self.label_1.move(100, 100)          self.label_1.adjustSize()          # show all the widgets        self.show()    # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
jQuery getJSON() Method

24 Nov, 2021
In this article, we will learn about the getJSON() method in jQuery, along with understanding their implementation through the example. jQuery is an open-source JavaScript library that simplifies the interactions between an HTML/CSS document, It is widely famous for its philosophy of “Write less, do more”. 
The getJSON() method in jQuery fetches JSON-encoded data from the server using a GET HTTP request.
Syntax:
$(selector).getJSON(url,data,success(data,status,xhr))
Parameters: This method accepts three parameters as mentioned above and described below:
url: It is a required parameter. It is used to specify the URL in the form of a string to which the request is sent
data: It is an optional parameter that specifies data that will be sent to the server.
callback: It is also an optional parameter that runs when the request succeeds.
Return Value: It returns XMLHttpRequest object.
Please refer to the jQuery Tutorial and jQuery Examples articles for further details.
Example: The below example illustrates the getJSON() method in jQuery.
employee.json file:
{ “name”: “Tony Stark”, “age” : “53”, “role”: “Techincal content writer”, “company”:”Geeks for Geeks” }
Here, we get the JSON file and displays its content.
HTML
<!DOCTYPE html><html>  <head>    <title>jQuery getJSON() Method</title>    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">    </script>          <!-- Script to get JSON file and display its content -->    <script type="text/javascript" language="javascript">    $(document).ready(function() {        $("#fetch").click(function(event) {            $.getJSON('employee.json', function(emp) {                $('#display').html('<p> Name: ' + emp.name + '</p>');                $('#display').append('<p>Age : ' + emp.age + '</p>');                $('#display').append('<p> Role: ' + emp.role + '</p>');                $('#display').append('<p> Company: '                + emp.company                 + '</p>');            });        });    });    </script></head>  <body>      <p> Click on the button to fetch employee data </p>      <div id="display" style="background-color:#39B54A;"></div>    <input type="button" id="fetch" value="Fetch Employee Data" /> </body>  </html>
Output:
 getJSON() Method
bhaskargeeksforgeeks
jQuery-AJAX
jQuery-Questions
Picked
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Find roots or zeros of a Polynomial in R Programming – polyroot() Function

12 Jun, 2020
polyroot() function in R Language is used to calculate roots of a polynomial equation.A polynomial equation is represented as,
p(x) = (z1) + (z2 * x) + (z3 * x2) +...+ (z[n] * xn-1)
Syntax: polyroot(z)
Parameters:z: Vector of polynomial coefficients in Increasing order
Example 1:
# R program to find zeros of a polynomial  # Creating vectors of coefficientsx1 <- c(1, 2, 3)x2 <- c(-8, 4, -2)x3 <- c(12, -2, 3)  # Calling polyroot() functionpolyroot(x1)polyroot(x2)polyroot(x3)
Output:
[1] -0.3333333+0.4714045i -0.3333333-0.4714045i
[1] 1+1.732051i 1-1.732051i
[1] 0.333333+1.972027i 0.333333-1.972027i

Example 2:
# R program to find zeros of a polynomial  # Calling polyroot() function  # For equation 2x - 3 = 0polyroot(c(-3, 2))  # For equation 3x ^ 2 - 4x + 5 = 0polyroot(c(5, -4, 3))  # For equation 2x ^ 4 - 3x -12 = 0polyroot(c(-12, -3, 0, 2))
Output:
[1] 1.5+0i
[1] 0.666667+1.105542i 0.666667-1.105542i
[1]  2.090489+0.000000i -1.045244+1.333269i -1.045244-1.333269i

R Math-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Filter data by multiple conditions in R using Dplyr
How to Replace specific values in column in R DataFrame ?
Change Color of Bars in Barchart using ggplot2 in R
How to Split Column Into Multiple Columns in R DataFrame?
Loops in R (for, while, repeat)
Group by function in R using Dplyr
How to change Row Names of DataFrame in R ?
How to Change Axis Scales in R Plots?
How to filter R DataFrame by values in a column?
R - if statement
HTML <blockquote> Tag

17 Mar, 2022
The <blockquote> tag in HTML is used to display the long quotations (a section that is quoted from another source). It changes the alignment to make it unique from others. It contains both opening and closing tags. In blockquote tag, we can use elements like heading, list, paragraph, etc.
Note: The <blockquote> tag in HTML4.1 defines the long quotation i.e. quotations that span multiple lines. But in HTML5, the <blockquote> tag specify the section that is quoted from other source. 
Syntax: 
<blockquote> Contents... </blockquote>
Attribute: It contains a single attribute cite which is used to specify the source of the quotation. 
The below examples illustrate the blockquote tag: Example 1:
HTML
<!DOCTYPE html><html>  <body>    <h1>GeeksforGeeks</h1>    <h2><blockquote> Tag</h2>    <!--blockquote Tag starts here -->    <blockquote cite="https://www.geeksforgeeks.org/html-tutorials/">        <p>        HTML stands for HyperText Markup Language. It         is used to design web pages using a markup language.        HTML is the combination of Hypertext and Markup language.        Hypertext defines the link between the web pages. A        markup language is used to define the text document within         tag which defines the structure of web pages.      </p>      </blockquote>    <!--blockquote Tag ends here -->  </body></html>
Output: 
Example 2: 
HTML
<!DOCTYPE html><html>  <body>    <h1>GeeksforGeeks</h1>    <h2><blockquote> Tag</h2>      <p>This is blockquote Tag text with attribute cite</p>      <!--blockquote Tag starts here -->    <blockquote cite="www.geeksforgeeks.org">        GeeksforGeeks:A computer science portal for geeks    </blockquote>    <!--blockquote Tag ends here --></body>  </html>
Output: 
Supported Browsers: 
Google Chrome
Internet Explorer
Firefox
Safari
Opera
shubhamyadav4
HTML-Tags
HTML
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
REST API (Introduction)
Hide or show elements in HTML using display property
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
CSS to put icon inside an input element in a form
Types of CSS (Cascading Style Sheet)
HTTP headers | Content-Type
Python - Summation of float string list - GeeksforGeeks

11 Dec, 2019
Sometimes, while working with Python list, we can have a problem in which we need to find summation in list. But sometimes, we don’t have a natural number but a floating-point number in string format. This problem can occur while working with data, both in web development and Data Science domain. Let’s discuss the ways in which this problem can be solved.
Method #1 : Using sum() + float() + generatorThis problem can be solved using the sum function in which we first convert the strings into float and then pass this logic in functions in respective sum function.
# Python3 code to demonstrate working of# Summation of float string list# using sum() + float() + generator  # initialize liststest_list = ['4.5', '7.8', '9.8', '10.3']  # printing original listprint("The original list is : " + str(test_list))  # Summation of float string list# using sum() + float() + generatorres_sum = sum(float(sub) for sub in test_list)  # printing resultprint("The summation of float string list : " + str(res_sum))
The original list is : ['4.5', '7.8', '9.8', '10.3']
The summation of float string list : 32.400000000000006

 
Method #2 : Using loopThis is a brute force method to perform this task. In this, we iterate for the list and convert and sum the list float elements during iteration.
# Python3 code to demonstrate working of# Summation of float string list# Using loop  # initialize liststest_list = ['4.5', '7.8', '9.8', '10.3']  # printing original listprint("The original list is : " + str(test_list))  # Summation of float string list# Using loopres_sum = 0 for ele in test_list:     res_sum += float(ele)      # printing resultprint("The summation of float string list : " + str(res_sum))
The original list is : ['4.5', '7.8', '9.8', '10.3']
The summation of float string list : 32.400000000000006

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
os.walk() in Python - GeeksforGeeks

23 Nov, 2020
How to traverse file system in Python ? Suppose we have given below file structure in our system and we want to traverse all it’s branches completely from top to bottom ?
OS.walk() generate the file names in a directory tree by walking the tree either top-down or bottom-up. For each directory in the tree rooted at directory top (including top itself), it yields a 3-tuple (dirpath, dirnames, filenames).
root : Prints out directories only from what you specified.
dirs : Prints out sub-directories from root.
files : Prints out all files from root and directories.
# Driver functionimport osif __name__ == "__main__":    for (root,dirs,files) in os.walk('Test', topdown=true):        print (root)        print (dirs)        print (files)        print ('--------------------------------')
Output:


This article is contributed by Shashank Mishra (Gullu). If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Python-Library
python-modules
python-os-module
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
*args and **kwargs in Python
Create a Pandas DataFrame from Lists
Convert integer to string in Python
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Graph Plotting in Python | Set 1
Python | Get unique values from a list
How to make horizontal line with words in the middle using CSS? - GeeksforGeeks

22 Apr, 2019
CSS provides the feature of making a horizontal line including words or image in the middle of the webpage to make it attractive. This can be achieved by using simple CSS properties.
Syntax:
h4:before, h4:after {
     content: "";
     flex: 1 1;
     border-bottom: 2px solid #000;
     margin: auto;
}

Example-1: To make a horizontal line with words in middle
<html>  <head>    <style>        h4 {            display: flex;            flex-direction: row;        }                  h4:before,        h4:after {            content: "";            flex: 1 1;            border-bottom: 2px solid #000;            margin: auto;        }                  img {            height: 100px;            width: 100px;            border-radius: 50%;        }    </style></head>  <body>    <h4>GeeksforGeeks</h4></body>  </html>
Output :
Example-2: To make a horizontal line with the image in middle
<html>  <head>    <style>        h1 {            display: flex;            flex-direction: row;        }                  h1:before,        h1:after {            content: "";            flex: 1 1;            border-bottom: 2px solid #000;            margin: auto;        }                  img {            height: 100px;            width: 100px;            border-radius: 50%;        }    </style></head>  <body>    <h1><img src="https://www.geeksforgeeks.org/wp-content/uploads/gfg_200X200.png">  </h1></body>  </html>
Output:
CSS-Misc
CSS-Selectors
Picked
CSS
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to apply style to parent if it has child with CSS?
How to set space between the flexbox ?
Design a web page using HTML and CSS
Create a Responsive Navbar using ReactJS
Making a div vertically scrollable using CSS
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
HTML | Marquee stop Method - GeeksforGeeks

20 Jan, 2022
The Marquee stop method in HTML is used to stop the scrolling. To start the scrolling use start() method.
Syntax:
Object.stop()
Return value: This method has no return value.
Example:
<!DOCTYPE html><html>  <head>    <title>Marquee stop Method</title>    <style>        .main {            text-align: center;        }    </style></head>  <body>    <h1 style="color:green; text-align:center;">      GeeksforGeeks  </h1>    <div class="main">        <marquee id="marID"                  bgcolor="Green"                 direction="left"                 loop="">            Scrolling        </marquee>        <br />        <input type="button"               onclick="marID.start()"                value="start">                <input type="button"                onclick="marID.stop()"               value="Stop">    </div></body>  </html>
Output:
Supported Browsers: The browsers supported by HTML Marquee stop Method are listed below:
Google Chrome
Internet Explorer
Firefox
Apple Safari
Opera
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
ManasChhabra2
HTML-Methods
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
HTML Cheat Sheet - A Basic Guide to HTML
Design a web page using HTML and CSS
Form validation using jQuery
Angular File Upload
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Python | Check if a variable is string - GeeksforGeeks

22 May, 2019
While working with different datatypes, we might come across a time, where we need to test the datatype for its nature. This article gives ways to test a variable against the data type it is. Let’s discuss certain ways in which this task can be done.
Method #1 : Using isinstance(x, str)
This method can be used to test whether any variable is a particular datatype. By giving the second argument as “str”, we can check if the variable we pass is a string or not.
# Python3 code to demonstrate# Check if variable is string # using isinstance()  # initializing string test_string = "GFG"  # printing original string print("The original string : " + str(test_string))  # using isinstance()# Check if variable is string res = isinstance(test_string, str)  # print resultprint("Is variable a string ? : " + str(res))
The original string : GFG
Is variable a string ? : True

 
Method #2 : Using type()
This task can also be achieved using the type function in which we just need to pass the variable and equate with a particular type.
# Python3 code to demonstrate# Check if variable is string # using type()  # initializing string test_string = "GFG"  # printing original string print("The original string : " + str(test_string))  # using type()# Check if variable is string res = type(test_string) == str  # print resultprint("Is variable a string ? : " + str(res))
The original string : GFG
Is variable a string ? : True

Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python String | replace()
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary