Skip to content

Instantly share code, notes, and snippets.

View codertcet111's full-sized avatar
💭
Consistency brings happiness

codertcet111

💭
Consistency brings happiness
View GitHub Profile
Function Naive (T[0....n], P[0.....m])
{
//This function is to find pattern P in the string T
//Inputs are the two string T and P
//Output will be the index of the matched position of T string
for (i = 0, j = 0; to i <= n - m) do
{
if (T[i] == P[j]){
temp_i = i
while(pattern P matching with Text){
void radix(int array1[], int n){
int buckets_container[10][10]; //This is the buckets shown in the diagram
int count[10];
int numberOfIteration, largestNumber, div, bucketnumber, i, j, k;
//Now FInd the largest number
largestNumber = array1[0];
for(i=1; i<n;i++)
if (array1[i] > largestNumber)
largestNumber = array1[i];
int factorial ( int n )
{
if ( n == 0 )
return 1;
else
return ( n * factorial ( n-1 ) );
}
int fibonacci ( int n )
{
if ( n == 0 )
return 0;
if ( n == 1 )
return 1;
return ( fibonacci( n-1 ) + fibonacci( n-2 ) );
}
#include<stdio.h>
#include<conio.h>
void merge_sorting_function( int[], int, int);
void merge_with_sorting_function( int[], int, int, int);
void main(){
//Here I have considered my own array u can replace it with actual code for accepting
// it from user
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "HistorySegue" {
if let viewController = segue.destination as? HistoryController {
if(barcodeInt != nil){
viewController.detailItem = barcodeInt as AnyObject
}
}
}
}
#Here's a little help on delegates between two view controllers:
#Step 1: Make a protocol in the UIViewController that you will be removing/will be sending the data.
protocol FooTwoViewControllerDelegate:class {
func myVCDidFinish(_ controller: FooTwoViewController, text: String)
}
#Step2: Declare the delegate in the sending class (i.e. UIViewcontroller)
students = {
'Shubham': 'Expert in maths',
'Ashwin': 'Expert in physics',
'Sneha': 'Expert in Dance and Art'
}
students['Ashwin']
# O/p:
'Expert in physics'
students = {
Shubham: 'Expert in maths',
Ashwin: 'Expert in physics',
Sneha: 'Expert in Dance and Art'
}
students[:Ashwin]
# O/p:
'Expert in physics'
hash1 = {a: 100, b: 200}
hash2 = {x: 'Shreya', y: 'Mohit'}
# Merging two hash, In this hash1 and hash2 won't change
# only new hash will be generated by merging two hash
hash1.merge(hash2)
# O/P:
{:a=>100, :b=>200, :x=>"Shreya", :y=>"Mohit"}