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

Concept explainers

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

Inserting an element to linked list after the address of the element

Program Plan:

  • Include required header files.
  • Create a structure for “Node”.
    • Declare a variable “element” to store the numeric values.
    • Declare a pointer “next” to store the address of the next link.
  • Define the function “insert_in_linked_list()”.
    • Declare a local pointer “ptr”.
    • Assign value for “ptr”.
    • Assign memory space for new node and place data value in it.
    • Link the new node.
    • Place the element in the list.
    • Link new node to the list.
  • Define the function “insert_element()” to add an element to the end of the list.
    • Iterate the “while” loop until last node becomes “null”.
      • Move pointer “ptr” to the pointer next node.
        • Assign memory allocation for the new node.
        • Create the new assigned memory space to the pointer “ptr”.
        • Place the element in the list.
        • Set “NULL” to the mark the end of the list.
  • Define the function “display_list()” to display all elements in the list.
    • If the “ptr” is null, then returns null.
    • Print the element in the list.
    • Call the function “display_list()” recursively with next element of the list.
  • Define main() function.
    • Declare required variables.
    • Declare pointer objects using structure.
    • Assign memory allocation for first element of list.
    • Set next of first element to “NULL”.
    • Use “for” loop to iterate 10 elements in the list.
      • Call the function “insert_element()” to insert each element in the list.
        • Call the function “display_list()” to display the elements in the list.
        • Read the element from user.
        • Read the index of new element from the user.
        • Set the temp pointer.
        • Use “for” loop to search for index value entered by the user.
          • Check condition and if the condition satisfies, then store the address in the pointer “temp_ptr”.
        • Call the function “insert_in_linked_list” with “add_element” and “temp_ptr”.
        • Call the function “display_list()” to display the elements of the list.

Blurred answer
Students have asked these similar questions
What is the ALU result if the 4-bit ALU Control signal is 0100? What happens if the ALU Control signal is 0101?
#include int main (void) { int i, *p, count } p = &count; = 10%; for (i = 5; i >= 0; i--) { count++; (*p) ++; } printf("count return 0; = %d, Have a wonderful day.\n", count); 1. [20 pts] What is the output of the program? Please explain why. 2. [15 pts] What is the gdb command to set a breakpoint in line 6 (p = &count;)? 3. [15 pts] Explain in your own words how the [break. need to use such command? ... if expr] command works. When might you
Please run and debug the following program and answer the questions.

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
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning
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 Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,