logo

The code performs a sorting operations

   

Added on  2022-08-21

4 Pages869 Words15 Views
Question One:
The code performs a sorting operation.
It does this using a nested loop that iteratively compares each of the values in the
original list with the rest and shifts the lesser value to the left. The outer iteration is
repeated until all elements in the list have been compared with each other. The inner
iteration goes on until a larger value is found then an assignment is done before
proceeding to the next iteration.
The result is a list sorted in descending order.
Question Two:
Iterations: The number of iterations(loops) done around the data. The more iterations
made, the slower the algorithm will appear to be
Size of n: The size/value of n also greatly affects the effectiveness of the data. The
large this value is, the slower the algorithm will appear to be
Question Three:
Topological sorting is the linear ordering of the vertices in a graph in such a way that
for each directed edge ab from vertex a to b, a always precedes b in ordering
Question Four:
methodA has time complexity of O(n)
methodB has time complexity of O(nLog(n))
methodC has time complexity of O(nLog(n))
Question Five:
Missing
Question Six:
a. Internal sorting, this is where data has to be sorted in the main memory always
which implies faster access. Here the complete sorting happens in the main memory
while in external sorting sorting happens outside the main memory.
The code performs a sorting operations_1
b. An algorithm is referred to as stable when the two objects that has equal keys is in
the same order in the output as they are in the input while its unstable if they are
unequal
c. n-place update does the sorting by working in the allocated memory additional
memory in sorting algorithms require more memory in sorting process.
Question Seven:
The main methods or operations which are characterize of queues are
1. enqueue() − this method checks whether the queue is full or not, if full; print an
overflow error, else; increment the end of the queue with one more item
2. dequeue() − The method also checks if the queue is empty. if its empty; print an
underflow error and exit the program else; access the element at the beginning of
the queue
The code performs a sorting operations_2

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Programming: Sorted Linked List, Binary Tree Traversal, and Efficient Sorting Algorithms
|6
|627
|111

TCSS142 Computer Science and Systems
|8
|2141
|359