code-rag-bench/online-tutorials huggingface dataset:
Why does PHP 5.2+ disallow abstract static class methods ? - GeeksforGeeks

31 May, 2020
Before we answer this question, you must have a clear definition of what exactly is an abstract class, an abstract method and a static method.
Abstract Class: In the Object-Oriented programming paradigm, abstraction refers to the process of hiding the internal implementation details of any program and only showing the functionality of the program to the user. Abstract classes are a way of achieving this. An abstract class is any class that cannot be instantiated (i.e. objects cannot be created) and has to be extended (inherited) for objects to be created. The ‘abstract’ keyword is used to create abstract classes.
Abstract Method: An abstract method is a method that can only be declared and not defined. It is defined in the class that inherits from this class.
Static Method: A static method of any class is a method that is created only once. This means that even if you create hundreds of objects of a class with static methods, there will be the only copy of each static method.
Consider the following example:
abstract class Abstract_Parent {          static function X() {        self::Y();    }          abstract static function Y();}  class Child extends Abstract_Parent {          static function Y() {        echo "GeeksforGeeks";    }}  Child::X();
Now if you run this PHP code, you will see the error, “PHP Fatal error: Cannot call abstract method Abstract_Parent::X().”
When we call method X() in the child class, the static function X() in the parent gets called. In the method X(), we are again calling function Y(), which is an abstract static function. The Y() that function X() is trying to call is the parent class Y(), which is itself an abstract function.
So, using abstract and static on the same method defeats each other purpose. This is the reason why PHP 5.2+ does not allow abstract static class methods.
PHP-Misc
Picked
PHP
PHP Programs
Web Technologies
Web technologies Questions
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to fetch data from localserver database and display on HTML table using PHP ?
How to pass form variables from one page to other page in PHP ?
Create a drop-down list that options fetched from a MySQL database in PHP
How to create admin login page using PHP?
Different ways for passing data to view in Laravel
How to call PHP function on the click of a Button ?
How to fetch data from localserver database and display on HTML table using PHP ?
How to pass form variables from one page to other page in PHP ?
How to create admin login page using PHP?
How to Install php-curl in Ubuntu ?
How to position and align a Matplotlib figure legend?

To position and align a matplotlib figure legend, we can take the following steps−
Plot line1 and line2 using plot() method.
Place a legend on the figure. Use bbox_to_anchor to set the position and make horizontal alignment of the legend elements.
To display the figure, use show() method.
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
line1, = plt.plot([1, 5, 1, 7], linewidth=0.7)
line2, = plt.plot([5, 1, 7, 1], linewidth=2.0)
plt.legend([line1, line2], ["line1", "line2"], bbox_to_anchor=(0.45, 1.0), ncol=2)
plt.show()
C++ Vector Library - assign() Function

The C++ function std::vector::assign() assign new values to the vector elements by replacing old ones. It modifies size of vector if necessary.
If memory allocation happens allocation is allocated by internal allocator.
Following is the declaration for std::vector::assign() function form std::vector header.
template <class InputIterator>
void assign(InputIterator first, InputIterator last);

template <class InputIterator>
wvoid assign (InputIterator first, InputIterator last);

first − Input iterator to the initial position in range.
first − Input iterator to the initial position in range.
last − Input iterator to the final position in range.
last − Input iterator to the final position in range.
None
This member function never throws exception. If value of (first, last) is not valid index then behavior is undefined.
Linear i.e. O(n)
The following example shows the usage of std::vector::assign() function.
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
   vector<int> v(5, 100);

   cout << "Initial vector contents" << endl;
   for (int i = 0; i < v.size(); ++i)
      cout << v[i] << endl;

   cout << endl;
  
   cout << "Modified vector contents" << endl;
  
   v.assign(v.begin(), v.begin() + 2);
   for (int i = 0; i < v.size(); ++i)
      cout << v[i] << endl;
  
   return 0;
}
Let us compile and run the above program, this will produce the following result −
Initial vector contents
100
100
100
100
100
Modified vector contents
100
100

 Print
 Add Notes
 Bookmark this page
Postfix to Infix in C++

In this problem, we are given expression in postfix form and our task is to print the infix form of the expression.
Infix expression is an expression in which the operator is in the middle of operands, like operand operator operand.
Postfix expression is an expression in which the operator is after operands, like operand operator.
Postfix expressions are easily computed by the system but are not human readable. So this conversion is required. Generally reading and editing by the end-user is done on infix notations as they are parenthesis separated hence easily understandable for humans.
Let’s take an example to understand the problem
Input − xyz/*
Output − (x * (y/z))
To solve this problem, we will use the stack data structure. And traverse the postfix expression one by one and then check for the following case −
Case 1 − if the operand is found, push it in the stack.
Case 2 − if an operator is found, pop to operands, create an infix expression of the three and push the expression as an operand.
In the end when the stack has only one element left and the traversing is done, pop the top of stack, it is the infix conversion.
Program to show the implementation of our solution.
 Live Demo
#include <bits/stdc++.h>
using namespace std;
bool isOperand(char x) {
   return (x >= 'a' && x <= 'z') || (x >= 'A' && x <= 'Z');
}
string infixConversion(string postfix) {
   stack<string> infix;
   for (int i=0; postfix[i]!='\0'; i++) {
      if (isOperand(postfix[i])) {
         string op(1, postfix[i]);
         infix.push(op);
      } else {
         string op1 = infix.top();
         infix.pop();
         string op2 = infix.top();
         infix.pop();
         infix.push("{"+op2+postfix[i]+op1 +"}");
      }
   }
   return infix.top();
}
int main() {
   string postfix = "xyae+/%";
   cout<<"The infix conversion of the postfix expression '"<<postfix<<"' is : ";
   cout<<infixConversion(postfix);
   return 0;
}
The infix conversion of the postfix expression 'xyae+/%' is : {x%{y/{a+e}}}
Branch prediction macros in GCC - GeeksforGeeks

28 May, 2017
One of the most used optimization techniques in the Linux kernel is ” __builtin_expect”. When working with conditional code (if-else statements), we often know which branch is true and which is not. If compiler knows this information in advance, it can generate most optimized code.
Let us see macro definition of “likely()” and “unlikely()” macros from linux kernel code “http://lxr.linux.no/linux+v3.6.5/include/linux/compiler.h” [line no 146 and 147].
#define likely(x)      __builtin_expect(!!(x), 1)#define unlikely(x)    __builtin_expect(!!(x), 0)
In the following example, we are marking branch as likely true:
const char *home_dir ;  home_dir = getenv("HOME");if (likely(home_dir))     printf("home directory: %s\n", home_dir);else    perror("getenv");
For above example, we have marked “if” condition as “likely()” true, so compiler will put true code immediately after branch, and false code within the branch instruction. In this way compiler can achieve optimization. But don’t use “likely()” and “unlikely()” macros blindly. If prediction is correct, it means there is zero cycle of jump instruction, but if prediction is wrong, then it will take several cycles, because processor needs to flush it’s pipeline which is worst than no prediction.
Accessing memory is the slowest CPU operation as compared to other CPU operations. To avoid this limitation, CPU uses “CPU caches” e.g L1-cache, L2-cache etc. The idea behind cache is, copy some part of memory into CPU itself. We can access cache memory much faster than any other memory. But the problem is, limited size of “cache memory”, we can’t copy entire memory into cache. So, the CPU has to guess which memory is going to be used in the near future and load that memory into the CPU cache and above macros are hint to load memory into the CPU cache.
This article is compiled by Narendra Kangralkar. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
AdvanceC
C-Macro & Preprocessor
c-puzzle
GCC
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Function Pointer in C
Substring in C++
fork() in C
std::string class in C++
Enumeration (or enum) in C
Command line arguments in C/C++
TCP Server-Client implementation in C
Different methods to reverse a string in C/C++
Structures in C
Exception Handling in C++
GATE | GATE-CS-2015 (Set 2) | Question 21 - GeeksforGeeks

01 Nov, 2021
Consider the following C function.
int fun (int n){  int x=1, k;  if (n==1) return x;  for (k=1; k < n; ++k)     x = x + fun(k) * fun(n – k);  return x;}
The return value of fun(5) is __________.
(A) 0(B) 26(C) 51(D) 71Answer: (C)Explanation:
fun(5) = 1 + fun(1) * fun(4) + fun(2) * fun(3) + 
             fun(3) * fun(2) + fun(4) * fun(1)
       = 1 + 2*[fun(1)*fun(4) + fun(2)*fun(3)]

Substituting fun(1) = 1
       = 1 + 2*[fun(4) + fun(2)*fun(3)]

Calculating fun(2), fun(3) and fun(4)
fun(2) = 1 + fun(1)*fun(1) = 1 + 1*1 = 2
fun(3) = 1 + 2*fun(1)*fun(2) = 1 + 2*1*2 = 5
fun(4) = 1 + 2*fun(1)*fun(3) + fun(2)*fun(2)
       = 1 + 2*1*5 + 2*2 = 15

Substituting values of fun(2), fun(3) and fun(4)
fun(5) = 1 + 2*[15 + 2*5] = 51 
Quiz of this Question
GATE-CS-2015 (Set 2)
GATE-GATE-CS-2015 (Set 2)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE MOCK 2017 | Question 24
GATE | GATE-CS-2006 | Question 47
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
PHP | urldecode() Function - GeeksforGeeks

23 May, 2019
The urldecode() function is an inbuilt function in PHP which is used to decode url which is encoded by encoded() function.Syntax:
string urldecode( $input )
Parameters: This function accepts single parameter $input which holds the url to be decoded.
Return Value: This function returns the decoded string on success.
Below programs illustrate the urldecode() function in PHP:Program 1:
<?php  // PHP program to illustrate urldecode function  // all sub domain  of geeksforgeeksecho urldecode("https%3A%2F%2Fide.geeksforgeeks.org%2F"). "\n";echo urldecode("https%3A%2F%2Fpractice.geeksforgeeks.org%2F"). "\n";echo urldecode("https%3A%2F%2Fgeeksforgeeks.org%2F"). "\n";?>
https://ide.geeksforgeeks.org/
https://practice.geeksforgeeks.org/
https://geeksforgeeks.org/

Program 2 :
<?php  // all sub domain  of geeksforgeeks$url1 = "https%3A%2F%2Fide.geeksforgeeks.org%2F";$url2 = "https%3A%2F%2Fpractice.geeksforgeeks.org%2F";$url3 = "https%3A%2F%2Fgeeksforgeeks.org%2F";  // create an array $query = array($url1, $url2, $url3);  // print decoded urlforeach ($query as $chunk) {        printf(urldecode($chunk). "\n");    }?>
https://ide.geeksforgeeks.org/
https://practice.geeksforgeeks.org/
https://geeksforgeeks.org/

Reference: http://php.net/manual/en/function.urldecode.php
nidhi_biet
PHP-function
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
How to Upload Image into Database and Display it using PHP ?
How to check whether an array is empty using PHP?
PHP | Converting string to Date and DateTime
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 ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
HTML | DOM Input Date disabled Property - GeeksforGeeks

09 Dec, 2021
The Input date disabled property is used to set or return whether a date field should be disabled, or not. An element becomes unusable and un-clickable if it is disabled. Such elements are generally rendered in gray by browsers. The HTML disable attribute is reflected by the Date disabled property.Syntax:  
To return the disabled property:  
inputdateObject.disabled
To set the disabled property:  
inputdateObject.disabled = true|false
Property Value  
true|false: It is used to specify whether a date field should be disabled or not. It is false by default.
Return Values: It returns a Boolean value which represents that the Input date field would be disabled or not. 
Below program illustrates the Date disabled property : Example: Disabling a Date field.  
html
<!DOCTYPE html><html>  <head>    <title>Input Date disabled Property in HTML  </title>    <style>        h1 {            color: green;        }                  h2 {            font-family: Impact;        }                  body {            text-align: center;        }    </style></head>  <body>      <h1>GeeksforGeeks</h1>    <h2> Input Date disabled Property  </h2>    <br>      <input type="date"           id="test_Date">        <p>To disable the date field,      double click the "Disable" button.  </p>        <button ondblclick="My_Date()">Disable  </button>      <script>        function My_Date() {                        // Set disabled = true.            document.getElementById(              "test_Date").disabled = true;        }    </script>  </body>  </html>
Output:Initially:  
Before clicking the disable button:  
After clicking the disable button:  
Supported Browsers:  
Apple Safari
Internet Explorer
Firefox
Google Chrome
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
chhabradhanvi
HTML-DOM
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
Passing arguments to a Tkinter button command

The Button widget in Tkinter is generally used for pushing an event defined in an application. We can bind the events with buttons that allow them to execute and run whenever an action is triggered by the user.
However, sharing the data and variables outside the function and events seems difficult sometimes. With the Button widget, we can pass arguments and data that allows the user to share and execute the event.
In general, passing the arguments to a button widget allows the event to pick the arguments and use them further in the program.
# Import the required library
from tkinter import *
from tkinter import ttk
from tkinter import messagebox

# Create an instance of tkinter frame
win=Tk()

# Set the geometry
win.geometry("700x250")

# Define a function to update the entry widget
def update_name(name):
   entry.insert(END, ""+str(name))

# Create an entry widget
entry=Entry(win, width=35, font=('Calibri 15'))
entry.pack()

b=ttk.Button(win, text="Insert", command=lambda:update_name("Tutorialspoint"))
b.pack(pady=30)

win.mainloop()
Running the above code will display a window with an Entry widget and a button to insert text in it.
Click the button "Insert" to add text in the Entry widget.
Rakuten Archives - GeeksforGeeks

Rakuten Interview Experience for Associate Software Engineer (Off-Campus)
Rakuten India Interview Experience | On-Campus 2021
Rakuten Interview Experience | SDE Intern (Pool Campus)
Rakuten Internship Interview Expereince
Rakuten India Interview Experience for Technical Intern
How to Add External JAR File to an IntelliJ IDEA Project?
apply(), lapply(), sapply(), and tapply() in R
How to connect MongoDB with ReactJS ?
Token, Patterns, and Lexems
SDE SHEET - A Complete Guide for SDE Preparation
DataFrame.to_excel() method in Pandas

16 Jul, 2020
The to_excel() method is used to export the DataFrame to the excel file.  To write a single object to the excel file, we have to specify the target file name. If we want to write to multiple sheets, we need to create an ExcelWriter object with target filename and also need to specify the sheet in the file in which we have to write. The multiple sheets can also be written by specifying the unique sheet_name. It is necessary to save the changes for all the data written to the file.
Syntax:
data.to_excel( excel_writer, sheet_name='Sheet1', \*\*kwargs )

Parameters:
One can provide the excel file name or the Excelwrite object.
By default the sheet number is 1, one can change it by input the value of argument “sheet_name”.
One can provide the name of the columns to store the data by input the value of the argument “columns”.
By default the index is labeled with numbers as 0,1,2 ... and so on, one can change it by passing a sequence of the list for the value of the argument “index”.
Below is the implementation of the above method :
Python3
# importing packages import pandas as pd   # dictionary of data dct = {'ID': {0: 23, 1: 43, 2: 12,               3: 13, 4: 67, 5: 89,               6: 90, 7: 56, 8: 34},       'Name': {0: 'Ram', 1: 'Deep',                2: 'Yash', 3: 'Aman',                4: 'Arjun', 5: 'Aditya',                6: 'Divya', 7: 'Chalsea',                8: 'Akash' },       'Marks': {0: 89, 1: 97, 2: 45, 3: 78,                 4: 56, 5: 76, 6: 100, 7: 87,                 8: 81},       'Grade': {0: 'B', 1: 'A', 2: 'F', 3: 'C',                 4: 'E', 5: 'C', 6: 'A', 7: 'B',                 8: 'B'}     }   # forming dataframedata = pd.DataFrame(dct)   # storing into the excel filedata.to_excel("output.xlsx")
Output :
In the above example,
By default index is labeled as 0,1,.... and so on.
As our DataFrame has columns names so columns are labeled.
By default, it is saved in “Sheet1”.
Python pandas-dataFrame
Python pandas-dataFrame-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Different ways to create Pandas Dataframe
Enumerate() in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Convert integer to string in Python
How to drop one or multiple columns in Pandas Dataframe
Time Series - Exponential Smoothing

In this chapter, we will talk about the techniques involved in exponential smoothing of time series.
Exponential Smoothing is a technique for smoothing univariate time-series by assigning exponentially decreasing weights to data over a time period.
Mathematically, the value of variable at time ‘t+1’ given value at time t, y_(t+1|t) is defined as −
yt+1|t=αyt+α⟮1−α⟯yt−1+α⟮1−α⟯2yt−2+...+y1
where,0≤α≤1 is the smoothing parameter, and
y1,....,yt are previous values of network traffic at times 1, 2, 3, ... ,t.
This is a simple method to model a time series with no clear trend or seasonality. But exponential smoothing can also be used for time series with trend and seasonality.
Triple Exponential Smoothing (TES) or Holt's Winter method, applies exponential smoothing three times - level smoothing lt, trend smoothing bt, and seasonal smoothing St, with α, β∗ and γ as smoothing parameters with ‘m’ as the frequency of the seasonality, i.e. the number of seasons in a year.
According to the nature of the seasonal component, TES has two categories −
Holt-Winter's Additive Method − When the seasonality is additive in nature.
Holt-Winter's Additive Method − When the seasonality is additive in nature.
Holt-Winter’s Multiplicative Method − When the seasonality is multiplicative in nature.
Holt-Winter’s Multiplicative Method − When the seasonality is multiplicative in nature.
For non-seasonal time series, we only have trend smoothing and level smoothing, which is called Holt’s Linear Trend Method.
Let’s try applying triple exponential smoothing on our data.
In [316]:
from statsmodels.tsa.holtwinters import ExponentialSmoothing

model = ExponentialSmoothing(train.values, trend= )
model_fit = model.fit()

In [322]:
predictions_ = model_fit.predict(len(test))

In [325]:
plt.plot(test.values)
plt.plot(predictions_[1:1871])

Out[325]:
[<matplotlib.lines.Line2D at 0x1eab00f1cf8>]

Here, we have trained the model once with training set and then we keep on making predictions. A more realistic approach is to re-train the model after one or more time step(s). As we get the prediction for time ‘t+1’ from training data ‘til time ‘t’, the next prediction for time ‘t+2’ can be made using the training data ‘til time ‘t+1’ as the actual value at ‘t+1’ will be known then. This methodology of making predictions for one or more future steps and then re-training the model is called rolling forecast or walk forward validation.

    16 Lectures 
     2 hours 

 Malhar Lathkar

    21 Lectures 
     2.5 hours 

 Sasha Miller

    19 Lectures 
     1 hours 

 Sasha Miller

    94 Lectures 
     13 hours 

 Abhishek And Pukhraj

    12 Lectures 
     2 hours 

 Prof. Paul Cline, Ed.D

    11 Lectures 
     1 hours 

 Prof. Paul Cline, Ed.D
 Print
 Add Notes
 Bookmark this page
Sum of the series 1, 3, 6, 10... (Triangular Numbers) in C++

In this problem, we are given a number n which is given the n of elements of the series 1, 3, 6, 10 ... (triangular number). Our task is to create a program to calculate the sum of the series.
Let’s brush up about triangular numbers before calculating the sum.
Triangular numbers are those numbers that can be represented in the form of a triangle.
A triangle is formed in such a way that the first row has one point, second has two, and so on.
Input
n = 4
Output
Explanation − sum = T1 + T2 + T3 + T4 = 1 + 3 + 6 + 10 = 20
A simple approach to solve this problem is to find all n triangle numbers. And adding them to the sum variable one by one.
Initialise sum = 0.
Step 1: loop for i = 0 to n. And follow steps 2 and 3
Step 2: for each value of i, calculate the triangular numbers using the formula, t[i] = ∑ i = i*(i+1)/2.
Step 3: Update sum value, sum += t[i].
Step 4: return sum.
Program to illustrate the working of our solution,
 Live Demo
#include <iostream>
using namespace std;
int calcSeriesSum(int n) {
   int sum = 0;
   for (int i=1; i<=n; i++)
   sum += i*(i+1)/2;
   return sum;
}
int main() {
   int n = 6;
   cout<<"Sum of the series 1, 3, 6, 10 ... (Triangular Numbers) is "<<calcSeriesSum(n);
   return 0;
}
Sum of the series 1, 3, 6, 10 ... (Triangular Numbers) is 56
This is not the most effective solution as it takes O(n), time complexity.
A more effective solution is by using the direct formula for the sum.
If Ti is the i-th triangular number. Then,
T1 = 1
T2 = 3
T3 = 6
Tn = n*(n+1) /2
Sum of all triangular numbers is
sum = 1 + 3 + 6 + 10 + ...
sum = T1 + T2 + T3 + ... + Tn
sum = ∑ (Ti) , i -> 0 to n
sum = ∑ (n)(n+1)/2
sum = 1⁄2 ∑ n2 + n
sum = 1⁄2 ∑n^2 + ∑ n
sum = 1⁄2 [ (n*(n+1)*(2n+1)/6) + (n*(n+1)/2) ]
sum = 1⁄2 (n*(n+1)/2)*[ (2n+1)/3 + 1 ]
sum = 1⁄4 [n*(n+1)]*[(2n+1+3)/3]
sum = 1⁄4 [n*(n+1)]*[(2n+4)/3]
sum = 1⁄4 [n*(n+1)]*[2(n+2)/3]
sum= 1⁄6 [n*(n+1)*(n+2)]
This is the general formula for the sum of triangle numbers.
Program to illustrate the working of our solution,
Live Demo
#include <iostream>
using namespace std;
int calcSeriesSum(int n) {
   return ( ( n*(n + 1)*(n + 2) )/6);
}
int main() {
   int n = 6;
   cout<<"Sum of the series 1, 3, 6, 10 ... (Triangular Numbers) is "<<calcSeriesSum(n);
   return 0;
}
Sum of the series 1, 3, 6, 10 ... (Triangular Numbers) is 56
How to hide Firefox window (Selenium WebDriver)?

We can hide the Firefox window in Selenium webdriver. This can be done by making the browser headless. We shall achieve this with the FirefoxOptions class. We shall then create an object option of that class.
We have to make the browser setting options.headless to True value. This driver object shall then receive this information. We need to have the import statement: from selenium.webdriver.firefox.options import Options as FirefoxOptions for adding the FirefoxOptions class.
options = webdriver.FirefoxOptions()
options.headless = True
Code Implementation.
from selenium import webdriver
from selenium.webdriver.firefox.options import Options as FirefoxOptions
#object of FirefoxOptions
options = webdriver.FirefoxOptions()
#setting headless parameter
options.headless = True
driver = webdriver.Firefox(executable_path="C:\\geckodriver.exe", options=options)
driver.implicitly_wait(0.8)
driver.get("https://www.tutorialspoint.com/tutorialslibrary.htm")
#identify element
n = driver.find_element_by_xpath("//*[text()='Library']")
#perform click
n.click();
print("Page title after click: " + driver.title)
driver.quit()
Insertion Sort List C++

Suppose we have a linked list, we have to perform the insertion sort on this list. So if the list is like [9,45,23,71,80,55], sorted list is [9,23,45,55,71,80].
To solve this, we will follow these steps −
dummy := new Node with some random value
dummy := new Node with some random value
node := given list
node := given list
while node is not null,newNode = next of node, dummyHead := next of dummy, prevDummyHead := dummywhile true −if dummyHead is not present, value of dummyHead > value of nodenext of node := dummyHeadnext of prevDummyHead := nodebreak the loopprevDummyHead := dymmyHead, and dummyHead = next of dummy headnode := nextNode
while node is not null,
newNode = next of node, dummyHead := next of dummy, prevDummyHead := dummy
newNode = next of node, dummyHead := next of dummy, prevDummyHead := dummy
while true −if dummyHead is not present, value of dummyHead > value of nodenext of node := dummyHeadnext of prevDummyHead := nodebreak the loopprevDummyHead := dymmyHead, and dummyHead = next of dummy head
while true −
if dummyHead is not present, value of dummyHead > value of nodenext of node := dummyHeadnext of prevDummyHead := nodebreak the loop
if dummyHead is not present, value of dummyHead > value of node
next of node := dummyHead
next of node := dummyHead
next of prevDummyHead := node
next of prevDummyHead := node
break the loop
break the loop
prevDummyHead := dymmyHead, and dummyHead = next of dummy head
prevDummyHead := dymmyHead, and dummyHead = next of dummy head
node := nextNode
node := nextNode
return next of dummy
Let us see the following implementation to get better understanding −
class Solution {
   public:
   ListNode* insertionSortList(ListNode* a) {
      ListNode* dummy = new ListNode(-1);
      ListNode* node = a;
      ListNode* nextNode;
      ListNode* dummyHead;
      ListNode* prevDummyHead;
      while(node != NULL){
         nextNode = node->next;
         dummyHead = dummy->next;
         prevDummyHead = dummy;
         while(1){
            if(!dummyHead || dummyHead->val > node->val){
               node->next = dummyHead;
               prevDummyHead->next = node;
               //cout << prevDummyHead->val << " " << node->val << endl;
               break;
            }
         }
         prevDummyHead = dummyHead;
         dummyHead = dummyHead->next;
      }
      node = nextNode;
   }
   return dummy->next;
}
[9,45,23,71,80,55]
[9,23,45,55,71,80]
What is the purpose of a default constructor in Java?

A constructor initializes an object when it is created. It has the same name as its class and is syntactically similar to a method. However, constructors have no explicit return type. There are two types of constructors namely −
parameterized constructors − Constructors with arguments.
no-arg constructors − Constructors without arguments.
 Live Demo
public class Sample{
   int num;
   Sample(){
      num = 100;
   }
   Sample(int num){
      this.num = num;
   }
   public static void main(String args[]){
      System.out.println(new Sample().num);
      System.out.println(new Sample(1000).num);
   }
}
100
1000
It is recommended to provide any of the above-mentioned contractors while defining a class. If not Java compiler provides a no-argument, default constructor on your behalf.
This is a constructor initializes the variables of the class with their respective default values (i.e. null for objects, 0.0 for float and double, false for boolean, 0 for byte, short, int and, long).
If you observe the following example, we are not providing any constructor to it.
public class Sample{
   int num;
   public static void main(String args[]){
      System.out.println(new Sample().num);
   }
}
If you compile and run the above program the default constructor initializes the integer variable num with 0 and, you will get 0 as result.
The javap command displays information about the fields, constructors, and methods of a class. If you (after compiling it) run the above class using javap command, you can observe the default constructor added by the compiler as shown below:
D:\>javap Sample
Compiled from "Sample.java"
public class Sample {
   int num;
   public Sample();
   public static void main(java.lang.String[]);
}
GATE | GATE-CS-2017 (Set 1) | Question 19 - GeeksforGeeks

28 Jun, 2021
Consider a database that has the relation schema EMP (EmpId, EmpName, and DeptName). An instance of the schema EMP and a SQL query on it are given below.
The output of executing the SQL query is _______.
Note: This questions appeared as Numerical Answer Type.(A) 1.2(B) 2.3(C) 2.6(D) 3.1Answer: (C)Explanation: Output of Query will be:

DeptName     Number

AA             4

AB             3

AC             3

AD             2

AE             1

4 + 3 + 3 + 2 + 1 = 13 / 5 = 2.6


Therefore, option C is correctQuiz of this Question
GATE-CS-2017 (Set 1)
GATE-GATE-CS-2017 (Set 1)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-CS-2014-(Set-3) | Question 38
GATE | GATE-IT-2004 | Question 83
GATE | GATE CS 2018 | Question 37
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE-CS-2016 (Set 1) | Question 65
GATE | GATE-CS-2016 (Set 1) | Question 63
GATE | GATE-CS-2007 | Question 17
GATE | GATE-IT-2004 | Question 12
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE-CS-2007 | Question 64
Why an interface doesn't have a constructor whereas an abstract class have a constructor in Java?

A Constructor is to initialize the non-static members of a particular class with respect to an object.
An Interface in Java doesn't have a constructor because all data members in interfaces are public static final by default, they are constants (assign the values at the time of declaration).
There are no data members in an interface to initialize them through the constructor.
In order to call a method, we need an object, since the methods in the interface don’t have a body there is no need for calling the methods in an interface.
Since we cannot call the methods in the interface, there is no need of creating an object for an interface and there is no need of having a constructor in it.
interface Addition {
   int add(int i, int j);
}
public class Test implements Addition {
   public int add(int i, int j) {
      int k = i+j;
      return k;
   }
   public static void main(String args[]) {
      Test t = new Test();
      System.out.println("k value is:" + t.add(10,20));
   }
}
k value is:30
The purpose of the constructor in a class is used to initialize fields but not to build objects.
When we try to create a new instance of an abstract superclass, the compiler will give an error.
However, we can inherit an abstract class and make use of its constructor by setting its variables.
abstract class Employee {
   public String empName;
   abstract double calcSalary();
   Employee(String name) {
      this.empName = name; // Constructor of abstract class  
   }
}
class Manager extends Employee {
   Manager(String name) {
      super(name); // setting the name in the constructor of subclass
   }
   double calcSalary() {
      return 50000;
   }
}
public class Test {
   public static void main(String args[]) {
      Employee e = new Manager("Adithya");
      System.out.println("Manager Name is:" + e.empName);
      System.out.println("Salary is:" + e.calcSalary());
   }
}
Manager Name is:Adithya
Salary is:50000.0
Kali Linux - Forensics Tools

In this chapter, we will learn about the forensics tools available in Kali Linux.
p0f is a tool that can identify the operating system of a target host simply by examining captured packets even when the device in question is behind a packet firewall. P0f does not generate any additional network traffic, direct or indirect; no name lookups; no mysterious probes; no ARIN queries; nothing. In the hands of advanced users, P0f can detect firewall presence, NAT use, and existence of load balancers.
Type “p0f – h” in the terminal to see how to use it and you will get the following results.
It will list even the available interfaces.
Then, type the following command: “p0f –i eth0 –p -o filename”.
Where the parameter "-i" is the interface name as shown above. "-p" means it is in promiscuous mode. "-o" means the output will be saved in a file.
Open a webpage with the address 192.168.1.2
From the results, you can observe that the Webserver is using apache 2.x and the OS is Debian.
pdf-parser is a tool that parses a PDF document to identify the fundamental elements used in the analyzed pdf file. It will not render a PDF document. It is not recommended for text book case for PDF parsers, however it gets the job done. Generally, this is used for pdf files that you suspect has a script embedded in it.
The command is −
pdf-parser  -o 10 filepath

where "-o" is the number of objects.
As you can see in the following screenshot, the pdf file opens a CMD command.
Dumpzilla application is developed in Python 3.x and has as a purpose to extract all forensic interesting information of Firefox, Iceweasel, and Seamonkey browsers to be analyzed.
It copies data from one file or block device (hard disc, cdrom, etc.) to another, trying to rescue the good parts first in case of read errors.
The basic operation of ddrescue is fully automatic. That is, you don't have to wait for an error, stop the program, restart it from a new position, etc.
If you use the mapfile feature of ddrescue, the data is rescued very efficiently (only the needed blocks are read). Also, you can interrupt the rescue at any time and resume it later at the same point. The mapfile is an essential part of ddrescue's effectiveness. Use it unless you know what you are doing.
The command line is −
dd_rescue infilepath  outfilepath

Parameter "–v" means verbose. "/dev/sdb" is the folder to be rescued. The img file is the recovered image.
It is another forensic tool used to recover the files. It has a GUI too. To open it, type “dff-gui” in the terminal and the following web GUI will open.
Click File → “Open Evidence”.
The following table will open. Check “Raw format” and click “+” to select the folder that you want to recover.
Then, you can browse the files on the left of the pane to see what has been recovered.

    84 Lectures 
     6.5 hours 

 Mohamad Mahjoub

    8 Lectures 
     1 hours 

 Corey Charles

    21 Lectures 
     4 hours 

 Atul Tiwari

    55 Lectures 
     3 hours 

 Musab Zayadneh

    29 Lectures 
     2 hours 

 Musab Zayadneh

    32 Lectures 
     4 hours 

 Adnaan Arbaaz Ahmed
 Print
 Add Notes
 Bookmark this page
PyQt - QGridLayout Class

A GridLayout class object presents with a grid of cells arranged in rows and columns. The class contains addWidget() method. Any widget can be added by specifying the number of rows and columns of the cell. Optionally, a spanning factor for row as well as column, if specified makes the widget wider or taller than one cell. Two overloads of addWidget() method are as follows −
addWidget(QWidget, int r, int c)
Adds a widget at specified row and column
addWidget(QWidget, int r, int c, int rowspan, int columnspan)
Adds a widget at specified row and column and having specified width and/or height
A child layout object can also be added at any cell in the grid.
addLayout(QLayout, int r, int c)
Adds a layout object at specified row and column
The following code creates a grid layout of 16 push buttons arranged in a grid layout of 4 rows and 4 columns.
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *

def window():
   app = QApplication(sys.argv)
   win = QWidget()
   grid = QGridLayout()
	
   for i in range(1,5):
      for j in range(1,5):
         grid.addWidget(QPushButton("B"+str(i)+str(j)),i,j)
			
   win.setLayout(grid)
   win.setGeometry(100,100,200,100)
   win.setWindowTitle("PyQt")
   win.show()
   sys.exit(app.exec_())

if __name__ == '__main__':
   window()
The code uses two nested for loops for row and column numbers, denoted by variables i and j. They are converted to string to concatenate the caption of each push button to be added at ith row and jth column.
The above code produces the following output −

    146 Lectures 
     22.5 hours 

 ALAA EID
 Print
 Add Notes
 Bookmark this page
Add elements to a Vector in Java

A dynamic array is implemented by a Vector. This means an array that can grow or reduce in size as required.
Elements can be added at the end of the Vector using the java.util.Vector.add() method. This method has a single parameter i.e. the element to be added. It returns true if the element is added to the Vector as required and false otherwise.
A program that demonstrates this is given as follows −
 Live Demo
import java.util.Vector;
public class Demo {
   public static void main(String args[]) {
      Vector vec = new Vector(5);
      vec.add(4);
      vec.add(1);
      vec.add(7);
      vec.add(3);
      vec.add(5);
      vec.add(9);
      vec.add(2);
      vec.add(8);
      vec.add(6);
      System.out.println("The Vector elements are: " + vec);
   }
}
The output of the above program is as follows −
The Vector elements are: [4, 1, 7, 3, 5, 9, 2, 8, 6]
Now let us understand the above program.
The Vector is created. Then Vector.add() is used to add the elements to the Vector. Finally, the Vector elements are displayed. A code snippet which demonstrates this is as follows −
Vector vec = new Vector(5);
vec.add(4);
vec.add(1);
vec.add(7);
vec.add(3);
vec.add(5);
vec.add(9);
vec.add(2);
vec.add(8);
vec.add(6);
System.out.println("The Vector elements are: " + vec);
Python | Numpy matrix.mean()

15 Apr, 2019
With the help of Numpy matrix.mean() method, we can get the mean value from given matrix.
Syntax : matrix.mean()
Return : Return mean value from given matrix
Example #1 :In this example we can see that we are able to get the mean value from a given matrix with the help of method matrix.mean().
# import the important module in pythonimport numpy as np          # make matrix with numpygfg = np.matrix('[64, 1; 12, 3]')          # applying matrix.mean() methodgeeks = gfg.mean()    print(geeks)
20.0

Example #2 :
# import the important module in pythonimport numpy as np          # make a matrix with numpygfg = np.matrix('[1, 2, 3; 4, 5, 6; 7, 8, 9]')          # applying matrix.mean() methodgeeks = gfg.mean()    print(geeks)
5.0

Python numpy-Matrix Function
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
MomentJS - Is Daylight Saving Time

This method returns true or false if the current moment falls in daylight saving time.
moment().isDST();

var isdylight = moment().isDST();
If date is not given it will check for the current time.
var isdylight = moment([2017, 2, 14]).isDST();
 Print
 Add Notes
 Bookmark this page
Perl | Pass By Reference - GeeksforGeeks

12 Feb, 2019
When a variable is passed by reference function operates on original data in the function. Passing by reference allows the function to change the original value of a variable.
When the values of the elements in the argument arrays @_ are changed, the values of the corresponding arguments will also change. This is what passing parameters by reference does.
In the example given below, when we update the elements of an array @a in subroutine sample, it also changes the value of the parameters which will be reflected in the whole program. Hence when parameters are called by reference, changing their value in the function also changes their value in the main program.
Example 1:
#!/usr/bin/perl  # Initialising an array 'a' @a = (0..10);   # Array before subroutine callprint("Values of an array before function call: = @a\n");  # calling subroutine 'sample'sample(@a);  # Array after subroutine callprint("Values of an array after function call: = @a");  # Subroutine to represent # Passing by Referencesub sample{     $_[0] = "A";      $_[1] = "B";}
Output:
Values of an array before function call: = 0 1 2 3 4 5 6 7 8 9 10
Values of an array after function call: =  A B 2 3 4 5 6 7 8 9 10

Here is how the program works:-
An array consisting of values from 0 to 10 is defined.Further, this array is passed to the ‘sample’ subroutine.A subroutine ‘sample’ is already defined. Inside this, the values of the first and second parameters are changed through the argument array @_.Values of the array @a are displayed after calling the subroutine. Now the first two values of the scalar are updated to A and B respectively.
An array consisting of values from 0 to 10 is defined.
Further, this array is passed to the ‘sample’ subroutine.
A subroutine ‘sample’ is already defined. Inside this, the values of the first and second parameters are changed through the argument array @_.
Values of the array @a are displayed after calling the subroutine. Now the first two values of the scalar are updated to A and B respectively.
Example 2:
#!/usr/bin/perl  # Initializing values to scalar# variables x and ymy $x = 10;my $y = 20;  # Values before subroutine callprint "Before calling subroutine x = $x, y = $y \n";  # Subroutine callsample($x, $y);   # Values after subroutine callprint "After calling subroutine x = $x, y = $y ";  # Subroutine sample sub sample{    $_[0] = 1;    $_[1] = 2;}
Output:
Before calling subroutine x = 10, y = 20 
After calling subroutine x = 1, y = 2 

Perl-function
Picked
Perl
Perl
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Perl | Polymorphism in OOPs
Perl | Arrays
Perl | Arrays (push, pop, shift, unshift)
Perl Tutorial - Learn Perl With Examples
Use of print() and say() in Perl
Perl | Boolean Values
Perl | length() Function
Introduction to Perl
Perl | sleep() Function
Perl | join() Function
How to pass individual elements in an array as argument to function in C language?

If individual elements are to be passed as arguments, then array elements along with their subscripts must be given in function call.
To receive the elements, simple variables are used in function definition.
#include<stdio.h>
main (){
   void display (int, int);
   int a[5], i;
   clrscr();
   printf (“enter 5 elements”);
   for (i=0; i<5; i++)
      scanf("%d", &a[i]);
   display (a [0], a[4]); //calling function with individual arguments
   getch( );
}
void display (int a, int b){ //called function with individual arguments
   print f ("first element = %d",a);
   printf ("last element = %d",b);
}
Enter 5 elements
   10    20    30    40    50
First element = 10
Last element = 50
Consider another example for passing individual elements as argument to a function.
#include<stdio.h>
main (){
   void arguments(int,int);
   int a[10], i;
   printf ("enter 6 elements:\n");
   for (i=0; i<6; i++)
      scanf("%d", &a[i]);
   arguments(a[0],a[5]); //calling function with individual arguments
   getch( );
}
void arguments(int a, int b){ //called function with individual arguments
   printf ("first element = %d\n",a);
   printf ("last element = %d\n",b);
}
enter 6 elements:
1
2
3
4
5
6
first element = 1
last element = 6
Writer append(char) method in Java with Examples - GeeksforGeeks

29 Jan, 2019
The append(char) method of Writer Class in Java is used to append the specified char value on the writer. This char value is taken as a parameter.
Syntax:
public void append(char charValue)
Parameters: This method accepts a mandatory parameter charValue which is the char value to be appended on the writer.
Return Value: This method do not returns any value.
Below methods illustrates the working of append(char) method:
Program 1:
// Java program to demonstrate// Writer append(char) method  import java.io.*;  class GFG {    public static void main(String[] args)    {          try {              // Create a Writer instance            Writer writer                = new PrintWriter(System.out);              // Append the char value 'A'            // to this writer using append() method            // This will put the charValue in the            // writer till it is appended on the console            writer.append('A');              writer.flush();        }        catch (Exception e) {            System.out.println(e);        }    }}
A

Program 2:
// Java program to demonstrate// Writer append(char) method  import java.io.*;  class GFG {    public static void main(String[] args)    {          try {              // Create a Writer instance            Writer writer                = new PrintWriter(System.out);              // Append the char value 'G'            // to this writer using append() method            // This will put the charValue in the            // writer till it is appended on the console            writer.append('G');              writer.flush();        }        catch (Exception e) {            System.out.println(e);        }    }}
G

Java-Functions
Java-IO package
Java-Writer
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
HashMap in Java with Examples
How to iterate any Map in Java
Interfaces in Java
Initialize an ArrayList in Java
Stack Class in Java
Multidimensional Arrays in Java
Singleton Class in Java
Collections in Java
Set in Java
Overriding in Java