15.7 LAB: Sorting user IDs Given code that reads user IDs (until -1), complete the quicksort() and partition() functions to sort the IDs in ascending order using the Quicksort algorithm. Increment the global variable num_calls in quicksort() to keep track of how many times quicksort() is called. The given code outputs num_calls followed by the sorted IDs. Ex: If the input is: kaylasimms julia myron1994 kaylajones -1 the output is: julia kaylajones kaylasimms myron1994
Q: 2. Use set builder notation to describe the following set A={2,4,6,8,10} i) A-13,5,9,17,33,65} v)…
A: In Mathematics, set builder notation is a mathematical notation of describing a set by listing its…
Q: What is the difference between the use of an index-based loop and the use of an iterator with an…
A: ANS: - Index-Based Loop: - It is a structured control abstraction. It traverses through a range of…
Q: In the C++ code for a queue, when you insert an item, which do you do first: insert the item,…
A: Queue is a data structure where it follows FIFO approach where the element that was inserted first…
Q: (Converting Strings to Integers for Calculations) Write a program that inputs six strings t hat…
A: Since you have not mentioned the sample output, so we have provided the output in the most…
Q: 11.16 LAB: Reverse a string Write a recursive function called ReverseString() that takes in a string…
A: Answer
Q: 11. Write code that reproduces the output shown below. In [11]: # Code Here In [12]: # DON'T WRITE…
A: In this question we have to write a python code to generate a array using numpy. Question 11. Write…
Q: 7. Use a property to give a description of each of the following sets { a, e, i,o,u} {2,4,6,8,10 }
A: Set is the collection of distinct elements In set no same element in the set . Set example…
Q: 7.12 Write a program that simulates the control software for a "people mover" system, a set of…
A: The program is given N amount of trains and M amount of stations in a text file; followed by the…
Q: Question 40. Consider the following code chunk: import random x = 0 while (x < 4): x = random.choice…
A: Given:
Q: 2 4 What are the values of the (B, C, D, E, and F) arrays after b) Let A = 2 Lo-1 4 -3 execution of…
A: Code: A=[1 -1 3 0;2 4 1 -3;2 1 4 2;0 -1 -3 5] %i%Sets all the negative numbers to 1 and positive…
Q: Writing append and search methods (singly-linked list) Given main.py and a Node class in Node.py,…
A: Search method def search(self,value): temp=self.head pos=1 while(temp):…
Q: 4. Consider the following declaration. int list[] = {3, 8, 10, 13, 6, 11}; a. Write a C++ code that…
A: please do upvote for my efforts thanks! answer: a) #include <bits/stdc++.h>using namespace…
Q: The code of a sequential search function is shown on textbook page 60. In fact, if the list is…
A: """Program to seach target element in list""" #function to search target in listdef…
Q: .13 Define a method named swapValues that takes an array of four integers as a parameter, swaps…
A: Java code to swap elements at index 0 and 1, 2, and 3 are given below with an output. Algorithm:…
Q: Write the remove_evens() function, which receives a list of integers as a parameter and returns a…
A: Use another list in the function where we append only the odd numbers to the list and return the…
Q: // Program 4.7.1 #include using namespace std; double getAverage(int *arr, int size); // function…
A: In this question array name balance store 5 elements and getAverage function find average of…
Q: 6. Write and test a function shuffle(myList) that scrambles a list into a random order, like…
A: The answer is given below.
Q: 8.11 (Random Sentences) Write a program that uses random-number generation to create sen- should…
A: Solving the given problem by using C++ as here no programming language is specified. The below…
Q: Find the mistakes in the following code. Not all lines contain mistakes. Each line depends on the…
A: Mistakes in the given code: In 2, the pointer variable assigned with a value 5 without “*”2: *p = 5;…
Q: (7) Implement the ShortenSpace() function. ShortenSpace() has a string parameter and updates the…
A: Programming language is missing in the question. The below program is provided in C language. If you…
Q: Python 3.7.4 Write a statement that associates d with an empty dictionary.
A: Following is the code statement to associate d with empty dictionary:A dictionary is an unordered,…
Q: 6. Write a C++ program to check whether the sequence of the numbers in a given array is a…
A: I give the code in c++ along with output screenshot and code screenshot
Q: 8.17 LAB: Inventory (linked lists: insert at the front of a list) C++ Given main(), define an…
A: Actually, the code has given below:
Q: Given a main() that reads user IDs (until -1), complete the Quicksort() and Partition() functions to…
A: import java.util.Scanner;import java.util.ArrayList;public class UserIDSorting {// TODO: Write the…
Q: Python 3.7.4 Write a statement that associates d with a one-entry dictionary that maps the str…
A: The required statement is as given below:d = {'answer':42}
Q: 5.a. Write a program using pointers to read in an array of integers and print its elements in…
A: Program in C: #include<stdio.h>#include<conio.h>#define MAX 30 void main() { int size,…
Q: 9.02) A palindrome consists of a word or deblanked, un-punctuated phrase that is spelled exactly the…
A: Given:- IN C LANGUAGE it must ignore spaces and ohter symbols. when checking the input the code must…
Q: T/F 10) We can define a list of int values recursively as: a list_item, followed by a comma,…
A: In a recursion, there should be a base case, which results in the termination of a recursive…
Q: isplaying a Sentence with Its Words Reversed
A: Program structure Include header files <stdio.h> and <string.h> to perform input/output…
Q: Consider an 1-d array of type int and a pointer pointing variable pointing to the 2nd item of the…
A: Q: Code the given problem
Q: ET-580 Object-Oriented Progzanning. 5. rowbridge 2020 b) Create a function that returns the count…
A: In the main method – Declare a variable to input the number. Take a number as an input. Call the…
Q: 4. Write a function remove_repetition that takes any list 1st and returns a new list with the same…
A: (1) Create an empty list called "res" (2)Loop through each element in the list (3) If the element is…
Q: 6. Write a swap function, that swaps the values of two variables in main, but use pointers instead…
A: As per our policy, "Since you have asked multiple questions, we will solve the first question for…
Q: 5.2 Write a function in Javascript to take input a matrix as a parameter and returns whether the…
A: As per the given question we need to write a function : Input parameter : A matrix To check if the…
Q: Q1 / Write a program in C++ that reads a binary array of dimensions (383) containing integers, and…
A: Given: Q1 / Write a program in C++ that reads a binary array of dimensions (383) containing…
Q: Using Dr-Racket, what is the purpose of the number function?
A: Given function (define (number n)(local [(define (abstract int)(* int 11))] (build-list n…
Q: 13.5 LAB: Zip code and population (class templates) Define a class StatePair with two template…
A: C++ code: main.cpp #include<iostream>#include <fstream>#include <vector>#include…
Q: What is wrong with following code: T *p = new T[10]; delete p;
A: vi. What is wrong with following code: T *p = new T[10];delete p;
Q: 5. Consider the following high-level code snippet. Assume that the base addresses of array1 and…
A: Each array contains 100 integers. So we reserve memory for 100*4=400 bytes
Q: 22.3 LAB: Remove all even numbers from a list Write the remove_evens() function, which receives a…
A: Remove the even numbers of the given list of array. [1,2,3,4,5,6,7,8,9]
Q: PLEASE USE JAVA Equivalence Class Software Testing Question: A function foo has k integers…
A: Given The answer is given below
Q: 3.40 Implement function partition() that splits a list of soccer players into two groups. More…
A: This is your solution code
Q: Assume that the node of a linked list is in the usual info-link form with the info of the type int.…
A: Program: //include header files #include <iostream> #include <string> using namespace…
Q: 2. (a) Write an algorithm in pseudo-code that • takes as input an array A[1...n], and an item M…
A: Below is the complete solution with C program taking an array A and element M and returns the last…
Q: 13.5 LAB: Zip code and population (class templates) Define a class StatePair with two template…
A: The answer is given in the following steps for your reference.
Q: 7.12 Write a program that simulates the control software for a "people mover" system, a set of…
A: In this program given thar we have N number of trains and M number of stations in a text file;…
Q: main.cpp 5. Sorting My Todo List 1 #include by CodeChum Admin 2 using namespace std; 3 Thanks to…
A:
Q: code in C# to perform an update
A: Steps to create the program: Declare an array with the original marks. Iterate over the length of…
Q: Implement the build_dictionary() function to build a word frequency dictionary from a list of words
A: Iterate over the given list and check whether each word is present or not
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- **11.18** Java Solve (ArrayList of Character) Using the following header, create a method that produces an array list of characters from a string: toCharacterArray public static ArrayListCharacter> (String s) ToCharacterArray("abc"), for example, returns an array list containing the characters 'a', 'b', and 'c'.8.26 LAB: Word frequencies (dictionaries) Implement the build_dictionary() function to build a word frequency dictionary from a list of words. Ex: If the words list is: ["hey", "hi", "Mark", "hi", "mark"] the dictionary returned from calling build_dictionary(words) is: {'hey': 1, 'hi': 2, 'Mark': 1, 'mark': 1} Ex: If the words list is: ["zyBooks", "now", "zyBooks", "later", "zyBooks", "forever"] the dictionary returned from calling build_dictionary(words) is: {'zyBooks': 3, 'now': 1, 'later': 1, 'forever': 1} The main code builds the word list from an input string, calls build_dictionary() to build the dictionary, and displays the dictionary sorted by key value. Ex: If the input is: hey hi Mark hi mark the output is: Mark: 1 hey: 1 hi: 2 mark: 1 Use Python, please.6.28 In Python, Write a program that replaces words in a sentence. The input begins with word replacement pairs (original and replacement). The next line of input is the sentence where any word on the original list is replaced. Ex: If the input is: automobile car manufacturer maker children kids The automobile manufacturer recommends car seats for children if the automobile doesn't already have one. 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.
- 13.14 LAB: Library book sorting Two sorted lists have been created, one implemented using a linked list (LinkedListLibrary linkedListLibrary) and the other implemented using the built-in ArrayList class (ArrayListLibrary arrayListLibrary). Each list contains 100 books (title, ISBN number, author), sorted in ascending order by ISBN number. Complete main() by inserting a new book into each list using the respective LinkedListLibrary and ArrayListLibrary insertSorted() methods and outputting the number of operations the computer must perform to insert the new book. Each insertSorted() returns the number of operations the computer performs. Ex: If the input is: The Catcher in the Rye 9787543321724 J.D. Salinger the output is: Number of linked list operations: 1 Number of ArrayList operations: 1 Which list do you think will require the most operations? Why?13.14 LAB: Library book sorting Two sorted lists have been created, one implemented using a linked list (LinkedListLibrary linkedListLibrary) and the other implemented using the built-in ArrayList class (ArrayListLibrary arrayListLibrary). Each list contains 100 books (title, ISBN number, author), sorted in ascending order by ISBN number. Complete main() by inserting a new book into each list using the respective LinkedListLibrary and ArrayListLibrary insertSorted() methods and outputting the number of operations the computer must perform to insert the new book. Each insertSorted() returns the number of operations the computer performs. Ex: If the input is: The Catcher in the Rye 9787543321724 J.D. Salinger the output is: Number of linked list operations: 1 Number of ArrayList operations: 1 Which list do you think will require the most operations? Why?…15.11 LAB: Sorting user IDs C++ Given a main() that reads user IDs (until -1), complete the Quicksort() and Partition() functions to sort the IDs in ascending order using the Quicksort algorithm, and output the sorted IDs one per line. Ex. If the input is: kaylasimms julia myron1994 kaylajones -1 the output is: julia kaylajones kaylasimms myron1994 I can only change the //TODO #include <string>#include <vector>#include <iostream> using namespace std; // TODO: Write the partitioning algorithm - pick the middle element as the// pivot, compare the values using two index variables l and h (low and high),// initialized to the left and right sides of the current elements being sorted,// and determine if a swap is necessaryint Partition(vector<string> &userIDs, int i, int k) { } // TODO: Write the quicksort algorithm that recursively sorts the low and// high partitionsvoid Quicksort(vector<string> &userIDs, int i, int k) { } int main(int argc,…
- 6.28 In Python, Write a program that replaces words in a sentence. The input begins with word replacement pairs (original and replacement). The next line of input is the sentence where any word on the original list is replaced. Ex: If the input is: automobile car manufacturer maker children kids The automobile manufacturer recommends car seats for children if the automobile doesn't already have one. 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. END WITH A NEW LINE15.11 LAB: Sorting user IDs C++ Given a main() that reads user IDs (until -1), complete the Quicksort() and Partition() functions to sort the IDs in ascending order using the Quicksort algorithm, and output the sorted IDs one per line. Ex. If the input is: kaylasimms julia myron1994 kaylajones -1 the output is: julia kaylajones kaylasimms myron1994 #include <string>#include <vector>#include <iostream> using namespace std; // TODO: Write the partitioning algorithm - pick the middle element as the// pivot, compare the values using two index variables l and h (low and high),// initialized to the left and right sides of the current elements being sorted,// and determine if a swap is necessaryint Partition(vector<string> &userIDs, int i, int k) { } // TODO: Write the quicksort algorithm that recursively sorts the low and// high partitionsvoid Quicksort(vector<string> &userIDs, int i, int k) { } int main(int argc, char* argv[])…8.13 LAB: Library book sorting Two sorted lists have been created, one implemented using a linked list (LinkedListLibrary linkedListLibrary) and the other implemented using the built-in Vector class (VectorLibrary vectorLibrary). Each list contains 100 books (title, ISBN number, author), sorted in ascending order by ISBN number. Complete main() by inserting a new book into each list using the respective LinkedListLibrary and VectorLibrary InsertSorted() methods and outputting the number of operations the computer must perform to insert the new book. Each InsertSorted() returns the number of operations the computer performs. Ex: If the input is: The Catcher in the Rye 9787543321724 J.D. Salinger the output is: Number of linked list operations: 1 Number of vector operations: 1 Which list do you think will require the most operations? Why? Main.cpp: #include "LinkedListLibrary.h"#include "VectorLibrary.h"#include "BookNode.h"#include "Book.h"#include <fstream>#include…
- 6.3.25 Develop a pair of TOY functions that implement a pushdown stack, passing the values to push and pop in R[B] and the address of the stack in R[A]. This question was taken from Computer science an interdisciplinary approach. NOTE: I don't need an answer with java or high-level language code but the TOY code as described in the book which has a specific set of opcodes in hexadecimal for eg 18AB; means that adding results of R[A] and R[B] and store them in R[8]. and so on...21.2 Project 1 (Checkpoint B): DNA Write the full C++ code for this Implement the following functions: /** * Reads from standard input a list of Short Tandem Repeat (STRs) * and their known counts for several individuals * * @param nameSTRs the STRs (eg. AGAT, AATG, TATC) * @param nameIndividuals the names of individuals (eg. Alice, Bob, Charlie) * @param STRcounts the count of the longest consecutive occurrences of each STR in the DNA sequence for each individual * @pre nameSTRs, nameIndividuals, and nameSTRs are empty * @post nameSTRs, nameIndividuals and STRcounts are populated with data read from stdin **/ void readData(vector<string>& nameSTRs, vector<string>& nameIndividuals, vector<vector<int>>& STRcounts) For example, consider the input: 3 AGAT AATG TATC Alice 5 2 8 Bob 3 7 4 Charlie 6 1 5 In the first line, the number of STRs followed by the names of those STRs, which will be populated into the vector nameSTRs. The remaining lines contain…8) Write a Java code segment to sum (total) only the positive (greater than zero) values contained in a one dimensional array of integers named intArr that has already been filled with a variety of values (from -250 to +250, for example) and print the final total of the positive contents with an appropriate message.