Module 4-2 Pseudocode and Reflection

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

3

Uploaded by UltraCamelMaster345

Report
Raphael Tolentino CS260 Prof. Lebel 22 Jul 2023 Pseudocode Task 1a: Selection Sorting Logic for selectionSort() : void selectionSort(vector<Bid>& bids) { create local variable for beginning index position create local variable for end index position create a for loop to increment the beginning variable through the list after the inner for loop is satisfied create an inner for loop that iterates the end index variable create an if condition statement to compare bid titles alphabeti- cally assign local beginning variable to the end variable } } create swapping logic out side the loops by swapping the low beginning vari- able and the end index variable } } Task 1b: selectionSort method call Case 3: create local variable to track CPU ticks call selectionSort method print the size of vector Bid bids to tell the console how many have been sorted initialize variable ticks to clock() - ticks to set current CPU ticks minus starting clock ticks print time in milliseconds print time in seconds Task 2a: quickSort - Partition create method called partition that take vector Bid bids, int begin, int end as param- eters { create local low variable and assign to parameter begin create local end variable and assign to parameter end define the pivot point of the vector establish a boolean keyword done and set to false while the keyword is not true iterate through {
while loop to iterate through the index starting at low to the pivot to com- pare { title alphabetically increment low index variable left to right } while loop to iterate through the index starting at the pivot to the end to compare { title alphabetically decrement the high index variable } if the low and high index meet, end the loop otherwise, swap the low and high index return the high index value; Task 2a: quickSort - quickSort Logic create quickSort method that take in parameter vector Bid bids, int begin, int end create local int variable mid and initialize to 0 if there are no more bids to sort, end the call set mid to call and partition the vector into low and high parts recursive call for the quickSort method with parameters bids, begin, mid recursive call for the quickSort method with parameters bids, mid + 1, end } Task 2b: quickSort method call Case 4: create local variable to track CPU ticks initialize quickSort call to sort vector bids, starting at index 0, ending at bids.size() - 1 initialize variable ticks to clock() - ticks to set current CPU ticks minus starting clock ticks print time in milliseconds print time in seconds Reflection Learning from the previous module, I sought to break down the coding problem by accomplishing the pseudocode first. In so doing, I was able to accomplish a step-by- step building of the code by breaking down each functionality given the task. Addi- tionally, I finished the zyBooks lessons early before I started the pseudocode and it
helped tremendously in my knowledge on how the sorting algorithms affect the data structure presented in the starter code. I encountered some problems with the shortcut of vector data swapping with the compiler stating it’s an error. I e-mailed the professor and was told to ignore the error and compile anyway so I did. Another issue I ran into was forgetting to create local variables in each function and trying to call them in the loop-logics. I was able to solve this issue by just going over the code and making sure to read the errors throwing it, other than that, it was mostly re- viewing the zyBooks lesson and making sure the logic is sound.
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