Algorithm #2 - Vector Sum Objective: compute the sum of integers 0..N-1 sum = 0 A = list(range(0,N)) for i in range(0,N): sum += A[i] print("sum = ", sum) Algorithm #3 - Indirect Sum Objective: compute the sum of N integers sum = 0 # set accumulator to 0 A = list(range(0,N)) # create an array of length N filled with values 0..N-1 B = [random.randint(0,N-1) for j in A ] # create an array of length N filled with random #s indx = B[0] for i in range(0,N): sum += A[indx] indx = B[indx] print("sum=", sum)
Q: Given: (192.168.25.15) 10 Tasks: a) Determine the octal number equivalent of the given number format…
A: This question comes from Number System which is a paper of Computer Science/ Engineering. Let's…
Q: Write types of Data flow diagram (DFD)
A: Introduction: A data flow diagram is a visual representation of data flow in a system (DFD). DFD can…
Q: What are the logic commands in Assembly language, and how do they work?
A: Assembly languages which refers to the type of low-level programming language which are intended in…
Q: Write a function that takes two queue structures as parameters: original queue and modified queue.…
A: Below I have provided a program for the given question. Also, I have attached a screenshot of the…
Q: Discuss what is CASE tool and its scope.
A: Answer is
Q: Create a UML diagram for the classes described in Question 7 (the Game/Room question). Be sure to…
A: Given classes: Game Room --------------- Fields and Methods of Game class: Fields: List<Room>…
Q: Determine the file structure in which the length of the fields separated by the colon is varied.…
A: The concept here is to identify the file structure in which the length of the fields separated by…
Q: Discuss what is CASE tool and its scope.
A:
Q: Discuss Requirements of a proto typing CASE tool.
A: Please check the solution below
Q: Which of the following users architects the database? Database designer Database administrator…
A: Solution for given question, Which of the following users architects the database? Introduction:…
Q: What is a criterion of a table being in first normal form? All transitive functional…
A: The answer to the question is given below:
Q: What is the effect of adding the instruction EMK;? EMK: X→ E(KMH₁, X) i = 0,1
A: Solution The effect of adding the instruction EMK0 It will allow users to generate personal session…
Q: Which data model(s) introduced the use of a data manipulation language?
A: There are three data models:- Hierarchical - stores data in hierarchy. Uses tree structure.…
Q: Discuss importance of DFDS in a good software design.
A: The answer to the question is given below:
Q: 5. Let the content of register $t1 represent a 2's complement number N. Write a MIPS code fragment…
A: Here is the code and explanation of the above code. See below steps.
Q: What is a public-key certificate?
A: The answer to the question is given below:
Q: Which of the following relational query languages have the same expressive power? A. Relational…
A:
Q: What is software design control.
A:
Q: What is Repeatable and non-Repeatable software development organisation?
A: Software development is the process programmers use to create computer programs. Also known as the…
Q: Implement LDA for feature selection in Python
A: LDA stands for Linear Discriminant Analysis and this can be implemented by using the Scikit Learn…
Q: Discuss what is CASE tool and its scope.
A: CASE (Computer Power-Assisted Software Package Engineering) tool is a general term that generally…
Q: } public int getLegs () { return numLegs; public boolean haswings() { } return haswings; public…
A: Answer:
Q: Indices can speed up query processing, but it's usually a terrible idea to index every attribute,…
A: Query Processing: High-level queries are converted into low-level expressions during query…
Q: What is a pointer? How do you dereference a pointer to get its stored value?
A: What is Variable: Data values are kept in variables as storage. There are other sorts of variables…
Q: In JAVA Write a program that simulates a simple dice game between the computer and the user. When…
A: I have provided JAVA CODE along with OUTPUT SCREENSHOT------------------
Q: ✔ Checkpoint: split Write a method called split that takes a Set of strings as a parameter and…
A: Answer:
Q: a) f(A,B,C,D) = Σm(1,4,5,6,7,9,11,13,15)
A:
Q: What is true about normalization? It increases the chance of data anomalies. It may decrease…
A: In this question we need to choose correct statement related to normalization in databases.
Q: help figuring out this program and typing it in c++
A: Solution- An C++ program is given which prompt the value of current and birth date,month,year from…
Q: What is software model?
A:
Q: Unified Modeling Language (UML) Instructions: Create a UML diagram for a Dog class. You can get some…
A: Uml benefits:- 1. The right decisions are made before you have given a poorly written code. 2.…
Q: What is the difference between an SSL connection and an SSL session?
A:
Q: Consider a very simple symmetric block encryption algorithm in which 32-bits blocks of plaintext are…
A:
Q: Write a function called makemat that will receive two row vectors as input arguments, and from them…
A: MATLAB which refers to the programming platform which are designed specifically for engineers and…
Q: What is a key feature of fifth normal form? A key step in this normal form has every…
A: Database Management System (or DBMS) Essentially nothing more than a computer-based data storage…
Q: IN C++ LIST STL INSERT NUMBERS FROM 14 to 27, THEN REVERSE THE LIST USING C++ STL AND PRINT THE…
A: Solution - An C++ program is given in which C++ List STL insert numbers from 14 to 27 and then…
Q: plot of the function r = 3 cos² (+0 for 0≤ 0 ≤ 2π
A: Solution: Given,
Q: Write a c# program that includes all the code for computing the shortest paths using Dijkstra’s…
A: using System; class Dijkstra { // Searches the vertex having least distance value, from the set of…
Q: Discuss Requirements of a proto typing CASE tool.
A:
Q: • Define a two dimensional list with NxN elements. This list should be filled with random numbers…
A: Below I have provided a program for the given question. Also, I have attached a screenshot of the…
Q: What is the effect of adding the instruction EMK;? EMK: X→ E(KMH₁, X) i = 0,1
A: Answer: We need to write the what will be the effect of adding the instruction EMK. So we will see…
Q: Definition, purpose, and importance of SDG7
A: By 2030, everyone must have access to "cheap, reliable, sustainable, and contemporary energy." This…
Q: eed help creating a conceptual model for Turo, the car rental/sharing company. I also would very…
A: Solution- The conceptual model for Turo, the car rental/sharing company is shown below The entities…
Q: Construct an FA equivalent to the regular expressions: 1) ab + (aa+bb)* b 2) (a+b+c)*+ ab + (a+b)
A: The complete answer is below:
Q: What protocols comprise SSL?
A: Data transit between a web browser and server is secure thanks to Secure Socket Layer (SSL). All…
Q: Discuss and write Monitors in detail.
A: What is Monitor? An electronic output device known as a monitor is also known as a video display…
Q: Given: Task: (11011110)2-(1FE) 16 X (12)8 / 210 Calculate the result of the operations performed on…
A: The complete answer is below:
Q: Create a Python function called triples that takes a string of characters and returns True if there…
A: Python : The Python programming language was created by Guido van Rossum and is an interpreted,…
Q: Discuss importance of DFDS in a good software design.
A: DFDS:-A data Flow Diagram is referred to as DFD. DFD is a representation of data flows through the…
Q: The first function you will write and test is the clean_data function. The function is described in…
A: # function to change the value def clean_data(li, x): # loop over each element in the list…
Write
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
- slecetion sort (python) Selection sort is a sorting algorithm, like Bubble sort which you saw in the previous module. Selection sort works as follows: Selection sort divides the input list into two parts: a sublist of sorted items (left part) and a sublist of still unsorted items (right part). Initially, the sorted sublist is empty and the whole input consists of the unsorted sublist. To fill the sorted sublist, the algorithm computes the (index of) the minimum of the unsorted sublist and swaps the first unsorted element and the minimum element (if the minimum is already the first element, nothing happens). Afterward, the sorted sublist is one bigger. This continues until the unsorted sublist is empty and the entire input is sorted. Example: Sorted sublist Unsorted sublist Least element in unsorted list () (11, 25, 12, 22, 64) 11 (11) (25, 12, 22, 64) 12 (11, 12) (25, 22, 64) 22 (11, 12, 22) (25, 64) 25 (11, 12, 22, 25) (64) 64 (11, 12, 22, 25, 64) () Implement this…Please use python codes and don't copy from previous answers. 3.) Consider the matrix list x = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]. Write a list comprehension to extract the last column of the matrix [3, 6, 9]. Write another list comprehension to create a vector of twice the square of the middle column [8, 50, 128].Implement the following two sorting algorithms in a program called p3.py. Write two separate functions for these algorithms. Both functions must take a list of integers as the input parameter.1) Bogosort: first shuffle the list argument (i.e., randomize the positions of every element) and then check to see if the result is in sorted order. If it is, the algorithm terminates successfully and returns True, but if it is not then the process must be repeated.2) Bozosort: choose two elements in the list at random, swap them, and then check if the result is in sorted order. If it is, the algorithm terminates successfully and returns True, but if it is not then the process must be repeated.Write a main() function and call both sorting functions using the same list as their arguments. The list can be of any size (try a small list first). Does any of your algorithms terminate? If yes, count the number of iterations it uses to sort the list. Does it always use the same number of repetitions? If…
- 35. A particular sorting algorithm takes integer list 10, 6, 8 and incorrectly sorts the list to 6, 10, 8. What is true about the algorithm's correctness for sorting an arbitrary list of three integers? A.The algorithm is correct. B.The algorithm is incorrect. C.The algorithm's correctness is unknown. D.The algorithm only works for 10, 6, 8.1. ax + b = 0, y = aeˣ! a,b ≠ 0a,b are constants number entered by the user. Find (x,y) and determine the quadrant of thecartesian plane. Print (x,y) and write which quadrant (I,II,III or IV). (PYTHON) 2. Write a program that sorts a list in ascending order. Don’t use sort method.Ask user number of list elements (at least 10 elements)Enter all elements from keyboard and printed.Sort your list. (PYTHON)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 list
- Plerase solve with inb 10 min!! I will rate you good for sure!! Please solve in Python Write a function that takes two lists: a list of states (as strings) and a list of corresponding nicknames (also as strings). Your function should return a list of tuples, where each tuple contains the state as its first element, and the corresponding nickname as its second element, in the same order as the inputs. Return an empty list if no nicknames are provided. Note: You can assume that the states list is at most as long as the nicknames list. If there are not enough states to make a tuple you should use 'NO STATE PROVIDED' as a placeholder of the state value. (See the doctests for more examples.) """>>> combine(['NV', 'CA', 'HI'], ['Silver State', 'Golden State', 'Aloha State'])[('NV', 'Silver State'), ('CA', 'Golden State'), ('HI', 'Aloha State')] >>> combine(['NV', 'CA'], ['Silver State', 'Golden State', 'Aloha State'])[('NV', 'Silver State'), ('CA', 'Golden State'), ('NO…Bubble Sort adaptation. Rewrite the following bubblesort algorithm so that in each pass, it “bubbles down” the smallest element to the left end. /*Bubble sort given list into ascending order Input: list a[0...n-1], n: the length of list a Output: list a is rearranged into ascending order BubbleSort (a, n) { //right points to the last element of the "remaining list" //it starts from n-1, after each pass, it decreases by 1 for right=n-1 downto 1: //perform one bubbling pass, bubbling up the largest element to right end for i=0 to right-1: if (a[i]>a[i+1]): swap (a[i], a[i+1]) } Trace the execution of your adapted bubble sort (in Q3) on the following input. Minimally, draw the content of list a after each iteration of the outer-loop. a=[5,3,10,4,2,1] n=6#include <bits/stdc++.h> using namespace std; // Function to return a vector that contains // all the generated letter combinations vector<string> letterCombinationsUtil(const int number[],int n,const string table[]) { // To store the generated letter combinations vector<string> list; queue<string> q; q.push(""); while (!q.empty()) { string s = q.front(); q.pop(); // If complete word is generated // push it in the list if (s.length() == n) { list.push_back(s); } else { // Try all possible letters for current digit // in number[] for (autoletter : table[number[s.length()]]) { q.push(s + letter); } } } // Return the generated list return list; } // Function that creates the mapping and // calls letterCombinationsUtil void letterCombinations(const int number[], int n) { // table[i] stores all characters that // corresponds to ith digit in phone string table[10] = { "0", "1", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };…
- 1. Rewrite the Bubble sort to use recursion. 2. Use the time(0) function to determine how many seconds it takes to sort a vector using the recursive method. 3. Use the time(0) function to determine how many seconds it takes to sort a vector using the non-recursive method described in the videos. Run the sort test on vectors containing random integers. You should sort vectors of the following sizes: 100 elements, 1000 elements, 5,000 elements, 10,000 elements and 50,000 elements. Was the recursive method able to work on vectors of each of those sizes? If not, explain why it errored.1. Rewrite the Bubble sort to use recursion. 2. Use the time(0) function to determine how many seconds it takes to sort a vector using the recursive method. 3. Use the time(0) function to determine how many seconds it takes to sort a vector using the non-recursive method described in the videos. Run the sort test on vectors containing random integers. You should sort vectors of the following sizes: 100 elements, 1000 elements, 5,000 elements, 10,000 elements and 50,000 elements. Was the recursive method able to work on vectors of each of those sizes? If not, explain why it errored. 4. Create a class that will store a vector of planets (See the Planet assignment). Your class will have functions to add a planet, delete a planet and sort the planets. The class must utilize the insertion sort.Implement bubble sort, selection sort iteratively, and recursively. Implement linear search. Familiarize with C++ STL class vector Program Execution: The following example illustrates how your program should work. The program first reads the length of the vector (as 5 in example below), then reads this number of integers, and push them into a vector. The program then reads a command (selection, bubble, rselection, rbubble), and call the corresponding sorting function to sort the vector. The vector after being sorted will be displayed. Note that the user input are underscored. [storm:]$ g++ lab1.cpp -o lab1.exe [ storm:]$ ./lab1.exe 5 74 25 32 99 24 selection 24 25 32 74 99 [storm:]$ ./lab1.exe 317 5 23bubble 5 17 23 General Hints:* Write your main function first. * Incrementally write one function and test it before moving to the next. Please refer to the slides on how to implement these functions. 1. selection: iterative selection sort function bubble: iterative bubble…