Instructions
We will carry on working with functions! Once more, all input and output has been taken care of for you. All you need to do is finish off the function tableMin that finds the minimum value within a table (2-D list).
Details
Input
Processing
Output
Sample input/output:
Program input | Program output |
4 6 2 3 4 3 4 2 1 4 8 7 2 8 4 3 7 |
Minimum value: 1 |
There is given code
def tableMin ( ):
"""
FUNCTION: tableMin ( table : list ) -> int
Finds the minimum value within an integer table.
Args:
@param table (list): 2-D integer table (list)
Returns:
@return int: minimum value contained within the table
"""
return
#=========================================================================
# PLEASE END YOUR WORK HERE
#=========================================================================
def main() :
N = int( input() )
table = []
for i in range( N ) :
inputData = input().split()
newRow = []
for j in inputData :
newRow.append( int(j) )
table.append( newRow )
print("Minimum value: ", tableMin( table ))
return
#-----------------#
# Body of program #
#-----------------#
main()
def tableMin(table): """ FUNCTION: tableMin ( table : list ) -> int Finds the minimum value within an integer table. Args: @param table (list): 2-D integer table (list) Returns: @return int: minimum value contained within the table """ if len(table) > 0: # if there is any data in the table smallest = table[0][0] # set first value of first row as smallest for lst in table: # go through each row for num in lst: # go through each value of the row if num < smallest: # if a smaller number is found smallest = num # then update smallest variable return smallest # finally return the smallest value found in the table # ========================================================================= # PLEASE END YOUR WORK HERE # ========================================================================= def main(): N = int(input()) table = [] for i in range(N): inputData = input().split() newRow = [] for j in inputData: newRow.append(int(j)) table.append(newRow) print("Minimum value: ", tableMin(table)) return # -----------------# # Body of program # # -----------------# main()
Instructions We will carry on working with functions! Once more, all input and output has been...
In C language Write a program that includes a function search() that finds the index of the first element of an input array that contains the value specified. n is the size of the array. If no element of the array contains the value, then the function should return -1. The program takes an int array, the number of elements in the array, and the value that it searches for. The main function takes input, calls the search()function, and displays...
use c++ language, keep it simple i am using code block Exercise #2: Digitise a number Write the function digitiselint, int[]) of type int, which takes an integer N and finds all the digits of that integer and save them in an array. The function then returns the number of digits in N. Write the main() program that reads an integer, calls the function digitisel ), and prints the digits in reverse order. Sample input/output: Enter an integer: 2309456 The...
Need to write a MIPS assembly program that finds the minimum and maximum and sum of a stored array. It also finds the locations of the minimum and maximum. The interaction between the main program and the function is solely through the stack. The function stores $ra immediately after being called and restores $ra before returning to main. The main program reserves a static C like array (index starts from 0) of 10 elements and initializes it. The maximum should...
#include <stdio.h> // Define other functions here to process the filled array: average, max, min, sort, search // Define computeAvg here // Define findMax here // Define findMin here // Define selectionSort here ( copy from zyBooks 11.6.1 ) // Define binarySearch here int main(void) { // Declare variables FILE* inFile = NULL; // File pointer int singleNum; // Data value read from file int valuesRead; // Number of data values read in by fscanf int counter=0; // Counter of...
Instructions Good news! You have are nearly finished with the semester! Today’s problem is going to be to modify a program to match the actual check used to verify Social Insurance Numbers. Don’t worry, the first part of the solution has been taken care of for you. You just need to modify it to also check the bits in BOLD font. A valid SIN is calculated by multiply odd-positioned digits (1st, 3rd, 5th, 7th, & 9th) by 1 and even-positioned...
In class we wrote a method closestPairFast that on an input array of numbers, finds the distance of the closest pair by first sorting the input array and then finding the closest adjacent pair. (See the file ClosestPair1D.java in the Code folder on D2L.) In this problem, you are asked to modify the method so that it returns an integer array consisting of the indices of the closest pair in the original array. If there is a tie, just return...
Please answer in C++, and Please consider ALL parts of the question, especially where it asks the user for V. So there should be a "cin >> V" somewhere. The last guy did not answer it correctly so please make sure you do! Thank You!! Question 1 Write the following two functions. The first function accepts as input a two-dimensional array of integers. It returns two results: the sum of the elements of the array and the average The second...
Map, Filter, and Reduce are three functions commonly used in functional programming. For this assignment you will be implementing all three, along with three minor functions that can be passed to them. Map The map function takes as arguments a function pointer and a integer vector pointer. It applies the function to every element in the vector, storing the results in-order in a new vector. It then returns a pointer to a new vector. You should pass your square function...
9.10: Reverse Array Write a function that accepts an int array and the array’s size as arguments. The function should create a copy of the array, except that the element values should be reversed in the copy. The function should return a pointer to the new array. Demonstrate the function by using it in the main program that reads an integer N (that is not more than 50) from standard input and then reads N integers from a file named...
in C++ and also each function has its own main function so please do the main function as well. Previously when i asked the question the person only did the function and didn't do the main function so please help me do it. 1-1. Write a function that returns the sum of all elements in an int array. The parameters of the function are the array and the number of elements in the array. The function should return 0 if...