Module 3-2 Pseudocode

docx

School

Southern New Hampshire University *

*We aren’t endorsed by this school

Course

260

Subject

Computer Science

Date

Feb 20, 2024

Type

docx

Pages

7

Uploaded by UltraCamelMaster345

Report
Raphael Tolentino CS-260 Prof. Lebel 19 Jul 2023 Pseudocode #include Parser File // translate csv type attachment into workable files for compiler Convert string to double Create struct Bid Create string variables bidId, title, fund Create double variable amount Create Bid constructor Initialize variable amount to 0.0 Create Class Linked List { Private Variable Struct Node { Create variable bid under struct Bid Create struct Node Create pointer variable ‘next’ pointing to Node’s memory address block Create Node constructor { Initialize next to null } Create another Node constructor with parameter aBid of struct Bid { Create local bid assigned to aBid to save any bids when Node method is called Initialize next to null again for safety to avoid overriding prveious constructor }
Create pointer node to variable head Create pointer node to variable tail Create int variable size and initalize to 0 } }; Public variables: LinkedList Create virtual LinkedList class that can be redefined in subsequent calls Create all functions/constructors such as Append, Prepend, PrintList, Remove, Bid Search Create int variable Size (different than previous ‘size’ variable with lower-case s) }; Create class LinkedList referencing constructor LinkedList { Initialize variables head and tail to null } Create class LinkedList referencing destructor for LinkedList to deallocate memory { } Create class LinkedList referencing function Append to contain logic for struct Bid { Create pointer variable node pointing memory address of Node and allocate a memory block for constructor Node with parameter bid If head does not contain anything (i.e. null) { then head is the new node } Else {If tail is not empty, then point the tail of the list to the new node} } Regardless, set tail to the new node Increase the size of the list }
Create class LinkedList referencing function Prepend { Create pointer variable node pointing memory address of Node and allocate a memory block for constructor Node with parameter bid If head node is not empty {make the next node as the head} Regardless, set head as new node Increase size of the list } Create class LinkedList referencing function PrintList { Point Node variable current to head node While current is not empty, iterate through the list and print bidId, bidtitle, bidamount, and bid fund respectively and print it in correlation with each other. Point current to the next node to avoid infinity loop } Create class LinkedList referencing function Remove { If head is not empty { If head node matches bidId, point a Node variable tempNode to the node next to head node to hold data from head’s address delete current head node set new head node to the tempNode containing the data } Point current variable to head node While the list not empty, iterate through the list If current variable points to a node matching the bidId { Create a tempNode variable to save the data of the next node next to where current is pointing Delete node where current is pointing Decrease size of list } } Point current variable to the next node }
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Create class LinkedList referencing function Search with parameters for string variable bidId { Point Node variable current to head node While current is not 0 { If what current variable is pointing to matches bidId { return the bid correlated to bidId } } Point current variable to next node to avoid infinity loop } Create int type class LinkedList referencing function Size { Return int variable size } Create displayBid printing function Print bid.Id, bid.title, bid.amount } Create getter functions for struct Bid { Create local variable of bid under global struct Bid Prompt user for ID Prompt user for Title Prompt user for Fund Prompt user for Amount Convert data to appropriate types Return local variable bid }
Create bid loader function that reads the csv attachments { Create try function to catch any errors when reading file Iterate through each row of the list Assign bidId to row i column 1 Assign title to row i column 0 Assign fund to row i colum 8 Assign amount to row i column 4 and convert the string types in the file to double types in the compiler and add symbol ‘$’ append to the list } Catch statement to throw errors { } Create main { Process command line arguments } Call inherent function clock_t and assign ‘ticks’ variable Create int type variable choice and initialize to 0 While variable choice is not 9, iterate through the list and await cases Print menu options 1-9 1 – Enter bid 2 – Load bids 3 – Display All Bids 4 – Find Bid 5 – Remove bid 9 – Exit
Receive user input Label cases based on menu option Case 1 { assign local variable bid to getter function Call append function to append received input and add to bidList add received bid and put it in function displayBid break } Case 2 { assign variable ticks to function clock create loadBids function that calls csvPath, and address of bidList Print bidList size Print time it took to load bidList size break } Case 3 { calls function PrintList to print the current bidList break } Case 4 { call function Search and input bidKey If bidId is found, display bidId Else print bid Id not found Print time it took to Search } Case 5 { calls function Remove with input bidKey break
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
} } Print “Good Bye” Return 0 }