3. (10 marks) a) (5 marks) For a given string S = p1p2...pn, the definition for next(i), 2 ≤ i ≤ n, is as follows: next(i) = the maximum j (0 < j < i − 1) such that p1p2...pj = pi−jpi−j+1...pi−1, 0 if no such j exists. (next(1) is defined as -1.) Compute the next function for string “abababc”.

ANSWER:
GIVEN THAT:
Given string S = p1p2...pn, the definition for next(i), 2 ≤ i ≤ n:
1. Given String is abababc and let thier indices be 1234567 , the string will be as below

2. Here S = p1p2...pn where p1=a , p2=b, p3=a, p4=b, p5=a, p6=b, p7=c
Given next(1) = -1
3. next(2) = 0 (as here 0<j<1 and we cant find any j)
4. next(3) = 0 (as here 0<j<2 and we will get i=3 and j=1 and equation is p1!=p2(a!=b) hence next(3) is 0)
5. next(4) = 1 (as here 0<j<3 we will get i=4 and j=1 and equation is p1=p3(a=a) and other combination is i=4 and j=2 p1p2!=p2p3(ab != ba) hence j=1)
6. next(5) = 2 (as here 0<j<4 we will get i=5 and j=1 and equation is p1!=p4(a=b) and other combination is i=5 and j=2 p1p2=p3p4(ab = ab) and other combination is i=5 and j=3 p1p2p3!=p2p3p4(aba = bab) hence j=2)
7. next(6) = 3 (as here 0<j<5 we will get i=6 and j=1 and equation is p1=p5(a=a) and other combination is i=6 and j=2 p1p2!=p4p5(ab = ba) and other combination is i=6 and j=3 p1p2p3=p3p4p5(aba = aba) and other combination is i=6 and j=4 p1p2p3p4!=p2p3p4p5(ababa=baba) hence j=3)
8. next(7) = 4 (as here 0<j<6 we will get i=7 and j=1 and equation is p1!=p6(a=b) and other combination is i=7 and j=2 p1p2=p5p6(ab = ab) and other combination is i=7 and j=3 p1p2p3!=p4p5p6(aba = bab) and other combination i=7 and j=4 p1p2p3p4=p3p4p5p6(abab=abab) and other combination i=7 and j=5 p1p2p3p4p5=p2p3p4p5p6(abab=babab) hence j=4)
So
9. next function of the string abababc is -1001234
3. (10 marks) a) (5 marks) For a given string S = p1p2...pn, the definition for...
c. [3 marks] Given the following definition of the class MyClass, class MyClass { String s int z Myclass(int y) { z = y } } fill in the blanks (labelled i., ii. and iii.) in the definition of the method main, of the class StringProcessing, with i. a declaration of a variable named obj of type MyClass, initialised with a MyClass object so that its instance variable z has a value of 20, ii. an assignment of the instance...
5. (A) Write an inductive definition for the following set: (please include ALL steps) S: lam b^2m | where me N and m >0} *Sis a set of strings, aam bn means amb (B) Write pseudo-code of a recursive function f(x, y) to check whether string x and string y are equal. The alphabet is (a.b). Hint for a given string P, you can verify if it is aQ or bQ (where Q is the remainder of string P) (10...
PLEASE ANSWER ALL! SHOWS STEPS
2. (a) Prove by using the definition of convergence only, without using limit theo- (b) Prove by using the definition of continuity, or by using the є_ó property, that 3. Let f be a twice differentiable function defined on the closed interval [0, 1]. Suppose rems, that if (S) is a sequence converging to s, then lim, 10 2 f (x) is a continuous function on R r,s,t e [0,1] are defined so that r...
hint
This exercise 5 to use the definition of Riemann integral
F. Let f : [a, b] → R be a bounded function. Suppose there exist a sequence of partitions {Pk} of [a, b] such that lim (U(Pk, f) – L (Pk,f)) = 0. k20 Show that f is Riemann integrable and that Så f = lim (U(P«, f)) = lim (L (Pk,f)). k- k0 1,0 < x <1 - Suppose f : [-1, 1] → R is defined as...
If we are given the improper integral definition of the gamma
function above,
i) show that , a>-1 where
ii) show that
iii) Given that , find the laplace transform of
please show all steps for all parts
0<'FP 2-0 1-07 OU = (20).J T + 5 Si = {27}] (I+D)) [{f(t)} = S.*f(t)e-stat T(a + 1) = al(a) r(a) = var f(t) = 43/2
5. Suppose we are given an unweighted, directed graph G with n vertices (labelled 1 to n), and let M be the n × n adjacency matrix for G (that is, M (i,j-1 if directed edge (1J) is in G and 0 otherwise). a. Let the product of M with itself (M2) be defined, for 1 S i,jS n, as follows where "." is the Boolean and operator and "+" is the Boolean or operator. Given this definition what does...
1. [5 marks Show the following hold using the definition of Big Oh: a) 2 mark 1729 is O(1) b) 3 marks 2n2-4n -3 is O(n2) 2. [3 marks] Using the definition of Big-Oh, prove that 2n2(n 1) is not O(n2) 3. 6 marks Let f(n),g(n), h(n) be complexity functions. Using the definition of Big-Oh, prove the following two claims a) 3 marks Let k be a positive real constant and f(n) is O(g(n)), then k f(n) is O(g(n)) b)...
Page 3 of 5 Question 3 (20 marks, each part is 5 marks) For the following snippets, how many times is the printf statement executed? Briefly explain (up to 3 sentences). Part a int i, j; int n = 100; for (i = 1; i <= n; i++) { for (j = 3*i; j <= n; j++) { printf("programming is fun\n"); } } Part b int i, j; int n = 1000000; for (i = 1; i <= n; i++)...
Please finish all the questions,Thanks
Following is Appendix
assume the definition of Java class Heap given in the Appendix For this question, a. (2 marks Consider the following heap 30 12 20 19 6 10 18 Given the array representation of a heap discussed in class, what is the array that corre sponds to this heap? b. (5 marks) Successively insert into the heap of part (a.) 22, 35 and 11, in that order. Use the standard heap insertion algorithm....
Question One (2 marks): What is the complexity of the given code as a function of the problem size n? Show the (complete) details of your analysis. Note: a [ i] s an array with n elements. for (int i- 0; i < n; i++) if (Math.random) > 0.5) if (i%2-0) Insertionsort (a[i]); else Quicksort (a[i]) else for (int j = 0; j < i; j++) for (int k 0: k 〈 i; k++) o (logn)
Question One (2 marks):...