Systems Architecture
Systems Architecture
7th Edition
ISBN: 9781305080195
Author: Stephen D. Burd
Publisher: Cengage Learning
bartleby

Concept explainers

Question
Book Icon
Chapter 3, Problem 2PE
Program Plan Intro

Inserting an element to array

Program Plan:

  • Include required header files.
  • Declare an array with the size “100”.
  • Declare an integer variable “top_value” to store the index of last inserted element.
  • Define the function “insert_in_array()” with two parameters “element” and “position”. This function is used to insert an element to specified position of an array.
    • Declare required variable.
    • Check condition for “position”. If “position” is less than “0” or “position” is greater than “top_value”, then display an error message.
    • Otherwise, that is if the position is in the range.
      • Insert an element one by one in the specified position using “for” loop.
        • Shift elements by “1” position to the right.
      • Insert the element at the desired location.
      • Increment the value of “top_value” by “1”.
  • Define the function “display_array()” which is used to display the elements in the array.
    • Declare required variables.
    • If the “top_value” is equal to “0” that is there is no element in the array, then display an error message.
    • Otherwise, display all elements in the array.
  • Define main function.
    • Declare required variables.
    • Set “top_value” to “0”.
    • Performs “do-while” loop. This loop will perform until the user enters the choice “3”.
      • Display menu options to user.
      • Read choice from user.
      • Check user entered option using “switch” statement.
        • If the user entered option is “1”, then
          • Read the position for element from user.
          • Read an element for given position from user.
          • Call the function “insert_in_array()” with argument “insert_element” and “idx”.
            • If user entered option is “2”, then display the array elements by calling the function “display_array()”.

Blurred answer
Students have asked these similar questions
High and Low Project Design a modular program which asks the user to enter a list of numbers. The numbers must be stored in an array. The program then finds the index of the first occurrence of the smallest element in the array and the last occurrence of the largest element in the array. The program displays the position and value of each of these items. Rather than processing items as they are read in as we have done so far, this program is asking you to read all the data into memory and then do the processing. Your design should contain a minimum of two functions. The first function takes as input the array and returns the indexof the location of the first occurrence of the smallest item. The second function takes the array as input and returns the index of the location of the last occurrence of the largest item in the array. Your functions do not need to return the highest and lowest data values since having the index is all that is needed to access the values. Do not display the…
Programming Language: C++ You have been hired by Google to work on their YouTube videos search team.  Every YouTube video has a unique ID and those IDs are in unsorted order.  As a software engineer, you are required to make a YouTube search engine which works for very user.  Create a test engine that only holds seven YouTube IDs.  Prompt for and get from the user the seven IDs and store them in an integer array.  Then sort and print the array using the insertion sort algorithm.  Finally, use a sentinel loop to prompt for and get from the user a series of IDs.  For each ID, perform a binary search on the array and tell the user if it was found or not.  If found, print the index where the ID is stored.  Continue to prompt the user for an ID until entering the sentinel value of -999.   In addition to function main, define the following two functions:   void insertion_sort(int arr[], int arr_size)   int binary_search(int sort_arr[], int size_array, int search_value) binary_seacrh returns…
1. Display Function Implement a function to display the contents of the patient_list array.  Add code to call this function. Note that there are multiple places where this function needs to be called. Look for the  // TODO comments to find the correct locations. 2. Sorting the array by Age Implement the code to sort the contents of the patient_list array based on the value stored in the age field. To do this you will need to implement code that relies on the qsort function from the C Standard library A function that compares two patient elements, based on the value stored in the age field. A call to the qsort function, which includes the array to be sorted, the number of elements in the array, the size of each array element and the function used to compare the array elements. Add code to call the qsort function, using the age comparison function that you implemented.  This code should be placed just under the appropriate // TODO comment in main().  Sorting the array by…

Chapter 3 Solutions

Systems Architecture

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning