Please follow the information here, explain your answer, and show that your code works. Your help is much appreciated.
Complete images are not posted (I am reffering to examples in 4 and 6) That's why their might be a little difference in psedocode while using while loop or accessing a field from a record By understanding the concept, you can change it by yourself but if you feel any difficulty then paste the complete image and tell me through comments
Below is the explaination of pseudocode -
Take 3 pointers - current(points to current record), previous(points to previous of current record) and temp(points to record to be deleted)
Initialise current to start and previos to NULL check whether account number of current is same as the account number to be deleted
If so then check -
If previous is NULL (It means that 1st record is to be deleted) In this scenario,store start in temp and update start and finally release memory
Else store current in temp ,update next of previous and finally release memory
Else
move current to next of current
Finally if current reaches to NULL,It means record to be deleted is not present hence return -1
Below is the Pseudocode Note that I have done proper indentation but this code is automatically left alligned on this interface
define a pointer to record called prev
define a pointer to record called cur
define a pointer to record called temp
define an int called cur_account_no
copy from NULL to prev
copy from start to cur
while( cur is not equal to NULL )
copy from accountno in the record whose address is in cur to cur_account_no
if( cur_account_no is equal to uaccountno )
if( prev is equal to NULL )
copy from start to temp
copy from next in the record whose address is in start to start
release the space whose address is in temp
return 0
else
copy from cur to temp
copy from next in the record whose address is in cur to next in the record whose address is in prev
release the space whose address is in temp
return 0
return -1
Below is its screenshot -(with indentation)
I have tried to explain it in very simple language and I hope that
i have answered your question satisfactorily.Leave doubts in
comment section if any.
Please follow the information here, explain your answer, and show that your code works. Your help...
****Using C and only C**** I have some C code that has the function addRecord, to add a record to a linked list of records. However, when I run it, the program exits after asking the user to input the address. See picture below: Here is my code: #include<stdio.h> #include<stdlib.h> struct record { int accountno; char name[25]; char address[80]; struct record* next; }; void addRecord(struct record* newRecord) //Function For Adding Record at last in a SinglyLinkedList { struct record *current,*start,*temp;...
can someone please double check my code here are the requirements please help me fulfill the requirements Using the material in the textbook (NumberList) as a sample, design your own dynamic linked list class (using pointers) to hold a series of capital letters. The class should have the following member functions: append, insert (at a specific position, return -1 if that position doesn't exist), delete (at a specific position, return -1 if that position doesn't exist), print, reverse (which rearranges...
****find_last_node.c #include <stdio.h> #include "linked_list.h" int main(){ struct node *linked_list = NULL; linked_list = add_to_list(linked_list, 5, 'a'); linked_list = add_to_list(linked_list, 10, 'b'); linked_list = add_to_list(linked_list, 4, 'c'); linked_list = add_to_list(linked_list, 10, 'd'); linked_list = add_to_list(linked_list, 5, 'e'); linked_list = add_to_list(linked_list, 7, 'f'); linked_list = add_to_list(linked_list, 5, 'g'); linked_list = add_to_list(linked_list, 3, 'h'); int search_number; printf("Enter number you want to search for:"); scanf("%d", &search_number); struct node *last_node = find_last(linked_list, search_number); if (last_node != NULL) { printf("Node found: value = %d and...
// C code // If you modify any of the given code, the return types, or the parameters, you risk getting compile error. // Yyou are not allowed to modify main (). // You can use string library functions. #include <stdio.h> #include <stdlib.h> #include <string.h> #pragma warning(disable: 4996) // for Visual Studio #define MAX_NAME 30 // global linked list 'list' contains the list of patients struct patientList { struct patient *patient; struct patientList *next; } *list = NULL; ...
Need this in C++ Goals: Your task is to implement a binary search tree of linked lists of movies. Tree nodes will contain a letter of the alphabet and a linked list. The linked list will be an alphabetically sorted list of movies which start with that letter. MovieTree() ➔ Constructor: Initialize any member variables of the class to default ~MovieTree() ➔ Destructor: Free all memory that was allocated void printMovieInventory() ➔ Print every movie in the data structure in...
ASSIGNMENT DUE DATE GOT PUSHED BACK TO LATE THIS WEEK. PLEASE READ COMMENTS AND CODE BEFORE ANSWERING CODING SECTIONS HW07 #Q1-Q5 HW08 #Q1-Q2 // READ BEFORE YOU START: // Please read the given Word document for the project description with an illustrartive diagram. // You are given a partially completed program that creates a list of students for a school. // Each student has the corresponding information: name, standard, and a linked list of absents. // Please read the instructions...
Need help for C program. Thx #include <stdio.h> #include <string.h> #include <ctype.h> // READ BEFORE YOU START: // This homework is built on homework 06. The given program is an updated version of hw06 solution. It begins by displaying a menu to the user // with the add() function from the last homework, as well as some new options: add an actor/actress to a movie, display a list of movies for // an actor/actress, delete all movies, display all movies,...
// CSE240 Spring 2019 HW 7 & 8 // Write your name here // Write the compiler used: Visual studio or gcc // READ BEFORE YOU START: // You are given a partially completed program that creates a linked list of patient information. // The global linked list 'list' is a list of patients with each node being struct 'patientList'. // 'patientList' consists of struct 'patient' which has: patient name, room number, and a linked list of 'doctors'. // The...
Programming in C: I am trying to modify this linked list to be doubly linked list. I’m also trying to add a print in reverse function. I’m really struggling with how to change the insert function to doubly link the nodes without effecting the alphabetical sorting mechanism. Example of desired output: Enter your choice: 1 to insert an element into the list. 2 to delete an element from the list. 3 to end. ? 1 Enter a character: a The...
Working in C++, Complete the code. // Lab 9 code /* Insert leading comments with your name and the date. Describe the purpose of the code. Also, list each pointer and describe how it is used to enable the selection sort for the linked list structure. */ /* Insert code as described by the comments. */ /* Add comments to each line of code that uses a pointer, describing how it is being used. */ #include <iostream> using namespace std;...