6. Binary Search [Problem description] Given the grade list of students in a class and your grade, find your position of Ken in the list according to his grade by the binary search method. The grade list is an ordered list and sorted ascendingly. The maximal length of the grade list is 100. [Basic requirements] Use the binary search method. [Example] What you need to show in the terminal (the back part is outputted by you and the blue part is inputted by the user, i. e., teacher) : Please input the student grade list: Alice:73 Bob: 80 Mark:82 David:84 Jenny: 89 Maria:93 Please input the grade of Ken: 06 The position of Ken is:
Q: Group Anagrams when given an array of strings in C++ Example: Input: ["eat", "tea", "tan", "ate",…
A: C++ program to group anagram with a given array of strings.
Q: Programming Practice Problem in C (Arrays and Strings): Implement substringList() that will produce…
A: #Code #include <stdio.h>#include <string.h>//main functionint main(){//initialize…
Q: Map and lambda problem 2: Input x = [1,2,3,5,7,8,9,10,11] Find the amount of even numbers in list.…
A: Step 1) Take given input list [1,2,3,5,7,8,9,10,11] even numbers condition is x%2==0 Print sum of…
Q: Part 1– Median of two sorted arrays Implement a C function, named median, that receives two arrays…
A: // A Simple Merge based O(n) solution to find// median of two sorted arrays#include <stdio.h>…
Q: Data Structure Using C++ (Recursion) Need C++ Code ::: This is a one question >>> 6 function in…
A: please see the next step for solution
Q: Does using array list better than linked list if your concern is doing random access elements and…
A: Here is the explanation about what should be chosen.
Q: Write the following recursive functions once for an array and once for simply linked list (as member…
A: Actually, program is an executable software that runs on a computer.
Q: Write the following recursive functions once for an array and once for simply linked list (as member…
A: Here is the solution which is mentioned below:
Q: Problem Statement Given a m by n grid of letters, (1 < m, n < 50), and a list of words, find the…
A: ANS IS GIVEN BELOW
Q: Write a recursive function flatten that takes a list as an argument and returns the flat version of…
A: Here is the detailed explanation of the solution
Q: Graph Data Structure - Adjacency Matrix Implement a Program in C++ that does the following: 1) Asks…
A: Note: As you have asked a mulitpart question, we will solve the first three parts for you. If you…
Q: Lab Assignment Question 1- Program in C++ to take input size of array from user and show how to…
A: In C++, cin function is used to take input a variable and syntax of declaration of array is: int…
Q: The programming language: C++ The union of two ordered lists (Sequential linear list)[the solution…
A: The program is written in C++. Please find the source code and output in the following steps.
Q: Description Write the code for the function find_sub which takes as parameter a list input_list and…
A: Q: Find maximum sum sublist
Q: a) Write the sequential version in C++ (refer the sequential algorithm below). Show the proof of…
A: Make a function sequential with parameters as: a : 2d matrix b: vector of size n c: vector of size m
Q: 4. Write a function, "outdegree", of two arguments, a node and the graph, which returns the…
A: Code: # Out degree for a vertex is the count# of direct paths from that vertex to other verticesdef…
Q: Description Write the code for the function find_sub which takes as parameter a list input_list and…
A: Here is the required Python code. main.py def read_list(param): p = param.replace(',', '')…
Q: 5. Most languages do not have the flexible built-in list (array) operations that Python has. Write…
A: Note: Answering the first three subparts as per the guidance. Task : Write the algorithm and…
Q: Complete C++ source code for Write a complete C++ program to help the manufacturer determine the…
A: Code: #include <iostream> #include <fstream> using namespace std; //fucntion…
Q: [Problem description] Give the union of two ordered lists. The maximal number of elements in an…
A: I am using python language for union of two ordered lists. According to example given in question,…
Q: length using Write a C++ function to swap the contents of two arrays with the same pointers.
A: #include <iostream> #define MAX_SIZE 100 // Maximum array size /* Function declarations */…
Q: d. Apply the Binary Search Algorithm, as performed during class, show all the necessary steps. Use…
A: Check the algorithm steps below.
Q: Part 2 – Sudoko The famous Sudoko game is played on a grid of 9 × 9. Each empty square in this grid…
A: Coded using C language.
Q: Modify the recursive Fibonacci function to employ the memoization technique discussed in this…
A: Code with output given below: Approach is to make the dictionary global and insert result in it when…
Q: -) Define a function printList(0 with one parameter p. 1) This function prints all values in the…
A: The program to print List using a function
Q: 6.27 LAB: Multiples of ten in a list Write a program that reads a list of integers, and outputs…
A: def is_list_mult10(my_list): count = 0 n = len(my_list) for i in range(0, n): if…
Q: Use pointers to write a C++ function that finds the largest element in an array of integers. Use…
A: program:- #include <bits/stdc++.h> using namespace std; int largest(int *arr, int n) { int…
Q: Please note global variables are not allowed to use in this assignment except of global constants.…
A: #include<bits/stdc++.h>using namespace std;void sortArray(int arr[],int n){…
Q: In the flavor of the work begun there, continue to modify the is_pal_phrase function to work for…
A: # boolean function returning True/False for# "Is s is a palindromic word or phrase?",# disregarding…
Q: Use a set to store a list of exclude words. Read lines from the user and count the number of each of…
A: Please find the answer below :
Q: Write the syntax for a for loop that does the centered finite difference scheme on an arbitrary…
A: Centered finite difference schemes are the approximations to the derivatives that become more and…
Q: Given a list of numbers (nums), for each element in nums, calculate how many numbers in the list are…
A: Please find the answer below :
Q: 1. Explain the concept of a partially filled array, what variables are required and why we would…
A: A simple solution to the problem is to create an array whose length is great enough to hold the…
Q: Thr beir MATLAR griohing procedure, for example in 2D, is to take a vector of r- coordinates, x =…
A: Hello student Greetings Hope you are doing great. I will try my best to answer your question. Thank…
Q: Description: Write a function Partition (f, l, p, a) // which partitions array a into…
A: Algorithm: Quick sort is a highly efficient sorting algorithm and is based on partitioning of array…
Q: 5. We know that the roots of a quadratic equation of the form are given by the following equations:…
A: Algorithm: Start Read a, b, and c values and store them in coefficients array of size 3 Declare an…
Q: Given a list_of_strings (which are all lowercase letters), define and implement a function…
A: Below is the Algorithm to solve the above problem: Step 1 : Input n whcih denotes number of strings…
Q: Please code in C Pascal’s Triangle Version 2 The Pascal triangle can be used to compute the…
A: Here have to determine about pascal triangle print code
Q: Problem 3. (Encryption Program) Write a program called encrypt.py that accepts the public-key n…
A: Given:
Q: Exercise: 1- Modify example 1 to find and display the summation of values in the array.
A: Given To modify c++ program to the smallest number in the array to the summation of array elements.
Q: Question 7 Analyze the following code.
A: Based on analysis on both code output and answer is given below.
Q: a C user defined 2-[40p] (search and find) Write function that take an array and a value which you…
A: ALGORITHM:- 1. Declare the user-defined function which takes 2 arguments as input and returns the…
Q: 1.WAP in c language using recursive function function to find the largest and number of an array…
A: Note: As per the policy we can provide answers to only one question at a time, kindly repost another…
Q: Complete the function: bool search(vector v, int key). This function searches for value key in…
A: We can use linear search here in which we will compare every value of the vector with the key. If…
Q: 4. Write a recursive function that calculates the sum of the integers in a recursive list. Name the…
A: here in the question ask for summation of integer in recursive list and give one function called…
Q: Given a list_of_strings (which are all lowercase letters), define and implement a function…
A: Compare each character in first string with every other and if present in all strings in list, then…
Q: Fill-in-the-Blank To pass an array to a function, pass the _________ of the array.
A: Array is one the basic data structures that is used to store the element of the same data type. For…
Q: 21.14 LAB: Binary Search Binary search can be implemented as a recursive algorithm. Each call makes…
A: Introduction : Binary search a searching algorithm used in a sorted array. The binary search…
IN C++ please follow the example interface
Step by step
Solved in 2 steps with 2 images
- In c programming without pointer and function Problem Statement A matrix is a 2D array of numbers arranged in rows and columns. We give you a Matrix of N rows and M columns. Now your task is to do this operation on this matrix: If the value matches with the current row and column number then add 3 with the value. If the value matches with only the current row number then add 2 with the value. If the value matches with only the current column number then add 1 with the value. Input Format The first line contains N is the number of rows in this matrix and M is the number of columns in this matrix The second line contains a 2D array Arr[i][j]. Constraints 1 <= N, M <= 10 0 <= Arr[i][j] <= 100 Output Format Print the matrix after the operation is done. Sample Input 0 3 31 1 11 1 11 1 1 Sample Output 0 4 3 3 2 1 1 2 1 1[] [] partite_sets In the cell below, you are to write a function "partite_sets (graph)" that takes in a BIPARTITE graph as its input, and then returns a single list whose two entries are the partite sets of the graph as lists (the order of the sets outputed does not matter). After compiling the above cell, you should be able to compile the following cell and obtain the desired outputs. print (partite_sets({"A" : ["B", "C"], "B" : partite_sets({"A" : ["B", "C"], "B" : ["A"], "C" : ["A"]}), ["A", "D"], "C" : ["A", "D"], "D" : ["B", "C"]})) This should return [["B","C"], ["A"]] [["A","D"], ["B","C"]] (the order in which the entries appear does not matter) Python PythonPython please! Generalized image blender function Create a function blend images() which takes multiple RGB images as an input, and outputs a blended image. The function should accept following parameters 1. image list- A Python list of 3D arrays where each 3D array corresponds to an RGB image 2. weight list-A Python list of float values between (0, 1) corresponding to the pixel weight to be given to each image-e.g. [0.2, 0.3, 0.1, 0.4] for 4 images. The sum of the weights should be equal to 1. Test your function against a provided list of 5 images with following weight lists (i.e. 2 blended images) [0.2, 0.2, 0.2, 0.2, 0.2]- blend all 5 images [0.2, 0.3, 0.5]- blend first 3 images NOTE: DO NOT USE pre-existing image blending functions.
- Algorithm Efficiency 1- Programming Problem Part 1 Write a function that will have a list as an input, the task of the function is to check if all the elements in the list are unique,( i.e. no repetition of any value has occurred in the list), then the function returns true otherwise it returns false. Your program should include a main method that call the method to test it. (If you would use built-in functions in Python, use lists’ or dictionaries’ methods as we studied their time efficiency in class) 2- Algorithm AnalysisFor the function you implemented in part 1, please calculate T(n), which represents the running time of your algorithm in terms of n. Where n is the length of the list. Then find the order of magnitude of your algorithm (Big O). 3- Algorithms Comparison Please find another algorithm that solves part 1, write the code, calculate T(n) and find Big O. Then compare the efficiency with the algorithm from part1 to determine the more efficient one.2 Problem Statement You are given a number n. There is an array of strings that contains all the binary strings of length n where each string represents the plantation system where '1' represents plant A and '0' repres According to research if any two plant A comes together then they will stop the growth of the neighbors also. Your task is to find the number of plantations in which growth will not be affected. Note-Since the answer can be too long, return the answer modulo 1e9+7. Constraints: 1 <= n <= 100000 B Rules E Finish Input Format The first line contains an integer n. Output Format Print k-the number of strings satisfying the condition. Sample Testcase #0 Testcase Input Light Theme Java Testcase Output ENG € 40 INPython only* Use recursive function*. Define colorListCircles with 2 parameters Use def to define colorListCircles with 2 parameters The colorListCircles function must draw concentric circles using colors from a list. It has two parameters: the first specifies the radius of the largest circle, and the second is a list of colors. The number of concentric circles drawn is the length of the list, and these circles are colored, from largest to smallest, by the colors in the list from first to last. When viewed as nested rings, all rings should have the same thickness. If the list is empty, nothing should be drawn. We will test both how many circles are drawn as well as whether the correct circles are drawn in the correct order, you may not use any loops and you must use recursion. Also, you will still need to use drawDot. For full credit, your function should call drawDot in only one place, and should only contain one recursive call. Do not use any kind of loop Within the definition…
- Python only* Use recursive function*. Define colorListCircles with 2 parameters Use def to define colorListCircles with 2 parameters The colorListCircles function must draw concentric circles using colors from a list. It has two parameters: the first specifies the radius of the largest circle, and the second is a list of colors. The number of concentric circles drawn is the length of the list, and these circles are colored, from largest to smallest, by the colors in the list from first to last. When viewed as nested rings, all rings should have the same thickness. If the list is empty, nothing should be drawn. We will test both how many circles are drawn as well as whether the correct circles are drawn in the correct order, you may not use any loops and you must use recursion. Also, you will still need to use drawDot. For full credit, your function should call drawDot in only one place, and should only contain one recursive call. Do not use any kind of loop Within the definition…PYTHON Problem Statement Given a list of numbers (nums), for each element in nums, calculate how many numbers in the list are smaller than it. Write a function that does the calculation and returns the result (as a list). For example, if you are given [6,5,4,8], your function should return [2, 1, 0, 3] because there are two numbers less than 6, one number less than 5, zero numbers less than 4, and three numbers less than 8. Sample Input smaller_than_current([6,5,4,8]) Sample Output [2, 1, 0, 3]The mapped list pattern Our second pattern is the mapped list pattern, described in video 4 3 mapped list pattern. Often we need to write a function that takes a list as a parameter and returns a new list in which each item in the original list is "mapped" to a new item in the result list. For example, the following function takes a list of numbers as a parameter and returns a list of all the numbers squared, e.g. squares ( [1, 3, 7]) returns [1, 9, 49]. def squares (nums): "Returns the squares of the given numbers""" result = [] for num in nums: result.append (num * num) return result Although this is just a special case of the accumulator pattern, it is so common that we give it its own name: the mapped list pattern. Consider the following function: def squares(nums): ""Returns the squares of the given numbers""" result = [] for num in nums: result.append (num * num) return result If the main program calls print(squares ( [5, -3, 2, 7]) what is the state table for the function…
- Data structure/ C language / Graph / Dijkstra’s algorithm implement a solution of a very common issue: howto get from one town to another using the shortest route.* design a solution that will let you find the shortest paths betweentwo input points in a graph, representing cities and towns, using Dijkstra’salgorithm. Your program should allow the user to enter the input filecontaining information of roads connecting cities/towns. The programshould then construct a graph based on the information provided from thefile. The user should then be able to enter pairs of cities/towns and thealgorithm should compute the shortest path between the two cities/townsentered.Attached a file containing a list of cities/towns with the following data:Field 1: Vertex ID of the 1st end of the segmentField 2: Vertex ID of the 2nd of the segmentField 3: Name of the townField 4: Distance in KilometerPlease note that all roads are two-ways. Meaning, a record may representboth the roads from feild1 to field2…Use the accumulator pattern to write a function my_max(data), which returns the maximum number in the list data. You may assume the list data contains at least one number. You are not allowed to use the max function. It is not necessary to sort the data and any calls to sort or sorted will be disallowed as well. For example: Test Result numbers = [11, 99, 3, -6] 99 print (my_max(numbers)) negatives = [-3, -5, -9, -10] -3 print (my_max(negatives))HOME WORK 1-Write a steps to search for a node contain a given value in a S.L.L.L. its head is given by pointer variable ( First ) 2-Write Recursive function to count number of nodes in a given S.L.L.L. 3-Write a steps to count number of nodes contain odd number in a given S.L.L.L. its head is given by pointer variable ( First ). 4-Write a steps to test values stored in S.L.L.L. if it is in ascending order or not .