Question
Write a pseudo code algorithms for each of the different functions. Keep in mind that your algorithms should be language agnostic since you will be
Write a pseudo code algorithms for each of the different functions. Keep in mind that your algorithms should be language agnostic since you will be using this for both C and Java.
addNode: This should add a location to the end of the list.
Inputs: name, latitude, and longitude of the new location
Return the index of where the element was added (i.e., if the list was empty, it should return 0; if the new entry is the 4th entry, it should return 3), or -1 on an error.
Note: Our LList data structure only contains a reference to the head of the list, so you will not be able to directly add to the rear like was done in our class example!
addSortedNode: Add a location to the list sorted by longitude (i.e. the one that changes as you go east/west).
Inputs: name, latitude, and longitude of the new location
Return the index of where the element was added (i.e., if the list was empty, it should return 0; if the new entry is the 4th entry, it should return 3), or -1 on an error.
You can assume that if a user wants a list to be sorted, they will only use addSortedNode (not a mix of that and addNode).
remNode: Remove a location by name
Input: The name of the location to remove.
Note: If there happen to be two entries in the list with the same name, you should remove the entry closest to the head of the list.
Implementation tip: you cannot test if two strings are equal with == in C or Java! In C you will have to learn to use the strcmp function and in Java you will want to use .equals
Return the index where the element was removed, or -1 on an error.
clearList: Clear a list
Remove all locations in the list
Return the total number of entries that were removed.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started