This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int factorial ( int n ) | |
{ | |
if ( n == 0 ) | |
return 1; | |
else | |
return ( n * factorial ( n-1 ) ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int fibonacci ( int n ) | |
{ | |
if ( n == 0 ) | |
return 0; | |
if ( n == 1 ) | |
return 1; | |
return ( fibonacci( n-1 ) + fibonacci( n-2 ) ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
students = { | |
'Shubham': 'Expert in maths', | |
'Ashwin': 'Expert in physics', | |
'Sneha': 'Expert in Dance and Art' | |
} | |
students['Ashwin'] | |
# O/p: | |
'Expert in physics' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
students = { | |
Shubham: 'Expert in maths', | |
Ashwin: 'Expert in physics', | |
Sneha: 'Expert in Dance and Art' | |
} | |
students[:Ashwin] | |
# O/p: | |
'Expert in physics' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"} | |