// Utility function to find minimum of three numbers
int min(int x, int y, int z)
{
return min(min(x, y), z);
}
int editDist(char* str1 , char* str2 , int m ,int n)
{
// If first string is empty, the only option is to
// insert all characters of second string into first
if (m == 0) return n;
// If second string is empty, the only option is to
// remove all characters of first string
if (n == 0) return m;
// If last characters of two strings are same, nothing
// much to do. Ignore last characters and get count for
// remaining strings.
if (str1[m-1] == str2[n-1])
return editDist(str1, str2, m-1, n-1);
// If last characters are not same, consider all three
// operations on last character of first string, recursively
// compute minimum cost for all three operations and take
// minimum of three values.
return 1 + min ( editDist(str1, str2, m, n-1), // Insert
editDist(str1, str2, m-1, n), // Remove
editDist(str1, str2, m-1, n-1) // Replace
);
}
int editDist(char *firstString, char *secString, int table)
{
return editDist(firstString, secString, table, table);
}
int editDist(char * firstString, char * secString, int table) { //Code to make a edit distance...
Consider the following code: int i = 0x56789a; char c = (char) i; int j = c; What is the hex value of c? (0x9a) What is the hex value of j? (0xffffff9a) I know the answer but I don't know how to get to that answer. Can someone explain this to me, please? Thanks!
CREATE TABLE vendor ( vendor_id int NOT NULL, vendor_name char(50) NOT NULL, contact_name char(50), CONSTRAINT vendors_pk PRIMARY KEY (vendor_id) ); What is the code to add the foreign key for this table? Can you please add the entire code with mine included. Thank you in advance.
int xyz( char[] X, char[] Y, int m, int n ) { int L[][] = new int[m+1] [n+1]; for (int i=0; i<=m; i++){ for (int j=0; j<=n; j++){ if (i == 0 Ilj == 0) L[i][j] = 0; else if (x[i-1] == Y[j-1]) L[i][j] = L[i-1][j-1] + 1; else L[i][j] max(L[i-1][j], L[i][j-1]); مه } ...//more code follows Given the code fragment above, select the best descriptive phrase from the list below. Bottom-up. Recursive. Top-down.
The following code on a 32 bit machine: int x= 0xAABBCCDD; print("%02x",(int) (* ((char *)(& x))&0xFF)) will print out a ___________________ if the machine is big-end-in.
#include <stdio.h> int main(int argc, char *argv[]) { char a, *pc, c[9]; int i, *pk, k[9]; a='z'; pc=&(c[8]); pk=&(k[0]); for (i=0; i<9; i++) { *pc=a-(char)i; pc--; *pk=(int)a-i; pk++; } return 0; }//end of main Answer the below questions with the above code Write out the memory map for the above C code in the following table. For array variables, list the address range for the entire array. Assume the memory address starts from 100, that is, the address for a...
why is correct the output of this code? #include <stdio.h> int main( void ) { char val[] = "one"; if (val[1] = 'o') printf("correct"); else printf("incorrect"); }
The Code is C++ // tic tac toe game #include <iostream> using namespace std; const int SIZE = 9; int check(char *); void displayBoard(char *); void initBoard(char *); int main() { char board[SIZE]; int player, choice, win, count; char mark; count = 0; // number of boxes marked till now initBoard(board); // start the game player = 1; // default player mark = 'X'; // default mark do { displayBoard(board); cout << "Player " << player << "(" << mark...
Here is the indexOf method that I wrote: public static int indexOf(char[] arr, char ch) { if(arr == null || arr.length == 0) { return -1; } for (int i = 0; i < arr.length; i++) { if(arr[i] == ch) { return i; } } return -1; ...
#include <stdio.h> int main(int argc, char *argv[]) { int i; for (i = argc - 1; i > 0; i--) printf("%s ", argv[i]); printf("\n"); return 0; } can you explain this code in c and why use this function
24. What will be the output of the following code #include<stdio.h> int main() { char *p; p="%d\n"; p++; p++; printf(p-2, 100); return 0; } a. 100 b. 00 c. 10 d. compiler error e. none of the above 26. What will be the output of the following code #define TRIPPLE(x) (3*x) int x = 4; printf(“triple(%d) = %d \n”,x+1, TRIPPLE(x+1)); a. triple(5) = 12 b. triple(5) = 13 c. triple(4) = 14 d. triple(4) = 15 e. none of the...