Task: Design an algorithm to read the bus rapid transit system routes list and print the number of tickets we need to purchase if we want to visit all places minimal twice. The complexity of the algorithm must be O(V+E). V is the number of places. E-> is the number of transits. PS: Use Tarjan's or Kosaraju's strongly connected component algorithm.
Q: For this computer algorithms problem, you are given an N amount of cents, Then you are being asked…
A: The pseudocode is as follows:-
Q: The weighted, undirected graph below represents a transit system, in which the vertices are train…
A:
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: You, Alice and Bob are working on recursive search algorithms and have been studying a variant of…
A: Bob has heard that trinary search is no more efficient than binary search.
Q: 24. Instead of reading in an entire list N,, N,, ... all at once, some algorithms (depending on the…
A: - We have to give pseudocode for the list value average problem.
Q: Algorithm A4: index(T, P) 1. Initialize i = 0 and max = t – p + 1 / * t and p are respectively…
A: length() is the function used to find the length of string
Q: 1. Consider the following search algorithm for sorted lists: Starting from the first element, the…
A: a)Algorithm PsuedoCode: Step 1: Set i=0 and m =step size or √n Step 2: Compare A[i] with item. If…
Q: You want to design an algorithm, called minMax(A,p,r), that takes an array of integers and indexes…
A: It is mention that our algorithm should be non-recursive and with time complexity of Θ(n). Our…
Q: You are to create a program that enables you to measure the execution times of various sorting…
A: Algorithm: Start the program. Generate a random number of array of size 10000 Perform the bubble…
Q: # Exercise 1. Implement the algorithm covered in lectures that determines if an integer n is prime.…
A: The code and the output is given in step 2.
Q: Input: A set of n movies. A positive integer k. A positive integer q. A function f that takes two…
A: Answer: Given, Set of n movies, positive constant k and q and {X,Y} ∈ n I have written algorithm…
Q: Sudoku is a number-placement puzzle. The objective is to fill a 9 × 9 grid with digits so that each…
A: Start Traverse the given matrix board[][]. Check if each row of the board[][] array stores only…
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: The example on page 190 of the textbook shows the restoring division of dividing 7 by 2. Redo the…
A: Dividend = 15Divisor = 2First the registers are initialized with corresponding values (Q = Dividend,…
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: 6. There are currently several online newspapers in Bangladesh, such as prothom Alo, bdnews24, daily…
A: In order to group a set of data possessing similar behaviour we could use clustering. Clustering is…
Q: Write a python program to implement Breadth first search Traversal.
A: Introduction: Here we are required to create a program in python to implement Breadth first search…
Q: a. List the different sorting algorithms that you learned and describe one of these algorithms. What…
A: There are many sorting algorithms, Selection SortBubble SortInsertion SortMerge SortQuick SortHeap…
Q: 5 def solveMaze ( maze ) : 6 # Creating a 5 *5 2-D list sol = [ [ 0 for j in range (5) ] for i in…
A: /* C++ program to solve Rat in a Maze problem using backtracking */ #include <stdio.h> //…
Q: An artificial intelligence system was design to forecast the financial trading market and predict…
A: All the answers are given below :
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: Answer the following questions relating to sorting a list with 400 distinct items (ie, no repeated…
A: Sorting Algorithm Sorting algorithm is an algorithm which is use to arranging elements in an…
Q: From the following list of bus rapid transit system (one way): Name Route Vacation : A->B->C->D Work…
A: Kosaraju’s algorithm: To find a SCC(strongly connected Components) in a graph KOSARAJU ALGORITHM…
Q: Sequential Money Problem (Coin Row) • Suppose there are n coins lined up side by side on a table;…
A: a) coins should not be picked from the adjacent sides. b) The picked up coins must be maximum…
Q: From the following list of train rapid transit system (one way): School : A->B->C->D Work 1 :…
A: Kosaraju’s algorithm: To find a SCC(strongly connected Components) in a graph KOSARAJU ALGORITHM…
Q: Section A: Multiple Choice Questions Q3: Which one of the following is an approach for a systematic…
A: BACKTRACKING uses trial and error. it is used for solving problems recursively by trying to build a…
Q: Develop and write pseudo code for an algorithm to do following steps: Find the maximum number from…
A: An array is a collection of homogenous elements and we can simply find the maximum or minimum by…
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: Starting from a randomly generated state of the 15-puzzle game…
A: • At each iteration, the hill-climbing search algorithm moves to the best successor of the current…
Q: Write a pseudocode algorithm that sorts a list of n items by dividing it into three sublists of…
A: Given :- Write a pseudocode algorithm that sorts a list of n items by dividing it into three…
Q: Using C++, implement the Probabilistic Sequential Search. INPUT FORMAT Your program must read…
A: Sequential Search is a collection of a stored data items in a list or a linear relationship where…
Q: Make a code snippet for a function (in the coding sense) that accepts as an input a list of size n…
A: Given :- Make a code snippet for a function (in the coding sense) that accepts as an input a list of…
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: Three points P, Q, and R are said to be collinear if they are on a single line. To check whether the…
A: The inputs are the x and y coordinates of three points and the output is statement whether the…
Q: Design a top-down algorithm (based on dynamic programming and recursion; i.e. memory function) for…
A: 1. Create a two-dimensional table with n+1 rows and m+1 columns 2. Initialize the first row and…
Q: 1. Given an integer List nums sorted in non-decreasing order, return an array of the squares of each…
A: According to the Question below the Solution: Output:
Q: Consider the following snippets of code. Then, identify and describe the sorting algorithm used. num…
A: The above program snippet follows the Insertion Sort Algorithm. It is simple and strong sorting…
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: design an algorithm to find all the common elements in two sorted lists of numbers. For example, for…
A:
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: 8. Programming and experiments (Ex.8.2-7) Please write a general program to solve the all-pairs…
A: The question is to write the code for solving the all pair shortest problem for the digraph. Here C…
Q: Using a random number generator, create a list of 500 integers in Python. Perform a benchmark…
A: According to the information given:- We have to follow the instruction to generate 500 integers in…
Q: A & B answers are given below please Answer C part Algorithm – We are taking first element of…
A: Algorithm We are taking first element of array in AComparing A with other elements of array, if A…
Q: BIG-O!! Make a code snippet for a function (in the coding sense) that accepts as an input a list…
A: Here ,We can sort the given list into the sorted order , then we will list all the numbers from 1…
Q: Consider the following algorithms. Each algorithm operates on a list containing n elements, where…
A: Below is the simplified answer to the above listed problem MCQ problem:
AI -
Step by step
Solved in 3 steps with 1 images
- Algorithm problem w/ recurrence: Frying pancakes: a small pan can only hold two pancakes at a time. Each pancake needs to be fried on both sides. Frying one side takes 1 minute, no matter how many pancakes are on the pan. Consider this recursive algorithm: If n <= 2, fry the pancakes or the two pancakes together on each side. If n > 2, fry any two pancakes together on each side and then apply the same process recursively to the remaining n-2 pancakes. a. Set up and solve the recurrence for the amount of time this algorithm needs to fry n pancakes. b. Explain why this algorithm does not fry the pancakes in the minimum time for all n > 0. c. Give a correct recursive algorithm that executes the task in the minimum amount of time. > I was not sure how to start this. I have had trouble with recurrence in the past. Also from the work that I did do, I didn't know how there could be a better algorithm. Thanks in advanceQuestion 2 You are doing the Tour de France and you are given a map with all the n places where you can refill your water bottles. Your bottles fit 2 liters of water with which are enough for m kilometres. Your goal is to stop as few times as possible to refill your bottles, since you care about a good time for the Tour de France. Design an efficient algorithm using dynamic programming, prove its correctness and analysis its run time. Give the one-dimensional array A. And the time complexity of filling your arrayDesign a top-down algorithm (based on dynamic programming and recursion; i.e. memory function) for checking the existence of a winning strategy for the “Rocks” game. Hints: • Give it the name: RocksMF(n,m) where n,m are the number of rocks on the two piles • Use recursion to call the algorithm itself to solve smaller subproblems • Use a global variable for the two-dimensional table
- Weighted Intervals Problem EXAMPLE:Suppose we have the following weighted intervals. start finish weight 11 14 4 10 13 5 9 11 5 11 14 3 8 9 2 To solve the problem, we start out by sorting the intervals by finish time. This gives us the following. start finish weight 8 9 2 9 11 5 10 13 5 11 14 4 11 14 3 Next we calculate the p-values. P(j) = k where interval k is the last interval prior to interval j in the list below which does not conflict with interval j, or P(j) = 0 if all intervals prior to interval j conflict with it. # start finish weight P 1 8 9 2 0 2 9 11 5 1 3 10 13 5 1 4 11 14 3 2 5 11 14 4 2 Finally, we use the formula OPT(j) = max{OPT(j-1), weight(j)+ OPT(P(j))} to fill in the OPT value for each j. (The…Nuts and bolts You are given a collection of n bolts of different widths and n corresponding nuts. You are allowed to try a nut and bolt together, from which you can determine whether the nut is larger than the bolt, smaller than the bolt, or matches the bolt exactly. However, there is no way to compare two nuts together or two bolts together. The problem is to match each bolt to its nut. Design an algorithm for this problem with average-case efficiency in (n log n).Artificial Intelligence (Part - 2) ==================== The Towers of Hanoi is a famous problem for studying recursion incomputer science and searching in artificial intelligence. We start with N discs of varying sizes on a peg (stacked in order according to size), and two empty pegs. We are allowed to move a disc from one peg to another, but we are never allowed to move a larger disc on top of a smaller disc. The goal is to move all the discs to the rightmost peg (see figure). To solve the problem by using search methods, we need first formulate the problem. Supposing there are K pegs and N disk. (2) What is the size of the state space?
- Artificial Intelligence (Part - 1) ==================== The Towers of Hanoi is a famous problem for studying recursion in computer science and searching in artificial intelligence. We start with N discs of varying sizes on a peg (stacked in order according to size), and two empty pegs. We are allowed to move a disc from one peg to another, but we are never allowed to move a larger disc on top of a smaller disc. The goal is to move all the discs to the rightmost peg (see figure). To solve the problem by using search methods, we need first formulate the problem. Supposing there are K pegs and N disk. (1) Propose a state representation for the problem?CodeW For fun X C Solved https://codeworkou... 臺亂 CodeWorkout X272: Recursion Programming Exercise: Is Reverse For function isReverse, write the two missing base case conditions. Given two strings, this function returns true if the two strings are identical, but are in reverse order. Otherwise it returns false. For example, if the inputs are "tac" and "cat", then the function should return true. Examples: isReverse("tac", "cat") -> true Your Answer: 1 public boolean isReverse(String s1, String s2) { 2. if > 3. 4. else if > return true; return false; 5. 6. else { String s1first = String s2last return s1first.equals (s2last) && 51. substring(0, 1); s2, substring(s2.length() 1); 7. 8. 6. isReverse(s1.substring(1), s2.substring(0, s2.length() 1)); { 12} 1:11AM 50°F Clear 12/4/2021Personal project Q5. This question is concerned with the design and analysis of recursive algorithms. You are given a problem statement as shown below. This problem is concerned with performing calculations on a sequence A of real numbers. Whilst this could be done using a conventional loop-based approach, your answer must be developed using a recursive algorithm. No marks will be given if your answer uses loops. FindAverageAndProduct(a1, ...., an) such that n > 1 Input: A sequence of real values A = (a1, ...., an) Output:, A 2-tuple (average, product) containing the average (average) of all the values and the product (product) of all the values of the elements in A. Your recursive algorithm should use a single recursive structure to find the average and product values, and should not use two separate instances of a recursive design. You should not employ any global variables. (a) Produce a pseudo code design for a recursive algorithm to solve this problem. (b) Draw a call-stack…
- Given the following array of numbers: 8 2 3 9 10 1 4 6 7 5 Show what the array looks like after each iteration of the following sorting algorithms: Bubble Selection Insertion Mergesort Only show the array contents with each algorithm. You do not need to show function call instances if recursion is used or write any code. Just show the array at key iterations of the algorithm. You can use your own words to describe them as well for more detail (but do not write any code). Show what the array looks like after each recursive iteration of the Quicksort algorithm.5. Given # > 3 points P₁ = (x₁, y₁), …….‚ P₂ = (x₂‹ Yn) in the coordinate plane, design an algorithm to check whether all the points lie within a triangle with its vertices at three of the points given. (You can either design an algorithm from scratch or reduce the problem to another one with a known algorithm.)Personal project Q5. This question is concerned with the design and analysis of recursive algorithms. You are given a problem statement as shown below. This problem is concerned with performing calculations on a sequence ? of real numbers. Whilst this could be done using a conventional loop-based approach, your answer must be developed using a recursive algorithm. No marks will be given if your answer uses loops. FindAverageAndProduct(a1, ...., an) such that n > 1 Input: A sequence of real values A = (a1, ..., an) Output:, A 2-tuple (average, product) containing the average (average) of all the values and the product (product) of all the values of the elements in A. Your recursive algorithm should use a single recursive structure to find the average and product values, and should not use two separate instances of a recursive design. You should not employ any global variables. (a) Produce a pseudo code design for a recursive algorithm to solve this problem. (b) Draw a call-stack…