EBK C PROGRAMMING:
8th Edition
ISBN: 9780357156025
Author: Malik
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Question
Chapter 16, Problem 1PE
Program Plan Intro
1. Variables mentioned below are used:
- inputArr − an array that holds all the input elements.
- size − the size of the input array.
- searchElement − the key element that is to be searched inside the array.
- returnVal − position of key element inside array.
2. Functions mentioned below are used:
- main()- main function in the program that reads the input and prints the output.
- bSort()- function that performs the bubble sorting of array elements.
- sequentialSearch()- function that performs the sequential search.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a program to test the sequential search algorithm that you wrote of this chapter. Use either the function bubbleSort or insertionSort to sort the list before the search.
PYTHON
Complete the function below, which takes two arguments:
data: a list of tweets
search_words: a list of search phrases
The function should, for each tweet in data, check whether that tweet uses any of the words in the list search_words. If it does, we keep the tweet. If it does not, we ignore the tweet.
data = ['ZOOM earnings for Q1 are up 5%', 'Subscriptions at ZOOM have risen to all-time highs, boosting sales', "Got a new Mazda, ZOOM ZOOM Y'ALL!", 'I hate getting up at 8am FOR A STUPID ZOOM MEETING', 'ZOOM execs hint at a decline in earnings following a capital expansion program']
Hint: Consider the example_function below. It takes a list of numbers in numbers and keeps only those that appear in search_numbers.
def example_function(numbers, search_numbers): keep = [] for number in numbers: if number in search_numbers(): keep.append(number) return keep
def search_words(data, search_words):
To determine if two lists of integers are equivalent, you must write a function that accepts the lists as input and returns true or false (i.e. contain the same values). The greatest value of each list must be shown if the lists are dissimilar and the procedure is effective.
Knowledge Booster
Similar questions
- Two arrays list1 and list2 are identical if they have the same contents. Write a function that returns true if list1 and list2 are identi- cal using the following header: bool isEqual(const int list1[], const int list2[], int size) Write a test program that prompts the user to enter two lists of integers and dis- plays whether the two are identical. Here are the sample runs. Note that the first number in the input indicates the number of the elements in the list. This number is not part of the list. Assume the list size is maximum 20.arrow_forwardThe Humane Society’s goal is to find adoptive homes for each of the animals in their care. Design a program that lets theuser enter the total animals adopted on each weekday … Monday through Friday … into a LIST. The program shouldcalculate and display the total number of animals adopted during the week, the average number of animals adopted perday, the highest number and the lowest number adopted per day. (Note that you should use a LIST to store thenumbers, and you should use a TUPLE to store the names of the days of the week, then use a loop to process the tuple.)arrow_forwardplease use pythonarrow_forward
- Create a program that sorts a list in ascending order. Assume that the list is in descending order. Write a function that has the number of elements and an array as input. Without the use of any sorting algorithms rearrangethe items in ascending order. Provide screenshots of the fully functional application. NB: No item comparisons should be used in the code.arrow_forwardThe function last_words in python takes one parameter, fname, the name of a text file, and returns a list containing the last word from each line of the file. For example, if the file contents are: apples are red bananas are yellow limes are green then the list ["red", "yellow", "green"] should be returned. NOTE: You may assume the file will contain no blank lines. BIG HINT: If line is a string representing a line of text (inside a for loop!), then L = line.split() creates a list of the words in the line. For example: Test Result L = last_words("wordlist1.txt") print(L) ['happy', 'sad', 'angsty', 'euphoric', 'maudlin']arrow_forwardYou can shuffle a list using random.shuffle(lst). Write your own function without using random.shuffle(lst) to shuffle a list and return the list. Use the following function header:def shuffle(lst):Write a test program that prompts the user to enter a list of numbers, invokes the function to shuffle the numbers, and displays the numbers.arrow_forward
- Notice that all of the data in the inner lists are represented as strings. You are to write the function convert_data, which should make modifications to the inner lists according to the following rules: If and only if a string represents a whole number (ex: '3' or '3.0'), convert the string to an int. If and only if a string represents a number that is not a whole number (ex: '3.14'), convert the string to a float. Otherwise, leave the string as a str.HINT: The provided helper function is_number may be used (attached image). QUESTION: Complete the docstring below.def convert_data(data: List[list]) -> None: """Convert each string in data to an int if and only if it represents a whole number, and a float if and only if it represents a number that is not a whole number. >>> d = [['abc', '123', '45.6', 'car', 'Bike']] >>> convert_data(d) >>> d [['abc', 123, 45.6, 'car', 'Bike']] >>> d = [['ab2'], ['-123'], ['BIKES', '3.2'],…arrow_forwardIn python Create a helper function as wellarrow_forward$ Print the required.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning