# Php Programming Code Examples

## Php > Algorithms Code Examples

### This function returns the position of string s1 within string s2

C++ Checks if an Undirected Graph is Tree -
C++ Program to check whether an undirected 'graph is tree' or not. Graph is tree if it doesn't contain cycles. A recursive function that uses visited[] & parent to detect cycle in subgraph

Generate All Possible Subsets With Exactly -
Algorithm takes the input of "n" data element and 'prints all possible' combination of length 'k'. It maintains a boolean array of length 'n'. If the corresponding boolean value is true, then

Code Copy its Input to its Output Replace -
Program sample to copy its input to its output replacing string of one or more blanks by a single blank. String will be terminated if you press ENTER. Press Ctrl-Z & then ENTER

Check Alphabets by Conditional Operator -
C program code input a character and check whether the character is alphabet or not using Conditional/Ternary operator ?:. How to check alphabets by conditional operator...

Swapping Two Numbers Without Variable -
Imagine we have two number 1 and 2 stored in x and j respectively now. If we add x and j (1 + 2) and store it to x then x will become 3 and j is still 2. We subtract j (2) from new value of

C program code Self-Referential structure -
Buffer for ungetch, next free position in buf, word frequency count, getword: get next word or character from input, addtree: add a node with w, at or below p, a new word has

Write the Number as the Sum of Numbers -
Algorithm "Counts the partition" of the given number. There is no straight method to count a total number of the partition so we need to 'Generate and Count' them. Time complexity

C++ Program Finds the Transitive Closure -
C++ Program to find the trnasitive closure of a given graph. In mathematics, the transitive closure of a binary relation R on a set X is the "transitive relation" R+ on set X such that R+