Q.No.5. 50 2 a) Find the shortest path from source node 1 to every other node using suitable Graph Algorithm 10 10 30 20 100 b) Write the following string with your information: 60 string="your fullName(RUWISH ZAHOOR) 19-arid-1149"
Q: Find the minimum node of a BST. Us
A: According to the question we need to find the minimum node of a BST. Use either a recursive or…
Q: Celebrity problem A celebrity among a group of n people is a person who knows nobody but is known by…
A: ANS: - Option(c) is correct. This problem can be solved by Decrease-by-a-constant algorithm.
Q: a d g Given the tree above, show the order of the nodes visited using recursive pre-order traversal.
A: Answer: Pre- order: It basically means visiting each node at once. Pre-order traversal is one of…
Q: RECURSIVELY calculate the height of a tree. RECURSIVELY calculate the level of a Node in a tree.
A: Actually, python is a easiest programming language. It is a dynamically typed programming language.
Q: You are required to provide the following: i) Construct and draw a binary search tree with the…
A: i) Construct and draw a binary search tree with the values or…
Q: Draw the binary expression trees for the following: e) (2a + 5b) ^ 3 * (x - 7y) ^ 4 f) Evaluate…
A: Expression tree gives an overview of how the expression would be evaluated. The expression at the…
Q: Tree Traversal Use the following tree for the traversals in the next four question parts. Just list…
A: Tree:- a print the tree preorder Depth first traversalSolutionPreorder→Root→Left→RightAccording…
Q: A co-worker emails you and said she developed a recursive version for doing search in a binary…
A: A binary search tree (BST) is a data structure in which left subtree node values are less than its…
Q: DESIGN & ALGORITHM Write an efficient recursive algorithm that takes a sentence, starting index and…
A: Given: To write an efficient recursive algorithm that takes a sentence, starting index, and ending…
Q: The Paper Tree store wants a program that calculates and displays the number of single rolls of…
A: Given :- The Paper Tree store wants a program that calculates and displays the number of single…
Q: The bakery and customers are vertices and all of them are connected (there is no pair of vertices…
A: A life cycle is a multiple stages between order placement and delivery. The physical movement of…
Q: Given the following graph, implement and run the Bellman-Ford algorithm using vertex ? as the…
A: The code for the above given algorithm is given below. No mathematical explanations are given, c++is…
Q: HW 3 (due 2/15) draw the graph below with 2 self-intersections
A: Solution: If a feature intersect itself at a point and continue by crossing itself, it is…
Q: : the left pointer of the node storing 50 points to the node stor espond to the direction they are…
A: Step by step with explanation is given below
Q: The equation of a parabola can be expressed in either standard form (y = ax? + bx + c) or vertex…
A: Take 3 variables for the user input. Input the values. Take 2 variables for the value of h and k.…
Q: (g) (h Assume the above tree is a binary search tree, a) [5pt] Show the tree after removing node h;…
A: In binary search tree, each left child is less then the parent node and each right child is greater…
Q: Perform a tree like dry run on recursive fibonacii series while n=10, also find out recursive…
A: here we write a code for fibonacci series and tree :
Q: Q} Solve the below programming problem using Python Tyrion is learning game theory to impress the…
A: Tyrion is learning game theory to impress the queen. Lord Varys wanted to test the learning of…
Q: Question Write the following string with your information: string="muhammad bilal 19-arid-825" Now…
A: Given String : string = muhammad bilal 19-arid-825 To find : Huffman Tree Generated Codes from…
Q: Write a Node.js program that uses the quadratic formula to solve for the two values of x, given a =…
A: Formula for quadratic :
Q: Using the recursive algorithm design technique, design an algorithm to determine if a string is a…
A: Question 1. Using the recursive algorithm design technique, design an algorithm to determine if a…
Q: Recursive Balanced Deletion In this assignment you should: • Create a tree with 20 nodes that have…
A: Answer: I have done code and also I have attached code and code screenshot as well as output
Q: A B D E F G 17. The root node is 18. Three nodes that are siblings are and 19. The terminal nodes…
A: 17.The root node is A. 18.Three nodes that are siblings are B,C and D. 19.The terminal nodes are…
Q: Q} Solve the below programming problem using Python Tyrion is learning game theory to impress the…
A: Tyrion is learning game theory to impress the queen. Lord Varys wanted to test the learning of…
Q: Manually create a binary search tree from the following list 32 89 72 56 54 20 14 21 18
A: I have given an answer in step 2.
Q: 4. 1 3 1 (7 4 3 2 2 8 2 5 1 2 2 4 Create adjacency list for the graph above. 2. 3.
A: Adjacency list and the BFS algorithm for the given graph
Q: 1. Draw the binary expression trees for the following: a) 4 * (5 - 9) + 9 * -1 * (3 +5-2) b) Y * (a
A: As per the answering guidelines solving the first 3 sub question Expression tree gives an overview…
Q: 10. Draw the expression tree with this postfix form (% is modulo operation) wpy/+ma+xb%*+
A: First, let's convert postfix to infix. Then we will draw the expression tree. Input String…
Q: Write a recursive function named RecursiveSum that, given a positive number n (n> 0), returns the…
A: def RecursiveSum(n): if n <= 1: return n return n + RecursiveSum(n - 1) # Driver…
Q: A recursive function could be denoted as below: T(m) =T () +1 Prove that T(n) = 0(lgn)| Note [x] is…
A: using the master method: to use the master method, we simply determine which case of the master…
Q: 6. Given the algebraic expression below: a e+ b-c a) Draw the Expression tree. b) Get the infix,…
A:
Q: 4. programming assignment (optional) Write a program to find the solution from Arad to Bucharest…
A: Answer: I have given answer in handwritten format
Q: please complete the following in JAVA Implement the graph ADT using the adjacency list…
A: According to the information given:- We have to use adjacency list structure and adjacency matrix by…
Q: Write a C++ code to insert the following information in the Binary Search Tree: {Paris, London,…
A: To execute a program written in high level language must be translated into machine understandable…
Q: Recursive Balanced Deletion In this assignment you should: • Create a tree with 20 nodes that have…
A: Please find the answer below:
Q: 1. Refer to the following equation. ly – 51 3 V5x i) Draw an expression tree for the equation. ii)…
A: Given equation is written as, 1*y-5*I/5*x*e*e*e. This is simplified equation to represent in to…
Q: 2. Consider the graph below. Write a program that outputs the shortest distance from node 0 to every…
A: Consider the graph below. Write a program that outputs that shortest distance from node 0 to every…
Q: A recursive function could be denoted as below: T(n) = T (|) +1 Prove that T(n) = 0(lgn) Note [x] is…
A: This question is from the subject Design & Analysis of algorithm. To solve this equation we have…
Q: Give Recursive Formulations describing path length and height in general trees.
A: 1) The maximum number of nodes at level ‘l’ of a binary tree is 2^l For root, l = 0, number of…
Q: Machine Problem 1 Given the following list of numbers, perform the following operations 63, 52, 10,…
A: Ans: Code: L = [63,52,10,42,32,17,60,45,47,39,71,55,41,95,70,48,42,32,13,35]largest = L[0]smallest =…
Q: T(n) = + 0(n) 3 Find the upper bound of this recurrence equation using O the master method (ii) the…
A: Master method: T(n) = a T( n/b ) + O( nk log p n ) where a>=1, b>1, k>=0 and p is a real…
Q: A heuristic is a way of trying (a) To discover something or an idea embedded in a program (b) To…
A: Question. A heuristic is a way of trying (a) To discover something or an idea embedded in a program…
Q: Q} Solve the below programming problem using Python Tyrion is learning game theory to impress the…
A: n=int(input())arr=list(map(int,input().split()))brr=list(map(int,input().split()))from collections…
Q: Develop a recursive algorithm that returns the number of nodes in a binary tree with root r.
A: The solution to the given problem is below.
Q: Input: 20 15 7 Solve question 4 Explanation: summing up every left leaf in the tree gives us: 9 + 15…
A: Solution to the given question: Approach: In a binary tree traverse every node from root to leaf and…
Q: uild the d table for the following graph if you use the breadth first search and start from node…
A: The d table is the traversal table for traversing different nodes in breadth first search. In our…
Q: Q2) Draw program graph for the following code segment then calculate the cyclomatic complexity of…
A: Our task:
Solve all parts and also make a huff huffing Huffman tree and generate code in part B take Name= RUWISH ZAHOOR
Step by step
Solved in 2 steps with 5 images
- #include "pqueue.h" #include <assert.h> #include "string.h" #include <stdlib.h> typedef char *string; typedef double priority; //priority here is double //There are some errors to be improved. I have already highlighted out. If there is any other errors, please tell points out typedef struct node { string data; priority prior; struct node* next; } NodeT; typedef struct PriorityQueueRepr{ NodeT* top; int element; //number of element in queue }PriorityQueueRepr; pqueue pqueue_create() { pqueue pq = (pqueue)malloc(sizeof(PriorityQueueRepr)); if (pq == NULL) { return NULL; } pq->element = 0; pq->top = NULL; return pq; } void pqueue_destroy(pqueue pq) { while (!pqueue_empty(pq)) { string s = pqueue_leave(pq); free(s); } free(pq); } void pqueue_join(pqueue pq, string dat, priority prio) { NodeT* newNode = (NodeT*)malloc(sizeof(NodeT)); newNode->data = (string)malloc(strlen(dat) + 1); //error is…String Pair // Problem Description // One person hands over the list of digits to Mr. String, But Mr. String understands only strings. Within strings also he understands only vowels. Mr. String needs your help to find the total number of pairs which add up to a certain digit D. // The rules to calculate digit D are as follow // Take all digits and convert them into their textual representation // Next, sum up the number of vowels i.e. {a, e, i, o, u} from all textual representation // This sum is digit D // Now, once digit D is known find out all unordered pairs of numbers in input whose sum is equal to D. Refer example section for better understanding. // Constraints // 1 <= N <= 100 // 1 <= value of each element in second line of input <= 100 // Number 100, if and when it appears in input should be converted to textual representation as hundred and not as one hundred. Hence number…Edef reverse_sentence (s: str) -> str: Given a sentence , we define a word within to be a continuous sequence of characters in that starts with a capital letter and ends before the next capital letter in the string or at the end of the string, whichever comes first. A word can include a mixture of punctuation and spaces. This means that in the string 'ATest string!', there are in fact only two words: 'A' and 'Test string!'. Again, keep in mind that words start with a capital letter and continue until the next capital letter or the end of the string, which is why we consider 'Test string!' as one word. This function will reverse each word found in the string, and return a new string with the reversed words, as illustrated in the doctest below. >>> reverse_sentence('ATest string!') 'A!gnirts tseT' return
- Q4: Colouring Book Having spent the last couple of hours grading assignments, I decide it’s time for a break. I take out my favourite colouring book, turn to a random page I haven’t coloured in yet, and lay it on my desk. I then take out all my n crayons and line them up on the desk (it’s a very long desk). The colour of the ith crayon is a string c[i] (e.g. "blue"). Many of the crayons have the same colour. In fact, no matter how many crayons I have, there are at most 30 distinct colours amongst them. To start colouring, I always take a sublist (see Q1 for a definition) of the crayons laid on the desk and put away the rest (too many options can be overwhelming and can lead to indecision). I take a look at the line art in front of me and wonder, “How many different colours do I need to make this look great? One? Two? Maybe three?”. Now you understand my dilemma and are fully aware of my indecision. You kindly decide to help me out by telling me for every number k, if I were to use…• get_tokens_from_equation(line): Takes one string as input that contains any combination of digits from 0-9 and the following mathematical symbols: + - x / = ^ (O The string does not have to correspond to a valid mathematical equation. For example, '4-3=0' and '4xx5=(8' could be valid inputs to this function. The function will translate the string into a list of tokens. A token is a single non-negative number (of any length) or a single mathematical symbol. Numbers should be added to the list as integers, and symbols as strings. The tokens in the list should be in the same order as the numbers/symbols appear in the string. For example, given the string '52-2=50', the function should return the list [52, '-', 50]. >>> get_tokens_from_equation('4=3') [4, '=', 3] >>> get_tokens_from_equation('6-5=15^4/2') [6, '-', 5, '=', 15, '^', 4, '/', 2] >>> get_tokens_from_equation('288/24x6=18x13x8') [288, '/', 24, 'x', 6, '=', 18, 'x', 13, 'x', 8]Q3. a) Construct a DFA that accepts all strings over {a,b} containing bba as a substring. b) Minimize the following DFA. q3 a b qo
- Based on coding below, help me fix all the error until the program can be run properly and neatly #include <iostream>#include <iomanip>#include <ctype.h>#include <string> using namespace std; struct nodeBankAccount{string bank_acc_name;string bank_acc_num;double bank_acc_bal; nodeBankAccount*link;}; nodeBankAccount *head, *rear;nodeBankAccount *current;nodeBankAccount *newNode;nodeBankAccount *deleteBank;nodeBankAccount *previous;nodeBankAccount *found; void addBankAccount(){char answer;int insertOption; do{newNode = new nodeBankAccount; cout << "Fill in the details below" << endl;cout << "Bank Account Name: ";cin>>newNode->bank_acc_name;cout << "Bank Account Number: ";cin>>newNode->bank_acc_num;cout << "Bank Account Balance: " << "RM ";cin>>newNode->bank_acc_bal;newNode->link = NULL; if(head == NULL){head = newNode;}else{cout<<"Press 1 to insert the new record at front of the…public static String pancakeScramble(String text) This nifty little problem is taken from the excellent Wolfram Challenges problem site where you can also see examples of what the result should be for various arguments. Given a text string, construct a new string by reversing its first two characters, then reversing the first three characters of that, and so on, until the last round where you reverse your entire current stringa) Write a program that asks user to enter number of vertices in an undirected graph and then the adjacency matrix representing the undirected graph. The program, then, must display whether the given graph is connected or not. You will find two sample runs of the program below. Sample 1 Sample 2 Enter number of vertices: 3 Enter number of vertices: 3 Enter adjacency matrix: 0 1 1 1 0 0 1 0 0 Enter adjacency matrix: 0 1 0 1 0 0 0 0 0 The graph is connected. The graph is not connected.
- a) Write a program that asks user to enter number of vertices in a directed graph and then the adjacency matrix representing the directed graph. The program, then, must display the node with the highest outdegree. Assume that nodes are named as 0, 1, 2 and so on. You will find a sample run of the program below. Enter number of vertices: 4 Enter adjacency matrix: 0 1 1 1 0 0 0 0 0 0 0 0 0 1 1 0 Node with the highest outdegree: 0What input or parameter value impacts the number of times the recursive function will be called. • Give three specific examples of input/parameter values and, for each, state the number of times the recursive function will be called. • Devise a formula with respect to n that describes the number of times the recursive function will be called, where n is either the value passed or some property of the value passed (e.g. n might be the length of a string of the size of an array).s = "abab" h 55m Left Substrings in s are { 'a', 'b', 'a', 'b', 'ab', 'ba', 'ab', 'aba', 'bab', 'abab'}. By deleting one "a" and one "b", the string becomes "ab" or "ba" and all of its substrings are distinct. This required 17. String Reduction 2 deletions. Given a string, reduce it in such a way that all of its substrings are distinct. To do so, you may delete any characters at any ALL index. What is the minimum number of deletions needed? Function Description Complete the function getMinDeletions in the editor below. Note: A substring is a contiguous group of 1 or more characters within a string. getMinDeletions has the following parameter(s): Example string s: the given string 8 S = "abab" Returns: int: the minimum number of deletions required Substrings in s are { 'a', 'b', 'a', 'b', 'ab', 'ba', 'ab', 'aba', 'bab', 'abab'}. By deleting one "a" and one "b", the string becomes "ab" or "ba" and all of its substrings are distinct. This required Constraints 2 deletions. 10 1sns 105…