Algorithm A4: index(T, P) 1. Initialize i = 0 and max = t – p + 1 / * t and p are respectively lengths of strings T and P * / 2. Repeat steps 3 to 6 while i < max 3. Repeat for j = 0 to p – 1 5. Return index i and exit 6. i = i + 1 7. Return –1 for no match 8. Exit run the above algorithms in C/C+
Q: Write a recursive function named merge_sort that sorts a given list using the recursive algorithm of…
A: Note: - We are allowed to answer one question at a time because you did not specify which question…
Q: Given these 8 numeric values to be sorted using the recursive Mergesort algorithm: 92 63 24 18 69…
A: Merge sort is the sorting technique which uses merging procedure to sort the elements and it good…
Q: write a python program to find the" kth smallest element" in the ascending order sorted list. also…
A: Program Plan: Initialize a list. Get the user input for the number of elements to store in the…
Q: Given the unsorted list [6, 5, 4, 3, 7, 1, 2], show what the contents of the list would be after…
A: a. Selection sort:[6, 5, 4, 3, 7, 1, 2][1, 5, 4, 3, 7, 6, 2][1, 2, 4, 3, 7, 6, 5][1, 2, 3, 4, 7, 6,…
Q: Suppose the following array were passed in to a mergesort algorithm: 42 39 87 21| 56 93 43 35 Draw…
A: I have applied the merge sort algorithm in the array and I have show how our array will be…
Q: Perform a selection sort on the following unsorted list: 3 2 5 6 4 1 In each blank, enter the list…
A:
Q: Python. A list A1, ..., An is given. Leave the list unchanged if its members are sorted…
A: num = [20, 19, 15, 10, 9, 8]res = [num[0], num[1]] if num[0]<num[1]: for i in…
Q: Write a Java code to find the smallest number from a list A[n] of numbers (show the output). Write a…
A: The solutions of the first three questions are shown below. Please repost the questions in sets of…
Q: Suppose you have the following sorted list [3, 5, 6, 8, 11, 12, 14, 15, 17, 18] and are using the…
A: Given a sorted array : [3, 5, 6, 8, 11, 12, 14, 15, 17, 18] Size of array : 10 Subscript Range : 0-9…
Q: You, Alice and Bob are working on recursive search algorithms and have been studying a variant of…
A: I will explain it in details,
Q: 1) Algorithm A1: length(s) 1. Initialize len to 0. 2. Set a variable to the beginning index of…
A: As per our guidelines we are supposed to answer only one question. Kindly repost the remaining…
Q: Given integer inputs seed, how_many, and max_num, generate a list of how_many unique random integers…
A: Given lower and maximum cutoff points, produce a given count of irregular numbers inside a given…
Q: You, Alice and Bob are working on recursive search algorithms and have been studying a variant of…
A: Sol:-- Bob has heard that tinary search is no more efficiant than binary search. Bound select a…
Q: For the following problem please write an algorithm in plain English .i.e give details as to how you…
A: Algorithm to arrange the deck of 52 cards for the given scenario is as follows:
Q: For a given character recursively, without using strchr() or strrchr(), Check if it is in a string.…
A: For a given character recursively, without using strchr() or strrchr(), Check if it is in a…
Q: a) read(): - Ask the user for a valid atomic number (Z) b) compute_binding_energy(Z, table) : -…
A: The code is below in python:
Q: Find a longest common subsequence between following strings: String1= {1, 2, 3, 4, 5, 6, 7, 8}…
A: The given string1 = {1,2,3,4,5,6,7,8} The given string2={1,1,9,0,3,9,6,4} The longest common…
Q: as a pivot is a very effective strategy for Quicksort. C. Both Quicksort and Insertion sort are
A: Explanation: Because Quick Sort has extra cost from the recursive function calls, insertion sort is…
Q: Algorithm 4.2.1: Binary Search #2 // version #2.0 Begin p - 1; q - n; While (p < q) Do j- [(p+q)/2];…
A: Answer below:
Q: Algorithm A1: length(s) 1. Initialize len to 0. 2. Set a variable to the beginning index of string…
A: s is the string and length is the function name
Q: 41 Aigonim 1. Initialize i= 0 and max = t-p+1/ *t and p are respectively lengths of strings T and P*…
A: /******************************************************************************…
Q: Use Figure 10.8 as an example to show how to apply the binary search approach to a search for key 10…
A: The binary search algorithm is mentioned below. STEP 1: In the first step, sort the list in…
Q: What does the ff algorithm return? (Note: indentation is important) algorithm foo(a1, a2, ..., an :…
A:
Q: You, Alice and Bob are working on recursive search algorithms and have been studying a variant of…
A: Introduction : Trinary search is a decrease and conquers algorithm that can be used to find an…
Q: 5. a) Run the algorithm below for the input list 5, 9, 10 and complete the table, showing how the…
A: a. Procedure Final(5,9,10) s:=0 k:=1,n=3 WHILE 1<=3 s:=0+5=5 k:=1+1=2 now WHILE 2<=3…
Q: Write a program that replaces words in a sentence. The input begins with word replacement pairs…
A: PROGRAM: #Defining the main program def main(): #Getting input for replacement sentence…
Q: Find a longest common subsequence (LCS) of two DNA sequences and fill the following table using the…
A: Given data, S1= CGATAG S2= GCATA Remember: 1. The cell directly to the left of it 2. The cell…
Q: By using a recursive function to find s value: S= 2/x – 4/x + 6/x – 8/x .. 2n/x
A: The given expression to be represented in the form of recursion is :: S = 2/x - 4/x + 6/x -…
Q: programming language. DynamicList + capacity : int /initialized to 10 add(int index, Object o):…
A: Two questions are asked so first question with two parts is solved. Please upload remaining…
Q: Design a type of sieve algorithm that would (1) Create a list of consecutive integers from 1 to n.…
A: import java.util.*; public class main5 { public static void main(String args[]){ Scanner…
Q: Given an input string, delete recursively all the duplicate adjacent characters and return a string…
A: Hello student, hope you are doing good. In this question, as the coding langauge is not mentioned so…
Q: How many ordered lists (a, b, c, d, e, f) satisfy the equation: a+b+c+d+e+f = 27 if a, b, c, d, e,…
A: Using Permutation and Combinations we can solve it using a formula i.e the Number of non-negative…
Q: 1. Initialize i = 0 and max = t – p + 1 / * t and p are respectively lengths of strings T and P * /…
A: Given: 1. Initialize i = 0 and max = t – p + 1 / * t and p are respectively lengthsof strings T and…
Q: Find a longest common subsequence between following strings: String1= "Your Name" String2= "Your…
A: Let us suppose m is the length of first string[X] and n be the length of the second string[Y].…
Q: Write a function that returns of multiples of n in given list. Ex: [12,41,63,21,52,17,18] n=3…
A: def multpiles_of_n(l,n): res=[] # taking empty list for i in l: #iterating over the list…
Q: In Python, write a recursive implementation of Fibonacci without memoization. Include a timer to…
A: Python program to solve the given problem is below.
Q: Write a program that replaces words in a sentence. The input begins with word replacement pairs…
A: replacementDict = {} s = input().split() i = 0 while i<len(s): replacementDict[s[i]] = s[i+1]…
Q: hich of the following import and call combinations does not work for the exponential function…
A: The answers for McQ with reason posted in answer section
Q: I want to solve them as algorithms 1-Write a steps to search for a node contain a given value in a…
A: Start Store the first pointer in some temp Iterate till end of list If data is same as search,…
Q: 4. Two words are anagrams if they contain all of the same letters, but in a different order. For…
A: Input the two strings. Create an dictionary for both the strings. Traverse both the strings and…
Q: 2. Write the recurrence relation of the following recursive algorithm. What is the compl of the…
A: The recurrence relation of the recursive algorithm, the complexity of the algorithm
Q: Convert to C language #include using namespace std; //hash function 1 int main() { string s;…
A: here in this question we have asked to write a program in c. which take any integer input from user…
Q: 5. a) Run the algorithm below for the input list 4, 5, 11 and complete the table, showing how the…
A: first lets understand given algorithm: procedure Final(a1,a2,a3 : positive integers) //takes 3…
Q: True or False? The sequence is defined recursively as an = an-1]+[1; ao = 3 Then ag = 3 . True False
A:
Q: Write a program that replaces words in a sentence. The input begins with word replacement pairs…
A: Error in program: The following statement will print whitespace at the end of the sentence.…
Q: In program C Write a recursive function find_sum(n)that calculates the sum of successive integers…
A: int find_sum(int n) { if(n == 1) return 1; else return (n + find_sum(n-1));}
Q: Write a version of the sequential search algorithm that can be used to search a sorted list. Write a…
A: Given :- Write a version of the sequential search algorithm that can be used to search a sorted…
1. Initialize i = 0 and max = t – p + 1 / * t and p are respectively lengths
of strings T and P * /
2. Repeat steps 3 to 6 while i < max
3. Repeat for j = 0 to p – 1
5. Return index i and exit
6. i = i + 1
7. Return –1 for no match
8. Exit
run the above algorithms in C/C++
Step by step
Solved in 2 steps
- in this code: def insertSort(A): for i in range(1,len(A)): j = i-1 while A[j]>A[j+1] and j>=0: A[j],A[j+1] = A[j+1],A[j] j -= 1 A = [3,1,11,9,10,2] insertSort(A) print(A) 1) What is the Hypothesis? 2) What is Your InductionComputer Science you are given a string X of length n and another string Y of length m ≤n. Say,the indexes p1, p2, p3, p4 and q1, q2, q3, q4 form two sub-sequences, i.e., 0 ≤ p1 < p2 < p3 < p4 < nand 0 ≤q1 < q2 < q3 < q4 < n; then, they are non-overlapping if p4 < q1.The task is to count the maximum number of non-overlapping sub-sequences of X that are thesame as Y . Thus, if X = GAXTYAWBGTAUGBTABGRGTAXB and Y = GTAB, then the answer is3 as shown by the red fonts. We cannot select the underlined GTAB as it overlaps with a red GTAB(i.e., among overlapping sub-sequences, you can select only one of them).Describe an O(m + n) time algorithm to obtain the count. Write a pseudo-code.For the following problem please write an algorithm in plain English .i.e give details as to how you will solve the problem.A deck of 52 playing cards (as used for playing bridge) has to be sorted. At the end of the attempt, the sorted deck of cards should be on the table with the backside up.The order within a suite is Ace - King - Queen - Jack- 10 -9 - 8 - 7- 6- 5- 4- 3- 2. The very first card in the sorted deck is the Ace of Clubs, the next ones are the King of Clubs, the Queen of Clubs, the Jack of Clubs, the 10 of Clubs ... down to the 2 of Clubs. The next card is Ace of Spades, followed by the King of Spades etc. The hearts and diamonds cards follow in the same order.The deck of cards must be well-shuffled immediately prior to the challenge.Please write the algorithm in steps like you write a recipe for a dish.If any steps need to be repeated try to use a loop.Please try to not use any programming language.(IT's one question just with a lot of instructions to be understood well)
- g1 = 5 g2 = 6 for k in range(3,8): gk = (k-1)·gk-1 + gk-2 What is the last term, g8, of the recursive sequence generated as a result of executing this algorithm?Given these 8 numeric values to be sorted using the recursive Mergesort algorithm: 92 63 24 18 69 27 64 43 The list that will be passed to the first call of the Mergesort algorithm will be the entire list of values above. Show the list that will be passed to the 5th call of the Mergesort algorithm.Use C++ Write a program that replaces words in a sentence. The input begins with an integer indicating the number of word replacement pairs (original and replacement) that follow. The next line of input begins with an integer indicating the number of words in the sentence that follows. Any word on the original list is replaced. Ex: If the input is: 3 automobile car manufacturer maker children kids 15 The automobile manufacturer recommends car seats for children if the automobile doesn't already have one. then the output is: The car maker recommends car seats for kids if the car doesn't already have one. You can assume the original words are unique. For coding simplicity, follow each output word by a space, even the last one. Hint: For words to replace, use two vectors: One for the original words, and the other for the replacements. Your program must define and call the following function that returns index of word's first occurrence in wordList. If not found, then the function returns…
- Computer Science Draw the TST that results from inserting the following strings into an initially empty trie now is the time for all good people to come to the aid ofHow this can be with recursion. It has to show all possible path, when movement in all possible direction is allowed. #include <bits/stdc++.h> #define MAX 5 using namespace std; // Function returns true if the // move taken is valid else // it will return false. bool isSafe(int row, int col, int m[][MAX], int n, bool visited[][MAX]) { if (row == -1 || row == n || col == -1 || col == n || visited[row][col] || m[row][col] == 0) return false; return true; } // Function to print all the possible // paths from (0, 0) to (n-1, n-1). void printPathUtil(int row, int col, int m[][MAX], int n, string& path, vector<string>& possiblePaths, bool visited[][MAX]) { // This will check the initial point // (i.e. (0, 0)) to start the paths. if (row == -1 || row == n || col == -1 || col == n || visited[row][col] || m[row][col] == 0) return; // If reach the last cell (n-1, n-1) // then store the path and return if (row == n - 1 && col == n - 1) {…he algorithm below is used to find the largest element in a list of numbers.By modifying one of the lines in the program it is possible to make the algorithm find the SMALLEST element. Which line would need to be modified and how?01 target <- list[1] 02 FOR EACH num IN list 03 { 04 IF(num > target) 05 { 06 target <- num 07 } 08 } 09 DISPLAY(target) a. Line 01 becomes target <- list[2] b. Line 01 becomes list[0] <- target c. Line 04 becomes if (num <= target) d. Line 04 becomes IF (num < target)
- Python code: import randomdef main(): # main function definition aGrades=[] # empty list to store Grades for i in range(7): # loop to read 7 inputs print("Input scores ",i+1," : ", end="") # a message to enter grade n=int(input()) # input grade aGrades.append(n) # add grade into list print("Grade list before randomize: ",aGrades) # print list random.shuffle(aGrades) # randomize list numExams=len(aGrades)-1 # compute numExams FinalExam=aGrades[-1] # store final grade TotalPoints=sum(aGrades)-aGrades[-1] # compute TotalPoints TestAverage=TotalPoints/numExams # compute TestAverage FinalAverage=TestAverage*.6 + FinalExam*.4 # compute FinalAverage print("Grade list after randomize is: ",aGrades) # print list print("Test Average = %.2f"%TestAverage) # print test average print("Final Average = %.2f "%FinalAverage) # print final averagemain() # calling main function Can you explain in a word doc explaining each line…Write a version of the sequential search algorithm that can be used to search a sorted list. Write a program to test the sequential search algorithm. Use either the function bubbleSort or insertionSort to sort the list before the search. Your program should prompt the user to enter 10 digits and then prompt the user to enter a digit to search - if the list contains this digit, output its position to the console: x is found at position y If the digit is not contained in the list, output the following: x is not in the listgiven input word, return the list of abbreviations.ex)word => ['word', 'wor1', 'wo1d', 'wo2', 'w1rd', 'w1r1', 'w2d', 'w3', '1ord', '1or1', '1o1d', '1o2', '2rd', '2r1', '3d', '4']""" def generate_abbreviations(word): def backtrack(result, word, pos, count, cur): if pos == len(word): if count > 0: cur += str(count) result.append(cur) return if count > 0: # add the current word backtrack(result, word, pos+1, 0, cur+str(count)+word[pos]) else: backtrack(result, word, pos+1, 0, cur+word[pos]) # skip the current word backtrack(result, word, pos+1, count+1, cur).