This file contains hidden or 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 <iostream> | |
using namespace std; | |
class A{ | |
public: | |
virtual void functionA() { | |
cout << "function A of class A called!" << endl; | |
} | |
virtual void functionB() { | |
cout << "function B of class A called!" << endl; |
This file contains hidden or 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 <iostream> | |
#include <string> | |
using namespace std; | |
// i: str1 | |
// j: str2 | |
int calcDeletionDistance(string str1, string str2, int i, int j, int dp[][2000]) { | |
if (i == str1.length()) { |
This file contains hidden or 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
signature Rational = | |
sig | |
type rational | |
exception rat_error | |
val make_rat: int * int -> rational | |
val rat: int -> rational | |
val reci: int -> rational | |
val == : rational * rational -> bool | |
val << : rational * rational -> bool |
This file contains hidden or 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
(* | |
This program is used to solve the standard Tower of Hanoi puzzle. | |
*) | |
(* | |
Generate a list containing the disks from 1 to n, which is the rod from where we will transfer | |
*) | |
(* fun genList(L, i, N) = | |
if i=N+1 then L | |
else genList(i::L, i+1, N) *) |
This file contains hidden or 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
(* | |
A program to take a list of numbers and the binary relation R | |
then sort the numbers in the list according to R and also remove the duplicates, but not removing the duplicates after sorting, rather while sorting. It is supposed to have O(nlogn) time complexity and O(n) space complexity. | |
*) | |
(* | |
using Merge Sort routine from Prof. S. Arun Kumar's programs | |
*) | |
fun sortWithoutDuplicates R [] = [] |
This file contains hidden or 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
(* A program to calculate the next day given the current day in the format | |
ymmdd where y can be anything > 1, mm and dd represent the two integers representing the month and day respectively *) | |
exception invalid_date | |
fun next_day(y,m,d)= | |
let | |
fun check_valid_day(d)= | |
if d>=1 andalso d<=31 then true | |
else false | |
fun check_valid_month(m)= |