6. There are currently several online newspapers in Bangladesh, such as prothom Alo, bdnews24, daily star, Bangla tribunes, etc. Suppose you have access to these online newspapers contest and want to group them into a set of articles about the same story (e.g., all the sports news of all these newspapers will appear in the same place). What type of algorithms will you use to perform such kind of operation above? What are the motivations for choosing your algorithm? Explain.
Q: cci series begins with the terms 0 and 1 and has the property that each succeeding term is the sum…
A: Start Now declare variables i, b, c, fib we will initialize the variables b=0, c=1 and fib=0 Enter…
Q: A binary search only works if the values in the list are sorted. A bubble sort is a simple way to…
A: Bubble sort as well explained in the question, it is the comparison between the two successor…
Q: Given an array of integers, return the largest gap between the sorted elements of the array. For…
A: Algorithm - Create a new class with the name main. Now create a method with the name largest gap…
Q: Given an array of integers, return the largest gap between the sorted elements of the array. For…
A: Algorithm - Create a new class with the name main. Now create a method with the name largest gap…
Q: Consider the following algorithm to find all the prime numbers less than a given positive number N…
A: #include <stdio.h>#include <stdlib.h> int main(){ int n; printf("Enter the…
Q: T(n) = 2T(n/4) +n
A: Solution: Using Master methodT(n) = Θ(n)
Q: Show how the binary search algorithm searches for 25 in the sorted list below: 4 6 17 25 32 39 41 43…
A: In binary search algorithm you first need a sorted array. The above is sorted so we can perform…
Q: Euclid’s algorithm (or the Euclidean algorithm) is an algorithm that computes the greatest common…
A: Solution:
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: Consider an array of N integers. Describe an algorithm with an 0(N) runtime that processes the array…
A: Please refer below for your reference: Below is a O(n) approach: I have counted the number of null…
Q: Binary search is significantly faster than the built-in search but requires that the list is sorted.…
A: The question asks roughly how many times we need to search in order to make sorting the list first…
Q: What is the time complexity of the given algorithm below? An algorithm, M, for sorting a given…
A: n is the number of elements in the array A We are always comparing marking the first element but the…
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: Text reading is an integral component in our counting algorithms, and it is also ubiquitous in daily…
A: Actually, the answer has given below:
Q: Suppose we have two arrays A[1:n] and B[1:m] which are both in sorted order and are consisting of…
A: We have two arrays A[1:n] and B[1:m] ,given an integer 1≤r≤m+n, the union of arrays A and B in the…
Q: Consider the following list: 2, 10, 17, 45, 49, 55, 68, 85, 92, 98, 110 Using the binary search as…
A: Source code: package solution; public class Solution{ static int[] binarySearch(int arr[], int…
Q: Suppose that I searched for a number x in a sorted list of n items by comparing against the 5th…
A: The expression that best describes the approximate running time of this algorithm is as follows.
Q: Let n be a positive integer and suppose we identify a collection of n people with numbers ranging…
A: The above question is solved in step 2 :-
Q: Points Study the two methods below both will do the same work. If you use your algorithm analysis…
A: Linked List is a data structure where elements are linearly arranged, and can be traversed in 1…
Q: Text reading is an integral component in our counting algorithms, and it is also ubiquitous in daily…
A: Actually, the answer has given below:
Q: Below are a number of statements about sorting algorithms. Which of the above statements is correct?…
A: Find the answer with explanation given as below :
Q: Suppose you are given an array A of n Your task is to sort n numbers stored in array A by reading…
A: Everytime we select an element and is compared with all the other elements in array and finally its…
Q: 2. Complete the Table given below for the growth rates of the funtions in the analysis of the…
A: Completed the given table for the growth rates of functions
Q: Consider sorting n numbers stored in array A by first finding the smallest element of A and…
A: Let's understand step by step : Selection sort : 1. In selection sort the smallest element first…
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: Text reading is an integral component in our counting algorithms, and it is also ubiquitous in daily…
A: Objective: According to the given question, the time-complexity of the method readTextBad in terms…
Q: Given an unsorted array of integers, A, its size n, and two numbers x and y both elements of A.…
A: Include header file <iostream> for input output operations. Define main method Define array…
Q: A palindromic number is a number that is the same if read forwards or backwards: 12321 and 641146…
A: Important:- As per our guidelines, we are allowed to answer only the first three questions of…
Q: Consider the following algorithm to find all the prime numbers less than a given positive number N…
A: The required C code: #include<stdio.h># define MAX_SIZE 200 /* assign maximum size 200 */int…
Q: Answer the following question for basic sorting algorithms. Here is an array of 7 integers: (1)…
A: Part (1): The selection sort algorithm sorts any array by repeatedly finding the minimum element…
Q: Write and execute a program that can read 16 numbers from keyboard and do the Binary search on them.…
A: To find the position of the element from a array which algorithm is used, called Binary search. It…
Q: Write an efficient algorithm (to the best of your knowledge) for the following problem, briefly…
A:
Q: Assume you have the following list of numbers: 12, 14, 23, 34, 37, 37, 45, 53, 55, 59, 66, 71, 74,…
A:
Q: Design and implement an algorithm using recursion and backtracking to sort an array of integers into…
A: Note: Since the language in the question is not defined so I am using python to implement this…
Q: It is not possible to get O(n) if the inner loop of the insertion sort is tested Select one: True…
A: It is not possible to get O(n) if the inner loop of the insertion sort is tested
Q: Let X and Y be two arrays. Let them contain the same distinct k keys but the keys are ordered…
A: prefixAverages(X,Y,n) Input array X,Y and n integers Output array X,Yof n doubles Let X,Y be an…
Q: Write the algorithm workflow using 2 number arrays where each number is 1 or 0, the fastest…
A: The answer is
Q: 1. a.An algorithm can be specified in various ways. Identify and explain four ways in which an…
A: 1 A. an algorithm can be specified in 4 ways as: By using Natural language: Any algorithm can be…
Q: Question 1) Implement Merge sort and Quick sort on a programming language of your choice. Evaluate…
A: The result for each sorting algorithm is given below:-
Q: T(n) = 2T(n/4) +1 %3D
A: Answer: T(n) = Θ(n)
Q: Java: Consider the following algorithm for searching in an unsorted array. If the size of the array…
A: This Algorithm is based on Merge sort. Pseudocode for Merge sort: We shall now see the pseudocodes…
Q: Given an array of integers, return the largest gap between the sorted elements of the array. For…
A: We will use one of the sorting technique to solve this problem. Below is the solution.
Q: 1.a)Given an array which is sorted in descending [large to small] order and got no repeated numbers.…
A:
Q: Suppose you are given a task to rank the students. You have gotten the marks and id of the students.…
A: NOTE: Code runs successfully as the above problem describe. Please use proper indentation for no…
Q: Analyze another algorithm under Divide and Conquer. In your discussion, include the following: 1.…
A: The program is written in Java. Check the program screenshot for the correct indentation. Please…
Q: Discuss another algorithm under Divide and Conquer. In your discussion, include the following: 1.…
A: Divide And Conquer : This technique can be divided into the following three parts: => Divide:-…
Step by step
Solved in 2 steps
- Implement a program that will populate a 6x5 matrix with randomly generated integers from 100 to 500. (1) print your matrix in a table form. (2) modify your code to multiply all odd numbers by 2 and print the matrix. Sample run: Initial Matrix: 145 | 437 | 222 | 101 | 100 | 278 500 | 190 | 415 | 288 | 466 322 377 | 240 | 451 | 331 186 186 432 102 | 106 | 105 249 248 | 117 | 213 | 499 488 355 | 266 | 396 | New Matrix: 290 | 874 | 222 | 101 | 100 | 278 500 | 190 | 830 288 | 466 322 754 | 240 | 902 | 662 186 432 | 102 | 106 | 210| 498 248 | 234 | 426 | 998 488 710 | 266 | 396 |Implement a city database using ordered lists. Each database record contains the name of the city (a string of arbitrary length) and the coordinates of the city expressed as integer x and y coordinates. Your database should allow records to be inserted, deleted by name, and searched by name. Another operation that should be supported is to print all records within a given distance of a specified point/coordinate. The order of cities should be alphabetically by city name. Implement the database using: an array- based list implementation. By using JAVA.Encryption Matrices are commonly used to encrypt data. Here is a simple form such an encryption can take. First, we represent each letter in the alphabet by a number, so let us take = 0, A = 1, B = 2, and so on. Thus, for example, "ABORT MISSION" becomes [1 2 15 18 20 0 13 9 19 19 9 15 14]. To encrypt this coded phrase, we use an invertible matrix of any size with integer entries. For instance, let us take A to be the 3 2 2 x 2 matrix 4 1 We can first arrange the coded sequence of numbers in the form of a matrix with two rows (using zero in the last place if we have an odd number of characters) and then multiply on the left by A. 3 2 1 15 20 13 19 9 14 Encrypted Matrix = 4 1 2 18 0 9. 19 15 0 7 81 60 57 95 57 42 = 6 78 80 61 95 51 56 which we can also write as [7 6 81 78 60 80 57 61 95 95 57 51 42 56]. To decipher the encoded message, multiply the encrypted matrix by A1. The following exercise uses the above matrix A for encoding and decoding. Use the matrix A to encode the phrase "GO…
- Encryption methods, such as the Caesar Cipher encryption, allow us to encrypt and decrypt text using a special key. Another method of encrypting text / passwords is called hashing. Hashing uses special algorithms to 'scramble' the text, which is tougher to be hacked. The hash function can take numbers, letters, and symbols as input, then the function applies one of the special algorithms to output the scrambled text. The longer the output string is, the harder to hack the hashed data. The difference between hashing and the Caesar Cipher encryption is that one cannot 'decrypt' a hashed data to its original text. Since a hashed data cannot be decrypted, a user must enter the original text, which will be hashed by the program. Then the program compares the hashed value with the hashed data stored previously for the original text. A salt is used, at times, to create a random sequence that is added to the original text before using the hashing algorithm. This can help prevent the Brute…Imagine that your best friend's birthday is just around the corner and she has a list of birthday gifts she wants. You want to buy not one but two gifts to her. There is a set of prices of gifts like following (2200, 850, 300, 5000, 1550, 480) Design and implement a way of finding the minimum two prices, sum up them, and display. While finding these numbers, make sure that you are using one searching and one sorting algorithm. You should also write your design in a few sentences as a comment.The following are the operations that you can do using a single linked list. Choose only one operation then create the algorithm and simulate. The attached Rubric will be used in evaluating the activity. 1. Delete a particular node in a single linked list 2. Delete the first node of a single linked list 3. Insertion after a given node of a single linked list 4. Insertion at a given position in a single linked list 5. Insertion before a given node in a single linked list 6. Reverse a single linked list EX: Delete the last node of a single linked list Problem" Deletion of the last node in a single linked list Algorithm" Step 1: if HEAD = NULL Write UNDERFLOW Go to Step 8 Step 2: SET PTR = HEAD Step 3: Repeat Steps 4 and while PTR à NEXT = NULL Step 4: SET PREPPTR = PTR Step 5: SET PTR =PTR à NEXT [End of loop] Step 6: SET PREPTR à NEXT = NULL Step 7: FREE PTR Step 8: EXIT…
- Create a list of N random numbers (Integer) and put them into a list and sort the list using the List’s sort method. Randomly select a number from the list. Find the position of the number in the list using binary search and record the number of comparison that you have to make (c). Then plot c against N for N = 30, 50, 75, 100, 150, 200, 300, 400, and 500. Implement the KMP algorithm from scratch. Test it and plot c against n and m where n is the size of the text and m is the size of the pattern, for different values of n and m. Implement the Boyer Moore algorithm from scratch. Test it and plot c against n and m where n is the size of the text and m is the size of the pattern, for different values of n and m. Implement the Z algorithm from scratch. Test it and plot c against n and m where n is the size of the text and m is the size of the pattern, for different values of n and m.Sudoku is a popular logic puzzle that uses a 9 by 9 array of squares that are organized into 3 by 3 subarrays. The puzzle solver must fill in the squares with the digits 1 to 9 such that no digit is repeated in any row, any column, or any of the nine 3 by 3 subgroups of squares. Initially, some squares are filled in already and cannot be changed. For example, the following might be a starting configuration for a Sudoku puzzle: Create a class SudokuPuzzle.java Download SudokuPuzzle.java that has the attributes • board—a 9 by 9 array of integers that represents the current state of the puzzle, where 0 indicates a blank square • start—a 9 by 9 array of boolean values that indicates which squares in board are given values that cannot be changed and the following methods: • SudokuPuzzle—a constructor that creates an empty puzzle • toString—returns a string representation of the puzzle that can be printed • addInitial(row, col, value)—sets the given square to the given value as an…Algorithm design with sorting. Each of n users spends some time on a social media site. For each i = 1, . . . , n, user i enters the site at time ai and leaves at time bi ≥ ai. You are interested in the question: how many distinct pairs of users are ever on the site at the same time? (Here, the pair (i, j) is the same as the pair (j, i)).Example: Suppose there are 5 users with the following entering and leaving times: Then, the number of distinct pairs of users who are on the site at the same time is five: these pairs are (1, 2), (1, 3), (2, 3), (4, 6), (5, 6). (Drawing the intervals on a number line may make this easier to see).(a) Given input (a1 , b1),(a2 , b2), . . . ,(an, bn) as above in no particular order (i.e., not sorted in any way), describe a straightforward algorithm that takes Θ(n2)-time to compute the number of pairs of users who are ever on the site at the same time, and explain why it takes Θ(n2)-time. [We are expecting pseudocode and a brief justification for its…
- Create four methods named insertionSort(), bubblesort(), mergesort() and quicksort(). Implement the sorting algorithms in the corresponding methods. In the main method, create four arrays a, b, c, d and initialize them with the same values. Pass these four arrays in four different functions. Create four instance variables named insertionSwap, bubbleSwap, countMerge, and countQuickSort and initialize them to 0. In methods insertionSort(), bubblesort() and quicksort(), increment the variables insertionSwap, bubbleSwap, and countQuickSort respectively by one whenever they call the method swap(). In method mergesort(), increment the variable countMerge by one to count the swaps. Use method swap() to swap the values.Implement three sorting algorithms – mergesort, quicksort, and heapsort in java language and investigate their performance on arrays of sizes n = 102, 103, 104, 105, and 106. For each of these sizes consider: randomly generated files of integers in the range [1..n]. increasing files of integers 1, 2, ..., n. decreasing files of integers n, n − 1, ..., 1.Can you ask with the python software language? A 2D matrix can be represented as a list and a column count value in Python. For example, the 3x3 matrix 1 2 3 4 5 6 7 8 9 can be row-wise represented as ([1,2,3,4,5,6,7,8,9], 3), where the number 3 represents the number of columns in the matrix. Similarly, 1 3 5 2 4 6 becomes ([1,3,5,2,4,6], 3). A submatrix can be defined as an (l,r,t,b) tuple, where l and r are left and right column indices, and t and b are top and bottom row indices (all inclusive). Write a function that takes a tuple containing the list representing a matrix, and the column count of the matrix, along with another tuple representing a specific submatrix, and returns the list representation of the submatrix along with its column count as a tuple. For example, given submatrix(([1,2,3,4,5,6,7,8,9,10,11,12], 4), (1,2,0,1)) returns: ([2,3,6,7], 2) def submatrix(matrix, indices):